Index: chrome/browser/chrome_content_browser_client.cc |
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc |
index 47900fbf0c658a69cabc9dbe0f8470028df1be78..ce9507def3a49c33c13c5bdf4f876c55c6833eea 100644 |
--- a/chrome/browser/chrome_content_browser_client.cc |
+++ b/chrome/browser/chrome_content_browser_client.cc |
@@ -175,6 +175,7 @@ |
#include "device/bluetooth/public/interfaces/adapter.mojom.h" |
#include "device/usb/public/interfaces/chooser_service.mojom.h" |
#include "device/usb/public/interfaces/device_manager.mojom.h" |
+#include "extensions/features/features.h" |
#include "gin/v8_initializer.h" |
#include "net/base/mime_util.h" |
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
@@ -289,7 +290,7 @@ |
#include "components/nacl/common/nacl_switches.h" |
#endif |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
#include "chrome/browser/accessibility/animation_policy_prefs.h" |
#include "chrome/browser/extensions/chrome_content_browser_client_extensions_part.h" |
#include "chrome/browser/media/cast_transport_host_filter.h" |
@@ -371,7 +372,7 @@ using security_interstitials::SSLErrorUI; |
using content::FileDescriptorInfo; |
#endif |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
using extensions::APIPermission; |
using extensions::ChromeContentBrowserClientExtensionsPart; |
using extensions::Extension; |
@@ -708,7 +709,7 @@ float GetDeviceScaleAdjustment() { |
} |
#endif // defined(OS_ANDROID) |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
// By default, JavaScript, images and autoplay are enabled in guest content. |
void GetGuestViewDefaultContentSettingRules( |
bool incognito, |
@@ -733,7 +734,7 @@ void GetGuestViewDefaultContentSettingRules( |
std::string(), |
incognito)); |
} |
-#endif // defined(ENABLE_EXTENSIONS) |
+#endif // BUILDFLAG(ENABLE_EXTENSIONS) |
void CreateUsbDeviceManager( |
RenderFrameHost* render_frame_host, |
@@ -829,7 +830,7 @@ ChromeContentBrowserClient::ChromeContentBrowserClient() |
TtsController::GetInstance()->SetTtsEngineDelegate(tts_extension_engine); |
#endif |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
extra_parts_.push_back(new ChromeContentBrowserClientExtensionsPart); |
#endif |
} |
@@ -939,7 +940,7 @@ std::string ChromeContentBrowserClient::GetStoragePartitionIdForSite( |
// SiteInstance URL - "chrome-guest://app_id/persist?partition". |
if (site.SchemeIs(content::kGuestScheme)) |
partition_id = site.spec(); |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
// The partition ID for extensions with isolated storage is treated similarly |
// to the above. |
else if (site.SchemeIs(extensions::kExtensionScheme) && |
@@ -974,7 +975,7 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite( |
partition_name->clear(); |
*in_memory = false; |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
bool success = extensions::WebViewGuest::GetGuestPartitionConfigForSite( |
site, partition_domain, partition_name, in_memory); |
@@ -1026,7 +1027,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch( |
host->AddFilter(new ChromeRenderMessageFilter( |
id, profile, host->GetStoragePartition()->GetServiceWorkerContext())); |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
host->AddFilter(new cast::CastTransportHostFilter); |
#endif |
#if BUILDFLAG(ENABLE_PRINTING) |
@@ -1076,7 +1077,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch( |
RendererContentSettingRules rules; |
if (host->IsForGuestsOnly()) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
GetGuestViewDefaultContentSettingRules(profile->IsOffTheRecord(), &rules); |
#else |
NOTREACHED(); |
@@ -1099,7 +1100,7 @@ GURL ChromeContentBrowserClient::GetEffectiveURL( |
if (search::ShouldAssignURLToInstantRenderer(url, profile)) |
return search::GetEffectiveURLForInstant(url, profile); |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientExtensionsPart::GetEffectiveURL( |
profile, url); |
#else |
@@ -1121,7 +1122,7 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
if (search::ShouldUseProcessPerSiteForInstantURL(effective_url, profile)) |
return true; |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientExtensionsPart::ShouldUseProcessPerSite( |
profile, effective_url); |
#else |
@@ -1132,7 +1133,7 @@ bool ChromeContentBrowserClient::ShouldUseProcessPerSite( |
bool ChromeContentBrowserClient::DoesSiteRequireDedicatedProcess( |
content::BrowserContext* browser_context, |
const GURL& effective_site_url) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
if (ChromeContentBrowserClientExtensionsPart::DoesSiteRequireDedicatedProcess( |
browser_context, effective_site_url)) { |
return true; |
@@ -1154,7 +1155,7 @@ bool ChromeContentBrowserClient::ShouldLockToOrigin( |
if (effective_site_url.SchemeIs(chrome::kChromeSearchScheme)) |
return false; |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
// Disable origin lock if this is an extension/app that applies effective URL |
// mappings. |
if (!ChromeContentBrowserClientExtensionsPart::ShouldLockToOrigin( |
@@ -1184,7 +1185,7 @@ bool ChromeContentBrowserClient::IsHandledURL(const GURL& url) { |
bool ChromeContentBrowserClient::CanCommitURL( |
content::RenderProcessHost* process_host, |
const GURL& url) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientExtensionsPart::CanCommitURL( |
process_host, url); |
#else |
@@ -1194,7 +1195,7 @@ bool ChromeContentBrowserClient::CanCommitURL( |
bool ChromeContentBrowserClient::ShouldAllowOpenURL( |
content::SiteInstance* site_instance, const GURL& url) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
bool result; |
if (ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL( |
site_instance, url, &result)) |
@@ -1239,7 +1240,7 @@ void ChromeContentBrowserClient::OverrideNavigationParams( |
*referrer = content::Referrer(); |
} |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
ChromeContentBrowserClientExtensionsPart::OverrideNavigationParams( |
site_instance, transition, is_renderer_initiated, referrer); |
#endif |
@@ -1268,7 +1269,7 @@ bool ChromeContentBrowserClient::IsSuitableHost( |
return is_instant_process && should_be_in_instant_process; |
} |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientExtensionsPart::IsSuitableHost( |
profile, process_host, site_url); |
#else |
@@ -1298,7 +1299,7 @@ bool ChromeContentBrowserClient::ShouldTryToUseExistingProcessHost( |
if (!url.is_valid()) |
return false; |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
Profile* profile = Profile::FromBrowserContext(browser_context); |
return ChromeContentBrowserClientExtensionsPart:: |
ShouldTryToUseExistingProcessHost( |
@@ -1344,7 +1345,7 @@ bool ChromeContentBrowserClient::ShouldSwapBrowsingInstancesForNavigation( |
SiteInstance* site_instance, |
const GURL& current_url, |
const GURL& new_url) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientExtensionsPart:: |
ShouldSwapBrowsingInstancesForNavigation( |
site_instance, current_url, new_url); |
@@ -1357,7 +1358,7 @@ bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( |
content::BrowserContext* browser_context, |
const GURL& current_url, |
const GURL& new_url) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientExtensionsPart:: |
ShouldSwapProcessesForRedirect(browser_context, current_url, new_url); |
#else |
@@ -1681,7 +1682,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
autofill::switches::kEnableSuggestionsWithSubstringMatch, |
autofill::switches::kIgnoreAutocompleteOffForAutofill, |
autofill::switches::kLocalHeuristicsOnlyForPasswordGeneration, |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
extensions::switches::kAllowHTTPBackgroundPage, |
extensions::switches::kAllowLegacyExtensionManifests, |
extensions::switches::kEnableAppWindowControls, |
@@ -1728,7 +1729,7 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches( |
command_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
arraysize(kSwitchNames)); |
} else if (process_type == switches::kUtilityProcess) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
static const char* const kSwitchNames[] = { |
extensions::switches::kAllowHTTPBackgroundPage, |
extensions::switches::kEnableExperimentalExtensionApis, |
@@ -1818,7 +1819,7 @@ bool ChromeContentBrowserClient::AllowServiceWorker( |
int render_frame_id) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
// Check if this is an extension-related service worker, and, if so, if it's |
// allowed (this can return false if, e.g., the extension is disabled). |
// If it's not allowed, return immediately. We deliberately do *not* report |
@@ -1927,14 +1928,14 @@ void ChromeContentBrowserClient::AllowWorkerFileSystem( |
io_data->GetCookieSettings(); |
bool allow = cookie_settings->IsSettingCookieAllowed(url, url); |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
GuestPermissionRequestHelper(url, render_frames, callback, allow); |
#else |
FileSystemAccessed(url, render_frames, callback, allow); |
#endif |
} |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
void ChromeContentBrowserClient::GuestPermissionRequestHelper( |
const GURL& url, |
const std::vector<std::pair<int, int> >& render_frames, |
@@ -2096,7 +2097,7 @@ net::URLRequestContext* |
ChromeContentBrowserClient::OverrideRequestContextForURL( |
const GURL& url, content::ResourceContext* context) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
if (url.SchemeIs(extensions::kExtensionScheme)) { |
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
return io_data->extensions_request_context(); |
@@ -2259,7 +2260,7 @@ bool ChromeContentBrowserClient::CanCreateWindow( |
// If the opener is trying to create a background window but doesn't have |
// the appropriate permission, fail the attempt. |
if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
InfoMap* map = io_data->GetExtensionInfoMap(); |
if (!map->SecurityOriginHasAPIPermission( |
@@ -2284,7 +2285,7 @@ bool ChromeContentBrowserClient::CanCreateWindow( |
return true; |
} |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
if (extensions::WebViewRendererState::GetInstance()->IsGuest( |
render_process_id)) { |
return true; |
@@ -2484,7 +2485,7 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs( |
web_prefs->hyperlink_auditing_enabled = |
prefs->GetBoolean(prefs::kEnableHyperlinkAuditing); |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
std::string image_animation_policy = |
prefs->GetString(prefs::kAnimationPolicy); |
if (image_animation_policy == kAnimationPolicyOnce) |
@@ -2689,7 +2690,7 @@ bool ChromeContentBrowserClient::AllowPepperSocketAPI( |
const GURL& url, |
bool private_api, |
const content::SocketPermissionRequest* params) { |
-#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
+#if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientPluginsPart::AllowPepperSocketAPI( |
browser_context, url, private_api, params, allowed_socket_origins_); |
#else |
@@ -2700,7 +2701,7 @@ bool ChromeContentBrowserClient::AllowPepperSocketAPI( |
bool ChromeContentBrowserClient::IsPepperVpnProviderAPIAllowed( |
content::BrowserContext* browser_context, |
const GURL& url) { |
-#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
+#if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientPluginsPart::IsPepperVpnProviderAPIAllowed( |
browser_context, url); |
#else |
@@ -2711,7 +2712,7 @@ bool ChromeContentBrowserClient::IsPepperVpnProviderAPIAllowed( |
std::unique_ptr<content::VpnServiceProxy> |
ChromeContentBrowserClient::GetVpnServiceProxy( |
content::BrowserContext* browser_context) { |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientExtensionsPart::GetVpnServiceProxy( |
browser_context); |
#else |
@@ -2927,7 +2928,7 @@ void ChromeContentBrowserClient::RegisterRenderFrameMojoInterfaces( |
service_manager::InterfaceRegistry* registry, |
content::RenderFrameHost* render_frame_host) { |
if (base::FeatureList::IsEnabled(features::kWebUsb) |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
&& |
!render_frame_host->GetSiteInstance()->GetSiteURL().SchemeIs( |
extensions::kExtensionScheme) |
@@ -3149,7 +3150,7 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( |
} |
#endif |
-#if defined(ENABLE_EXTENSIONS) |
+#if BUILDFLAG(ENABLE_EXTENSIONS) |
throttles.push_back(new extensions::ExtensionNavigationThrottle(handle)); |
#endif |
@@ -3178,7 +3179,7 @@ content::TracingDelegate* ChromeContentBrowserClient::GetTracingDelegate() { |
bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
content::BrowserContext* browser_context, |
const GURL& url) { |
-#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
+#if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientPluginsPart:: |
IsPluginAllowedToCallRequestOSFileHandle(browser_context, url, |
allowed_file_handle_origins_); |
@@ -3190,7 +3191,7 @@ bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
bool ChromeContentBrowserClient::IsPluginAllowedToUseDevChannelAPIs( |
content::BrowserContext* browser_context, |
const GURL& url) { |
-#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) |
+#if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS) |
return ChromeContentBrowserClientPluginsPart:: |
IsPluginAllowedToUseDevChannelAPIs(browser_context, url, |
allowed_dev_channel_origins_); |