| Index: chrome/renderer/chrome_content_renderer_client.cc
|
| diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
|
| index b9c6c05a897751146857111737fcd5362b1a86ac..3e4e68b9af7dc9cd5b2985271c64291b207abafc 100644
|
| --- a/chrome/renderer/chrome_content_renderer_client.cc
|
| +++ b/chrome/renderer/chrome_content_renderer_client.cc
|
| @@ -92,6 +92,7 @@
|
| #include "content/public/renderer/render_view.h"
|
| #include "content/public/renderer/render_view_visitor.h"
|
| #include "extensions/common/constants.h"
|
| +#include "extensions/features/features.h"
|
| #include "ipc/ipc_sync_channel.h"
|
| #include "net/base/net_errors.h"
|
| #include "ppapi/c/private/ppb_pdf.h"
|
| @@ -124,7 +125,7 @@
|
| #include "components/nacl/renderer/nacl_helper.h"
|
| #endif
|
|
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| #include "chrome/common/extensions/chrome_extensions_client.h"
|
| #include "chrome/renderer/extensions/chrome_extensions_renderer_client.h"
|
| #include "extensions/common/extension_urls.h"
|
| @@ -260,7 +261,7 @@ bool SpellCheckReplacer::Visit(content::RenderView* render_view) {
|
| }
|
| #endif
|
|
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| bool IsStandaloneExtensionProcess() {
|
| return base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| extensions::switches::kExtensionProcess);
|
| @@ -294,7 +295,7 @@ class MediaLoadDeferrer : public content::RenderFrameObserver {
|
|
|
| ChromeContentRendererClient::ChromeContentRendererClient()
|
| : main_entry_time_(base::TimeTicks::Now()) {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| extensions::ExtensionsClient::Set(
|
| extensions::ChromeExtensionsClient::GetInstance());
|
| extensions::ExtensionsRendererClient::Set(
|
| @@ -327,7 +328,7 @@ void ChromeContentRendererClient::RenderThreadStarted() {
|
| chrome_observer_.reset(new ChromeRenderThreadObserver());
|
| web_cache_impl_.reset(new web_cache::WebCacheImpl());
|
|
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| ChromeExtensionsRendererClient::GetInstance()->RenderThreadStarted();
|
| #endif
|
|
|
| @@ -444,7 +445,7 @@ void ChromeContentRendererClient::RenderFrameCreated(
|
| base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kInstantProcess);
|
| extensions::Dispatcher* ext_dispatcher = NULL;
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| ext_dispatcher =
|
| ChromeExtensionsRendererClient::GetInstance()->extension_dispatcher();
|
| #endif
|
| @@ -455,7 +456,7 @@ void ChromeContentRendererClient::RenderFrameCreated(
|
| chrome_observer_->content_setting_rules());
|
| }
|
|
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| ChromeExtensionsRendererClient::GetInstance()->RenderFrameCreated(
|
| render_frame);
|
| #endif
|
| @@ -517,7 +518,7 @@ void ChromeContentRendererClient::RenderFrameCreated(
|
|
|
| void ChromeContentRendererClient::RenderViewCreated(
|
| content::RenderView* render_view) {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| ChromeExtensionsRendererClient::GetInstance()->RenderViewCreated(render_view);
|
| #endif
|
| #if BUILDFLAG(ENABLE_PRINTING)
|
| @@ -556,7 +557,7 @@ bool ChromeContentRendererClient::OverrideCreatePlugin(
|
| const WebPluginParams& params,
|
| WebPlugin** plugin) {
|
| std::string orig_mime_type = params.mimeType.utf8();
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| if (!ChromeExtensionsRendererClient::GetInstance()->OverrideCreatePlugin(
|
| render_frame, params)) {
|
| return false;
|
| @@ -691,7 +692,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
| }
|
| case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed:
|
| case ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent: {
|
| -#if !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
|
| +#if !defined(DISABLE_NACL) && BUILDFLAG(ENABLE_EXTENSIONS)
|
| const bool is_nacl_plugin =
|
| info.name == ASCIIToUTF16(nacl::kNaClPluginName);
|
| const bool is_nacl_mime_type =
|
| @@ -750,7 +751,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
| break;
|
| }
|
| }
|
| -#endif // !defined(DISABLE_NACL) && defined(ENABLE_EXTENSIONS)
|
| +#endif // !defined(DISABLE_NACL) && BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
| // Delay loading plugins if prerendering.
|
| // TODO(mmenke): In the case of prerendering, feed into
|
| @@ -926,7 +927,7 @@ bool ChromeContentRendererClient::IsNaClAllowed(
|
| bool is_invoked_by_webstore_installed_extension = false;
|
| bool is_extension_unrestricted = false;
|
| bool is_extension_force_installed = false;
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| bool is_extension_from_webstore = extension && extension->from_webstore();
|
|
|
| bool is_invoked_by_extension = app_url.SchemeIs("chrome-extension");
|
| @@ -944,7 +945,7 @@ bool ChromeContentRendererClient::IsNaClAllowed(
|
| // Allow extensions force installed by admin policy.
|
| is_extension_force_installed = extension &&
|
| extensions::Manifest::IsPolicyLocation(extension->location());
|
| -#endif // defined(ENABLE_EXTENSIONS)
|
| +#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
| // Allow NaCl under any of the following circumstances:
|
| // 1) An app or URL is explictly whitelisted above.
|
| @@ -1041,7 +1042,7 @@ void ChromeContentRendererClient::GetNavigationErrorStrings(
|
| }
|
|
|
| bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| return !IsStandaloneExtensionProcess();
|
| #else
|
| return true;
|
| @@ -1058,7 +1059,7 @@ bool ChromeContentRendererClient::
|
| }
|
|
|
| bool ChromeContentRendererClient::AllowPopup() {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| return ChromeExtensionsRendererClient::GetInstance()->AllowPopup();
|
| #else
|
| return false;
|
| @@ -1105,12 +1106,12 @@ bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
|
| return true;
|
| }
|
|
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| bool should_fork = ChromeExtensionsRendererClient::ShouldFork(
|
| frame, url, is_initial_navigation, is_server_redirect, send_referrer);
|
| if (should_fork)
|
| return true;
|
| -#endif // defined(ENABLE_EXTENSIONS)
|
| +#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
| return false;
|
| }
|
| @@ -1122,7 +1123,7 @@ bool ChromeContentRendererClient::WillSendRequest(
|
| GURL* new_url) {
|
| // Check whether the request should be allowed. If not allowed, we reset the
|
| // URL to something invalid to prevent the request and cause an error.
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest(
|
| frame, transition_type, url, new_url)) {
|
| return true;
|
| @@ -1208,7 +1209,7 @@ bool ChromeContentRendererClient::IsExternalPepperPlugin(
|
| return module_name == "Native Client";
|
| }
|
|
|
| -#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
|
| +#if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
|
| bool ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted(
|
| const GURL& url, const std::set<std::string>& whitelist) {
|
| const extensions::ExtensionSet* extension_set =
|
| @@ -1249,7 +1250,7 @@ void ChromeContentRendererClient::AddSupportedKeySystems(
|
|
|
| bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource(
|
| const base::string16& source) const {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| return extensions::IsSourceFromAnExtension(source);
|
| #else
|
| return false;
|
| @@ -1262,7 +1263,7 @@ bool ChromeContentRendererClient::ShouldGatherSiteIsolationStats() const {
|
| // TODO(nick): https://crbug.com/268640 Gather stats for extension processes
|
| // too; we would need to check the extension's manifest to know which sites
|
| // it's allowed to access.
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
| return !command_line->HasSwitch(extensions::switches::kExtensionProcess);
|
| #else
|
| @@ -1297,7 +1298,7 @@ bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() {
|
|
|
| bool ChromeContentRendererClient::IsPluginAllowedToUseCameraDeviceAPI(
|
| const GURL& url) {
|
| -#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
|
| +#if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
|
| if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kEnablePepperTesting))
|
| return true;
|
| @@ -1311,7 +1312,7 @@ bool ChromeContentRendererClient::IsPluginAllowedToUseCameraDeviceAPI(
|
|
|
| bool ChromeContentRendererClient::IsPluginAllowedToUseCompositorAPI(
|
| const GURL& url) {
|
| -#if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
|
| +#if defined(ENABLE_PLUGINS) && BUILDFLAG(ENABLE_EXTENSIONS)
|
| if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kEnablePepperTesting))
|
| return true;
|
| @@ -1330,7 +1331,7 @@ ChromeContentRendererClient::CreateBrowserPluginDelegate(
|
| content::RenderFrame* render_frame,
|
| const std::string& mime_type,
|
| const GURL& original_url) {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| return ChromeExtensionsRendererClient::CreateBrowserPluginDelegate(
|
| render_frame, mime_type, original_url);
|
| #else
|
| @@ -1369,7 +1370,7 @@ void ChromeContentRendererClient::AddImageContextMenuProperties(
|
|
|
| void ChromeContentRendererClient::RunScriptsAtDocumentStart(
|
| content::RenderFrame* render_frame) {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| ChromeExtensionsRendererClient::GetInstance()->RunScriptsAtDocumentStart(
|
| render_frame);
|
| // |render_frame| might be dead by now.
|
| @@ -1378,7 +1379,7 @@ void ChromeContentRendererClient::RunScriptsAtDocumentStart(
|
|
|
| void ChromeContentRendererClient::RunScriptsAtDocumentEnd(
|
| content::RenderFrame* render_frame) {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| ChromeExtensionsRendererClient::GetInstance()->RunScriptsAtDocumentEnd(
|
| render_frame);
|
| // |render_frame| might be dead by now.
|
| @@ -1390,7 +1391,7 @@ void ChromeContentRendererClient::
|
| v8::Local<v8::Context> context,
|
| int64_t service_worker_version_id,
|
| const GURL& url) {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| ChromeExtensionsRendererClient::GetInstance()
|
| ->extension_dispatcher()
|
| ->DidInitializeServiceWorkerContextOnWorkerThread(
|
| @@ -1402,7 +1403,7 @@ void ChromeContentRendererClient::WillDestroyServiceWorkerContextOnWorkerThread(
|
| v8::Local<v8::Context> context,
|
| int64_t service_worker_version_id,
|
| const GURL& url) {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| extensions::Dispatcher::WillDestroyServiceWorkerContextOnWorkerThread(
|
| context, service_worker_version_id, url);
|
| #endif
|
| @@ -1413,7 +1414,7 @@ void ChromeContentRendererClient::WillDestroyServiceWorkerContextOnWorkerThread(
|
| // information. Also, the enforcement of sending and binding UDP is already done
|
| // by chrome extension permission model.
|
| bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() {
|
| -#if defined(ENABLE_EXTENSIONS)
|
| +#if BUILDFLAG(ENABLE_EXTENSIONS)
|
| return !IsStandaloneExtensionProcess();
|
| #else
|
| return true;
|
|
|