Always use ENABLE_PLUGINS to indicate plugins support.
We should rely on GYP_DEFINE "enable_plugins" in gyp files and C++ macro
"ENABLE_PLUGINS" in source code to indicate plugins support. This removes
hard-coded assumptions that certain OS does (or does not) support plugins.
Also add GYP_DEFINE "enable_pdf" and macro "ENABLE_PDF" to indicate
built-in PDF viewer plugin support.
BUG=490433
TEST=trybot
[email protected]
Review URL: https://codereview.chromium.org/1318143002
Cr-Commit-Position: refs/heads/master@{#346284}
diff --git a/build/common.gypi b/build/common.gypi
index b58fede7..92852a6ed 100644
--- a/build/common.gypi
+++ b/build/common.gypi
@@ -900,6 +900,13 @@
'chromium_win_pch%': 1
}],
+ # Whether PDF plugin is enabled.
+ ['OS=="android" or OS=="ios" or (embedded==1 and chromecast==0)', {
+ 'enable_pdf%': 0,
+ }, {
+ 'enable_pdf%': 1,
+ }],
+
['chromeos==1 or OS=="android" or OS=="ios" or desktop_linux==1', {
'enable_plugin_installation%': 0,
}, {
@@ -1204,6 +1211,7 @@
'order_profiling%': '<(order_profiling)',
'order_text_section%': '<(order_text_section)',
'enable_extensions%': '<(enable_extensions)',
+ 'enable_pdf%': '<(enable_pdf)',
'enable_plugin_installation%': '<(enable_plugin_installation)',
'enable_plugins%': '<(enable_plugins)',
'enable_session_service%': '<(enable_session_service)',
@@ -2986,6 +2994,9 @@
['enable_dart==1', {
'defines': ['WEBKIT_USING_DART=1'],
}],
+ ['enable_pdf==1', {
+ 'defines': ['ENABLE_PDF=1'],
+ }],
['enable_plugin_installation==1', {
'defines': ['ENABLE_PLUGIN_INSTALLATION=1'],
}],
diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn
index 278baec6..488768d 100644
--- a/build/config/BUILD.gn
+++ b/build/config/BUILD.gn
@@ -68,6 +68,9 @@
if (enable_plugins) {
defines += [ "ENABLE_PLUGINS=1" ]
}
+ if (enable_pdf) {
+ defines += [ "ENABLE_PDF=1" ]
+ }
if (enable_basic_printing || enable_print_preview) {
# Convenience define for ENABLE_BASIC_PRINTING || ENABLE_PRINT_PREVIEW.
defines += [ "ENABLE_PRINTING=1" ]
diff --git a/build/config/features.gni b/build/config/features.gni
index 3bbb0b6..73ba9fc 100644
--- a/build/config/features.gni
+++ b/build/config/features.gni
@@ -24,6 +24,7 @@
enable_mdns = is_win || is_linux
enable_plugins = !is_android && !is_ios
+ enable_pdf = !is_android && !is_ios
# Enables Native Client support.
# TODO(GYP): Get NaCl linking on other platforms.
diff --git a/chrome/app/chrome_main_delegate.cc b/chrome/app/chrome_main_delegate.cc
index 8b6457c..9338b89 100644
--- a/chrome/app/chrome_main_delegate.cc
+++ b/chrome/app/chrome_main_delegate.cc
@@ -810,7 +810,7 @@
nacl_plugin::PPP_InitializeModule,
nacl_plugin::PPP_ShutdownModule);
#endif
-#if defined(ENABLE_PLUGINS)
+#if defined(ENABLE_PLUGINS) && defined(ENABLE_PDF)
ChromeContentClient::SetPDFEntryFunctions(
chrome_pdf::PPP_GetInterface,
chrome_pdf::PPP_InitializeModule,
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 5ee2a20..1340cdbd 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -223,7 +223,7 @@
<include name="IDR_OMNIBOX_CSS" file="resources\omnibox\omnibox.css" type="BINDATA" />
<include name="IDR_OMNIBOX_JS" file="resources\omnibox\omnibox.js" type="BINDATA" />
<include name="IDR_OMNIBOX_MOJO_JS" file="${omnibox_mojom_file}" use_base_dir="false" type="BINDATA"/>
- <if expr="not is_android">
+ <if expr="enable_plugins">
<include name="IDR_PLUGINS_HTML" file="resources\plugins.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_PLUGINS_JS" file="resources\plugins.js" type="BINDATA" />
</if>
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 75e355d3..6379884 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -440,6 +440,10 @@
ExtensionWelcomeNotification::RegisterProfilePrefs(registry);
#endif
+#if defined(ENABLE_PLUGINS)
+ PluginsUI::RegisterProfilePrefs(registry);
+#endif
+
#if defined(ENABLE_PRINT_PREVIEW)
printing::StickySettings::RegisterProfilePrefs(registry);
#endif
@@ -475,7 +479,6 @@
NewTabUI::RegisterProfilePrefs(registry);
PepperFlashSettingsManager::RegisterProfilePrefs(registry);
PinnedTabCodec::RegisterProfilePrefs(registry);
- PluginsUI::RegisterProfilePrefs(registry);
RegisterAutolaunchUserPrefs(registry);
signin::RegisterProfilePrefs(registry);
#endif
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 511a8ab..cb00c1c 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -384,9 +384,6 @@
// Downloads list on Android uses the built-in download manager.
if (url.host() == chrome::kChromeUIDownloadsHost)
return &NewWebUI<DownloadsUI>;
- // Flash is not available on android.
- if (url.host() == chrome::kChromeUIFlashHost)
- return &NewWebUI<FlashUI>;
if (url.host() == chrome::kChromeUIGCMInternalsHost)
return &NewWebUI<GCMInternalsUI>;
// Help is implemented with native UI elements on Android.
@@ -401,9 +398,6 @@
::switches::MdSettingsEnabled()) {
return &NewWebUI<settings::MdSettingsUI>;
}
- // Android does not support plugins for now.
- if (url.host() == chrome::kChromeUIPluginsHost)
- return &NewWebUI<PluginsUI>;
if (url.host() == chrome::kChromeUIQuotaInternalsHost)
return &NewWebUI<QuotaInternalsUI>;
// Settings are implemented with native UI elements on Android.
@@ -549,6 +543,12 @@
if (url.host() == chrome::kChromeUIExtensionsFrameHost)
return &NewWebUI<extensions::ExtensionsUI>;
#endif
+#if defined(ENABLE_PLUGINS)
+ if (url.host() == chrome::kChromeUIFlashHost)
+ return &NewWebUI<FlashUI>;
+ if (url.host() == chrome::kChromeUIPluginsHost)
+ return &NewWebUI<PluginsUI>;
+#endif
#if defined(ENABLE_PRINT_PREVIEW)
if (url.host() == chrome::kChromeUIPrintHost &&
!profile->GetPrefs()->GetBoolean(prefs::kPrintPreviewDisabled)) {
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 6e822456..1cc5163 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1892,8 +1892,6 @@
'browser/ui/webui/options/supervised_user_learn_more_handler.h',
'browser/ui/webui/options/sync_setup_handler.cc',
'browser/ui/webui/options/sync_setup_handler.h',
- 'browser/ui/webui/plugins_ui.cc',
- 'browser/ui/webui/plugins_ui.h',
'browser/ui/webui/profile_info_watcher.cc',
'browser/ui/webui/profile_info_watcher.h',
'browser/ui/webui/quota_internals/quota_internals_handler.cc',
@@ -2657,6 +2655,8 @@
'browser/ui/hung_plugin_tab_helper.h',
'browser/ui/webui/flash_ui.cc',
'browser/ui/webui/flash_ui.h',
+ 'browser/ui/webui/plugins_ui.cc',
+ 'browser/ui/webui/plugins_ui.h',
],
'chrome_browser_ui_policy_sources': [
'browser/ui/webui/policy_ui.cc',
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index c577edf..3b9b5f82 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -74,12 +74,14 @@
namespace {
#if defined(ENABLE_PLUGINS)
+#if defined(ENABLE_PDF)
const char kPDFPluginExtension[] = "pdf";
const char kPDFPluginDescription[] = "Portable Document Format";
const char kPDFPluginOutOfProcessMimeType[] =
"application/x-google-chrome-pdf";
const uint32 kPDFPluginPermissions = ppapi::PERMISSION_PRIVATE |
ppapi::PERMISSION_DEV;
+#endif // defined(ENABLE_PDF)
content::PepperPluginInfo::GetInterfaceFunc g_pdf_get_interface;
content::PepperPluginInfo::PPP_InitializeModuleFunc g_pdf_initialize_module;
@@ -97,6 +99,7 @@
// not marked internal, aside from being automatically registered, they're just
// regular plugins).
void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
+#if defined(ENABLE_PDF)
content::PepperPluginInfo pdf_info;
pdf_info.is_internal = true;
pdf_info.is_out_of_process = true;
@@ -114,6 +117,7 @@
pdf_info.internal_entry_points.shutdown_module = g_pdf_shutdown_module;
pdf_info.permissions = kPDFPluginPermissions;
plugins->push_back(pdf_info);
+#endif // defined(ENABLE_PDF)
base::FilePath path;
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index e23ab4c..1f65fd2 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -911,7 +911,7 @@
const char kNpapiFlashMigratedToPepperFlash[] =
"plugins.npapi_flash_migrated_to_pepper_flash";
-#if !defined(OS_ANDROID)
+#if defined(ENABLE_PLUGINS)
// Whether about:plugins is shown in the details mode or not.
const char kPluginsShowDetails[] = "plugins.show_details";
#endif
@@ -952,7 +952,7 @@
// true, we draw a custom chrome frame (thicker title bar and blue border).
const char kUseCustomChromeFrame[] = "browser.custom_chrome_frame";
-#if !defined(OS_ANDROID)
+#if defined(ENABLE_PLUGINS)
// Which plugins have been whitelisted manually by the user.
const char kContentSettingsPluginWhitelist[] =
"profile.content_settings.plugin_whitelist";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 74306c84..8a86b12 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -312,7 +312,7 @@
extern const char kPluginsDisabledPluginsExceptions[];
extern const char kPluginsEnabledPlugins[];
extern const char kNpapiFlashMigratedToPepperFlash[];
-#if !defined(OS_ANDROID)
+#if defined(ENABLE_PLUGINS)
extern const char kPluginsShowDetails[];
#endif
extern const char kPluginsAllowOutdated[];
@@ -327,7 +327,7 @@
extern const char kShowUpdatePromotionInfoBar[];
#endif
extern const char kUseCustomChromeFrame[];
-#if !defined(OS_ANDROID)
+#if defined(ENABLE_PLUGINS)
extern const char kContentSettingsPluginWhitelist[];
#endif
extern const char kPartitionDefaultZoomLevel[];
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 0abbc60..4804349 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -372,6 +372,9 @@
cmd_line->GetSwitchValueASCII(switches::kProcessType);
CHECK(process_type == switches::kGpuProcess ||
process_type == switches::kRendererProcess ||
+#if defined(ENABLE_PLUGINS)
+ process_type == switches::kPpapiPluginProcess ||
+#endif
process_type == switches::kUtilityProcess)
<< "Unsupported process type: " << process_type;
diff --git a/content/content_browsertests.isolate b/content/content_browsertests.isolate
index ca92600..2ebd3e8 100644
--- a/content/content_browsertests.isolate
+++ b/content/content_browsertests.isolate
@@ -77,12 +77,18 @@
],
},
}],
+ ['enable_plugins==1', {
+ 'variables': {
+ 'files': [
+ '../ppapi/tests/test_case.html',
+ '../ppapi/tests/test_page.css',
+ ],
+ },
+ }],
['OS=="linux" or OS=="mac" or OS=="win"', {
'variables': {
'files': [
'../net/tools/testserver/',
- '../ppapi/tests/test_case.html',
- '../ppapi/tests/test_page.css',
'../testing/test_env.py',
'../third_party/pyftpdlib/',
'../third_party/pywebsocket/',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 4871458..9d9660f 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -1923,6 +1923,11 @@
'<(PRODUCT_DIR)/snapshot_blob.bin',
],
}],
+ ['enable_plugins==1', {
+ 'additional_bundled_libs': [
+ '<(PRODUCT_DIR)/libppapi_tests.so',
+ ],
+ }],
],
},
'includes': [ '../build/apk_browsertest.gypi' ],