mirror of
https://github.com/Alex313031/thorium.git
synced 2025-01-10 11:57:48 -03:00
Update chrome_content_browser_client.cc
This commit is contained in:
parent
7641cdfd6f
commit
0041f6f619
1 changed files with 51 additions and 40 deletions
|
@ -151,7 +151,7 @@
|
|||
#include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
|
||||
#include "chrome/browser/ui/webui/log_web_ui_url.h"
|
||||
#include "chrome/browser/universal_web_contents_observers.h"
|
||||
#include "chrome/browser/usb/frame_usb_services.h"
|
||||
#include "chrome/browser/usb/chrome_usb_delegate.h"
|
||||
#include "chrome/browser/vr/vr_tab_helper.h"
|
||||
#include "chrome/browser/webapps/web_app_offline.h"
|
||||
#include "chrome/browser/webauthn/webauthn_pref_names.h"
|
||||
|
@ -722,12 +722,8 @@ bool IsSSLErrorOverrideAllowedForOrigin(const GURL& request_url,
|
|||
if (prefs->GetBoolean(prefs::kSSLErrorOverrideAllowed))
|
||||
return true;
|
||||
|
||||
if (!prefs->GetList(prefs::kSSLErrorOverrideAllowedForOrigins))
|
||||
return false;
|
||||
|
||||
base::Value::ConstListView allow_list_urls =
|
||||
prefs->GetList(prefs::kSSLErrorOverrideAllowedForOrigins)
|
||||
->GetListDeprecated();
|
||||
const base::Value::List& allow_list_urls =
|
||||
prefs->GetValueList(prefs::kSSLErrorOverrideAllowedForOrigins);
|
||||
if (allow_list_urls.empty())
|
||||
return false;
|
||||
|
||||
|
@ -845,7 +841,7 @@ bool HandleNewTabPageLocationOverride(
|
|||
#if !BUILDFLAG(IS_ANDROID)
|
||||
// Check if the current url is allowlisted based on a list of allowlisted urls.
|
||||
bool IsURLAllowlisted(const GURL& current_url,
|
||||
base::Value::ConstListView allowlisted_urls) {
|
||||
const base::Value::List& allowlisted_urls) {
|
||||
// Only check on HTTP and HTTPS pages.
|
||||
if (!current_url.SchemeIsHTTPOrHTTPS())
|
||||
return false;
|
||||
|
@ -877,12 +873,10 @@ bool IsAutoplayAllowedByPolicy(content::WebContents* contents,
|
|||
return false;
|
||||
|
||||
// Check if the current URL matches a URL pattern on the allowlist.
|
||||
const base::Value* autoplay_allowlist =
|
||||
prefs->GetList(prefs::kAutoplayAllowlist);
|
||||
return autoplay_allowlist &&
|
||||
prefs->IsManagedPreference(prefs::kAutoplayAllowlist) &&
|
||||
IsURLAllowlisted(contents->GetURL(),
|
||||
autoplay_allowlist->GetListDeprecated());
|
||||
const base::Value::List& autoplay_allowlist =
|
||||
prefs->GetValueList(prefs::kAutoplayAllowlist);
|
||||
return prefs->IsManagedPreference(prefs::kAutoplayAllowlist) &&
|
||||
IsURLAllowlisted(contents->GetURL(), autoplay_allowlist);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1719,7 +1713,7 @@ bool ChromeContentBrowserClient::
|
|||
ShouldCompareEffectiveURLsForSiteInstanceSelection(
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* candidate_site_instance,
|
||||
bool is_main_frame,
|
||||
bool is_outermost_main_frame,
|
||||
const GURL& candidate_url,
|
||||
const GURL& destination_url) {
|
||||
DCHECK(browser_context);
|
||||
|
@ -1727,7 +1721,7 @@ bool ChromeContentBrowserClient::
|
|||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
return ChromeContentBrowserClientExtensionsPart::
|
||||
ShouldCompareEffectiveURLsForSiteInstanceSelection(
|
||||
browser_context, candidate_site_instance, is_main_frame,
|
||||
browser_context, candidate_site_instance, is_outermost_main_frame,
|
||||
candidate_url, destination_url);
|
||||
#else
|
||||
return true;
|
||||
|
@ -2424,6 +2418,12 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
|
|||
command_line->AppendSwitch(blink::switches::kPersistentQuotaEnabled);
|
||||
}
|
||||
|
||||
// Enable legacy quota API if enabled by enterprise policy.
|
||||
if (prefs->GetBoolean(storage::kPrefixedStorageInfoEnabled)) {
|
||||
command_line->AppendSwitch(
|
||||
blink::switches::kPrefixedStorageInfoEnabled);
|
||||
}
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
InstantService* instant_service =
|
||||
InstantServiceFactory::GetForProfile(profile);
|
||||
|
@ -2726,6 +2726,7 @@ ChromeContentBrowserClient::AllowServiceWorker(
|
|||
const absl::optional<url::Origin>& top_frame_origin,
|
||||
const GURL& script_url,
|
||||
content::BrowserContext* context) {
|
||||
DCHECK(context);
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
GURL first_party_url = top_frame_origin ? top_frame_origin->GetURL() : GURL();
|
||||
|
||||
|
@ -3037,6 +3038,19 @@ bool ChromeContentBrowserClient::IsSharedStorageAllowed(
|
|||
accessing_origin);
|
||||
}
|
||||
|
||||
bool ChromeContentBrowserClient::IsPrivateAggregationAllowed(
|
||||
content::BrowserContext* browser_context,
|
||||
const url::Origin& top_frame_origin,
|
||||
const url::Origin& reporting_origin) {
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context);
|
||||
auto* privacy_sandbox_settings =
|
||||
PrivacySandboxSettingsFactory::GetForProfile(profile);
|
||||
DCHECK(privacy_sandbox_settings);
|
||||
|
||||
return privacy_sandbox_settings->IsPrivateAggregationAllowed(
|
||||
top_frame_origin, reporting_origin);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
void ChromeContentBrowserClient::OnTrustAnchorUsed(
|
||||
content::BrowserContext* browser_context) {
|
||||
|
@ -3466,7 +3480,8 @@ bool ChromeContentBrowserClient::CanCreateWindow(
|
|||
frame_name, disposition, features, user_gesture, opener_suppressed);
|
||||
NavigateParams nav_params =
|
||||
blocked_params.CreateNavigateParams(opener->GetProcess(), web_contents);
|
||||
return blocked_content::MaybeBlockPopup(
|
||||
return !blocked_content::ConsiderForPopupBlocking(disposition) ||
|
||||
blocked_content::MaybeBlockPopup(
|
||||
web_contents, &opener_top_level_frame_url,
|
||||
std::make_unique<ChromePopupNavigationDelegate>(
|
||||
std::move(nav_params)),
|
||||
|
@ -4262,20 +4277,21 @@ bool ChromeContentBrowserClient::PreSpawnChild(
|
|||
if (chrome::kBrowserProcessExecutableName != exe_path.BaseName().value())
|
||||
return true;
|
||||
|
||||
sandbox::MitigationFlags mitigations = policy->GetProcessMitigations();
|
||||
sandbox::TargetConfig* config = policy->GetConfig();
|
||||
if (config->IsConfigured())
|
||||
return true;
|
||||
|
||||
sandbox::MitigationFlags mitigations = config->GetProcessMitigations();
|
||||
mitigations |= sandbox::MITIGATION_FORCE_MS_SIGNED_BINS;
|
||||
sandbox::ResultCode result = policy->SetProcessMitigations(mitigations);
|
||||
sandbox::ResultCode result = config->SetProcessMitigations(mitigations);
|
||||
if (result != sandbox::SBOX_ALL_OK)
|
||||
return false;
|
||||
|
||||
if (policy->GetConfig()->IsConfigured())
|
||||
return true;
|
||||
|
||||
// Allow loading Chrome's DLLs.
|
||||
for (const auto* dll : {chrome::kBrowserResourcesDll, chrome::kElfDll}) {
|
||||
result = policy->GetConfig()->AddRule(sandbox::SubSystem::kSignedBinary,
|
||||
sandbox::Semantics::kSignedAllowLoad,
|
||||
GetModulePath(dll).value().c_str());
|
||||
result = config->AddRule(sandbox::SubSystem::kSignedBinary,
|
||||
sandbox::Semantics::kSignedAllowLoad,
|
||||
GetModulePath(dll).value().c_str());
|
||||
if (result != sandbox::SBOX_ALL_OK)
|
||||
return false;
|
||||
}
|
||||
|
@ -4722,12 +4738,11 @@ ChromeContentBrowserClient::GetDevToolsBackgroundServiceExpirations(
|
|||
auto* pref_service = profile->GetPrefs();
|
||||
DCHECK(pref_service);
|
||||
|
||||
auto* expiration_dict = pref_service->GetDictionary(
|
||||
const auto& expiration_dict = pref_service->GetValueDict(
|
||||
prefs::kDevToolsBackgroundServicesExpirationDict);
|
||||
DCHECK(expiration_dict);
|
||||
|
||||
base::flat_map<int, base::Time> expiration_times;
|
||||
for (auto it : expiration_dict->DictItems()) {
|
||||
for (auto it : expiration_dict) {
|
||||
// key.
|
||||
int service = 0;
|
||||
bool did_convert = base::StringToInt(it.first, &service);
|
||||
|
@ -5668,17 +5683,6 @@ bool ChromeContentBrowserClient::ShouldForceDownloadResource(
|
|||
#endif
|
||||
}
|
||||
|
||||
void ChromeContentBrowserClient::CreateWebUsbService(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
mojo::PendingReceiver<blink::mojom::WebUsbService> receiver) {
|
||||
if (!base::FeatureList::IsEnabled(features::kWebUsb))
|
||||
return;
|
||||
|
||||
CHECK(render_frame_host);
|
||||
FrameUsbServices::CreateFrameUsbServices(render_frame_host,
|
||||
std::move(receiver));
|
||||
}
|
||||
|
||||
content::BluetoothDelegate* ChromeContentBrowserClient::GetBluetoothDelegate() {
|
||||
if (!bluetooth_delegate_) {
|
||||
bluetooth_delegate_ = std::make_unique<permissions::BluetoothDelegateImpl>(
|
||||
|
@ -5715,6 +5719,12 @@ content::HidDelegate* ChromeContentBrowserClient::GetHidDelegate() {
|
|||
return hid_delegate_.get();
|
||||
}
|
||||
|
||||
content::UsbDelegate* ChromeContentBrowserClient::GetUsbDelegate() {
|
||||
if (!usb_delegate_)
|
||||
usb_delegate_ = std::make_unique<ChromeUsbDelegate>();
|
||||
return usb_delegate_.get();
|
||||
}
|
||||
|
||||
content::WebAuthenticationDelegate*
|
||||
ChromeContentBrowserClient::GetWebAuthenticationDelegate() {
|
||||
if (!web_authentication_delegate_) {
|
||||
|
@ -6730,7 +6740,8 @@ bool ChromeContentBrowserClient::OpenExternally(
|
|||
!url.SchemeIs(extensions::kExtensionScheme);
|
||||
if (should_open_in_lacros) {
|
||||
ash::NewWindowDelegate::GetPrimary()->OpenUrl(
|
||||
url, ash::NewWindowDelegate::OpenUrlFrom::kUserInteraction);
|
||||
url, ash::NewWindowDelegate::OpenUrlFrom::kUserInteraction,
|
||||
ash::NewWindowDelegate::Disposition::kNewForegroundTab);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue