Only build various flash/pnacl/ppapi code when they are enabled. (try 2)

Review URL: https://codereview.chromium.org/494993005

Cr-Commit-Position: refs/heads/master@{#291810}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index d021820..f170292 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -168,7 +168,6 @@
       "//mojo/system",
       "//net:net_with_v8",
       "//third_party/WebKit/public:resources",
-      "//third_party/adobe/flash:flapper_version_h",
       "//third_party/expat",
       "//third_party/leveldatabase",
       "//third_party/libaddressinput",
@@ -306,6 +305,7 @@
                            ".", "//chrome")
     deps += [
       "//ppapi:ppapi_ipc",
+      "//third_party/adobe/flash:flapper_version_h",
     ]
   }
   if (safe_browsing_mode != 0) {
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index c379704..b178721 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -29,7 +29,6 @@
 #include "chrome/browser/chrome_content_browser_client.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
-#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
 #include "chrome/browser/defaults.h"
 #include "chrome/browser/devtools/remote_debugging_server.h"
 #include "chrome/browser/download/download_request_limiter.h"
@@ -129,6 +128,10 @@
 #include "components/storage_monitor/storage_monitor.h"
 #endif
 
+#if !defined(DISABLE_NACL)
+#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
+#endif
+
 #if defined(ENABLE_PLUGIN_INSTALLATION)
 #include "chrome/browser/plugins/plugins_resource_service.h"
 #endif
@@ -901,11 +904,15 @@
 
 component_updater::PnaclComponentInstaller*
 BrowserProcessImpl::pnacl_component_installer() {
+#if !defined(DISABLE_NACL)
   if (!pnacl_component_installer_.get()) {
     pnacl_component_installer_.reset(
         new component_updater::PnaclComponentInstaller());
   }
   return pnacl_component_installer_.get();
+#else
+  return NULL;
+#endif
 }
 
 void BrowserProcessImpl::ResourceDispatcherHostCreated() {
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 4899cc3e..6234faf 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -276,8 +276,11 @@
   // but some users of component updater only install per-user.
   scoped_ptr<component_updater::ComponentUpdateService> component_updater_;
   scoped_refptr<CRLSetFetcher> crl_set_fetcher_;
+
+#if !defined(DISABLE_NACL)
   scoped_ptr<component_updater::PnaclComponentInstaller>
       pnacl_component_installer_;
+#endif
 
 #if defined(ENABLE_PLUGIN_INSTALLATION)
   scoped_refptr<PluginsResourceService> plugins_resource_service_;
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index e869248..561677f 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -45,7 +45,6 @@
 #include "chrome/browser/component_updater/cld_component_installer.h"
 #include "chrome/browser/component_updater/ev_whitelist_component_installer.h"
 #include "chrome/browser/component_updater/flash_component_installer.h"
-#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
 #include "chrome/browser/component_updater/recovery_component_installer.h"
 #include "chrome/browser/component_updater/swiftshader_component_installer.h"
 #include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
@@ -186,6 +185,7 @@
 #endif
 
 #if !defined(DISABLE_NACL)
+#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
 #include "components/nacl/browser/nacl_process_host.h"
 #endif
 
@@ -394,8 +394,10 @@
   RegisterPepperFlashComponent(cus);
   RegisterSwiftShaderComponent(cus);
   RegisterWidevineCdmComponent(cus);
+#if !defined(DISABLE_NACL)
   g_browser_process->pnacl_component_installer()->RegisterPnaclComponent(cus);
 #endif
+#endif
 
   if (translate::CldDataSource::ShouldRegisterForComponentUpdates()) {
     RegisterCldComponent(cus);
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
index 3514461..09dd83d 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
@@ -13,7 +13,6 @@
 #include "chrome/browser/browser_process.h"
 #include "chrome/browser/chrome_notification_types.h"
 #include "chrome/browser/component_updater/component_updater_resource_throttle.h"
-#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
 #include "chrome/browser/content_settings/host_content_settings_map.h"
 #include "chrome/browser/download/download_request_limiter.h"
 #include "chrome/browser/download/download_resource_throttle.h"
@@ -53,6 +52,10 @@
 #include "net/http/http_response_headers.h"
 #include "net/url_request/url_request.h"
 
+#if !defined(DISABLE_NACL)
+#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
+#endif
+
 #if defined(ENABLE_CONFIGURATION_POLICY)
 #include "components/policy/core/common/cloud/policy_header_io_helper.h"
 #endif
@@ -223,6 +226,7 @@
 }
 #endif  // !defined(OS_ANDROID)
 
+#if !defined(DISABLE_NACL)
 void AppendComponentUpdaterThrottles(
     net::URLRequest* request,
     content::ResourceContext* resource_context,
@@ -251,8 +255,9 @@
         component_updater::GetOnDemandResourceThrottle(cus, crx_id));
   }
 }
+#endif  // !defined(DISABLE_NACL)
 
-}  // end namespace
+}  // namespace
 
 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate(
     prerender::PrerenderTracker* prerender_tracker)
@@ -397,12 +402,14 @@
                                   resource_context,
                                   resource_type,
                                   throttles);
+#if !defined(DISABLE_NACL)
   if (!is_prerendering) {
     AppendComponentUpdaterThrottles(request,
                                     resource_context,
                                     resource_type,
                                     throttles);
   }
+#endif
 }
 
 void ChromeResourceDispatcherHostDelegate::DownloadStarting(
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 62a37c3..88483be 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -209,8 +209,6 @@
       'browser/browsing_data/browsing_data_database_helper.h',
       'browser/browsing_data/browsing_data_file_system_helper.cc',
       'browser/browsing_data/browsing_data_file_system_helper.h',
-      'browser/browsing_data/browsing_data_flash_lso_helper.cc',
-      'browser/browsing_data/browsing_data_flash_lso_helper.h',
       'browser/browsing_data/browsing_data_helper.cc',
       'browser/browsing_data/browsing_data_helper.h',
       'browser/browsing_data/browsing_data_indexed_db_helper.cc',
@@ -280,12 +278,6 @@
       'browser/component_updater/component_updater_resource_throttle.h',
       'browser/component_updater/ev_whitelist_component_installer.cc',
       'browser/component_updater/ev_whitelist_component_installer.h',
-      'browser/component_updater/flash_component_installer.h',
-      'browser/component_updater/pepper_flash_component_installer.cc',
-      'browser/component_updater/pnacl/pnacl_component_installer.cc',
-      'browser/component_updater/pnacl/pnacl_component_installer.h',
-      'browser/component_updater/ppapi_utils.cc',
-      'browser/component_updater/ppapi_utils.h',
       'browser/component_updater/recovery_component_installer.cc',
       'browser/component_updater/recovery_component_installer.h',
       'browser/component_updater/sw_reporter_installer_win.cc',
@@ -1723,6 +1715,8 @@
       'browser/spellchecker/word_trimmer.h',
     ],
     'chrome_browser_nacl_sources': [
+      'browser/component_updater/pnacl/pnacl_component_installer.cc',
+      'browser/component_updater/pnacl/pnacl_component_installer.h',
       'browser/nacl_host/nacl_browser_delegate_impl.cc',
       'browser/nacl_host/nacl_browser_delegate_impl.h',
       'browser/nacl_host/nacl_infobar_delegate.cc',
@@ -1730,6 +1724,12 @@
     ],
     # See also the plugin_installation_sources list below.
     'chrome_browser_plugins_sources': [
+      'browser/browsing_data/browsing_data_flash_lso_helper.cc',
+      'browser/browsing_data/browsing_data_flash_lso_helper.h',
+      'browser/component_updater/flash_component_installer.h',
+      'browser/component_updater/pepper_flash_component_installer.cc',
+      'browser/component_updater/ppapi_utils.cc',
+      'browser/component_updater/ppapi_utils.h',
       'browser/metrics/plugin_metrics_provider.cc',
       'browser/metrics/plugin_metrics_provider.h',
       'browser/pepper_broker_infobar_delegate.cc',
@@ -2948,7 +2948,6 @@
             '../net/net.gyp:net_with_v8',
             # TODO(tonyg): Remove this dependency (crbug.com/280157).
             '../testing/perf/perf_test.gyp:*',
-            '../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
             '../third_party/expat/expat.gyp:expat',
             '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
             '../third_party/libaddressinput/libaddressinput.gyp:libaddressinput',
@@ -3099,6 +3098,7 @@
         ['enable_plugins==1', {
           'dependencies': [
             '../ppapi/ppapi_internal.gyp:ppapi_ipc',
+            '../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
           ],
           'sources': [ '<@(chrome_browser_plugins_sources)' ],
         }],
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 4c6f734c..f53b548 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1059,8 +1059,6 @@
       'browser/ui/webui/fileicon_source.h',
       'browser/ui/webui/flags_ui.cc',
       'browser/ui/webui/flags_ui.h',
-      'browser/ui/webui/flash_ui.cc',
-      'browser/ui/webui/flash_ui.h',
       'browser/ui/webui/gcm_internals_ui.cc',
       'browser/ui/webui/gcm_internals_ui.h',
       'browser/ui/webui/history_ui.cc',
@@ -1854,6 +1852,8 @@
     'chrome_browser_ui_plugin_sources': [
       'browser/ui/hung_plugin_tab_helper.cc',
       'browser/ui/hung_plugin_tab_helper.h',
+      'browser/ui/webui/flash_ui.cc',
+      'browser/ui/webui/flash_ui.h',
     ],
     'chrome_browser_ui_policy_sources': [
       'browser/ui/webui/policy_ui.cc',
@@ -2621,7 +2621,6 @@
             '../media/media.gyp:media',
             '../mojo/mojo_base.gyp:mojo_system_impl',
             '../net/net.gyp:net_with_v8',
-            '../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
             '../third_party/expat/expat.gyp:expat',
             '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase',
             '../third_party/libjingle/libjingle.gyp:libjingle',
@@ -2680,6 +2679,7 @@
           'sources': [ '<@(chrome_browser_ui_plugin_sources)' ],
           'dependencies': [
             '../ppapi/ppapi_internal.gyp:ppapi_ipc',
+            '../third_party/adobe/flash/flash_player.gyp:flapper_version_h',
           ],
         }],
         ['safe_browsing==1', {
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index ddf250a..1be2c43 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -149,10 +149,6 @@
       'common/omnibox_focus_state.h',
       'common/partial_circular_buffer.cc',
       'common/partial_circular_buffer.h',
-      'common/pepper_flash.cc',
-      'common/pepper_flash.h',
-      'common/pepper_permission_util.cc',
-      'common/pepper_permission_util.h',
       'common/pref_names_util.cc',
       'common/pref_names_util.h',
       'common/prerender_types.h',
@@ -376,7 +372,6 @@
             '<(DEPTH)/extensions/common/api/api.gyp:extensions_api',
             '<(DEPTH)/extensions/extensions.gyp:extensions_common',
             '<(DEPTH)/ipc/ipc.gyp:ipc',
-            '<(DEPTH)/third_party/adobe/flash/flash_player.gyp:flapper_version_h',
             '<(DEPTH)/third_party/re2/re2.gyp:re2',
             '<(DEPTH)/third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
           ],
@@ -395,7 +390,6 @@
             ['exclude', '^common/logging_chrome\\.'],
             ['exclude', '^common/media_galleries/'],
             ['exclude', '^common/multi_process_'],
-            ['exclude', '^common/pepper_flash\\.'],
             ['exclude', '^common/profiling\\.'],
             ['exclude', '^common/spellcheck_'],
             ['exclude', '^common/validation_message_'],
@@ -420,6 +414,17 @@
             '<(DEPTH)/ppapi/native_client/src/trusted/plugin/plugin.gyp:nacl_trusted_plugin',
           ],
         }],
+        ['enable_plugins==1', {
+          'dependencies': [
+            '<(DEPTH)/third_party/adobe/flash/flash_player.gyp:flapper_version_h',
+          ],
+          'sources': [
+            'common/pepper_flash.cc',
+            'common/pepper_flash.h',
+            'common/pepper_permission_util.cc',
+            'common/pepper_permission_util.h',
+          ],
+        }],
         ['enable_printing==0', {
           'sources!': [
             'common/print_messages.cc',
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 263b78c..77df767 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -2275,7 +2275,9 @@
             ['exclude', '^browser/plugins/'],
           ],
           'sources!': [
+            'browser/component_updater/test/component_installers_unittest.cc',
             'browser/metrics/plugin_metrics_provider_unittest.cc',
+            'common/pepper_permission_util_unittest.cc',
           ],
         }],
         ['enable_printing!=1', {
diff --git a/chrome/common/BUILD.gn b/chrome/common/BUILD.gn
index d489c05c..b99d3b03 100644
--- a/chrome/common/BUILD.gn
+++ b/chrome/common/BUILD.gn
@@ -94,7 +94,6 @@
       "//extensions/common",
       "//extensions/common/api",
       "//ipc",
-      "//third_party/adobe/flash:flapper_version_h",
       "//third_party/re2",
       "//third_party/widevine/cdm:version_h",
     ]
@@ -211,7 +210,11 @@
   if (enable_remoting) {
     #deps += [ '../remoting/remoting.gyp:remoting_client_plugin' ]  TODO(GYP)
   }
-  if (!enable_plugins) {
+  if (enable_plugins) {
+    deps += [
+      "//third_party/adobe/flash:flapper_version_h",
+    ]
+  } else {
     sources -= [ "pepper_permission_util.cc" ]
   }
   if (!enable_webrtc) {
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index 6bff669..efc4b06 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -21,12 +21,10 @@
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/chrome_version_info.h"
 #include "chrome/common/crash_keys.h"
-#include "chrome/common/pepper_flash.h"
 #include "chrome/common/render_messages.h"
 #include "chrome/common/url_constants.h"
 #include "chrome/grit/common_resources.h"
 #include "components/dom_distiller/core/url_constants.h"
-#include "components/nacl/common/nacl_process_type.h"
 #include "content/public/common/content_constants.h"
 #include "content/public/common/content_switches.h"
 #include "content/public/common/pepper_plugin_info.h"
@@ -35,12 +33,10 @@
 #include "extensions/common/constants.h"
 #include "gpu/config/gpu_info.h"
 #include "net/http/http_util.h"
-#include "ppapi/shared_impl/ppapi_permissions.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/layout.h"
 #include "ui/base/resource/resource_bundle.h"
 
-#include "flapper_version.h"  // In SHARED_INTERMEDIATE_DIR.
 #include "widevine_cdm_version.h"  // In SHARED_INTERMEDIATE_DIR.
 
 #if defined(OS_WIN)
@@ -52,9 +48,16 @@
 
 #if !defined(DISABLE_NACL)
 #include "components/nacl/common/nacl_constants.h"
+#include "components/nacl/common/nacl_process_type.h"
 #include "ppapi/native_client/src/trusted/plugin/ppapi_entrypoints.h"
 #endif
 
+#if defined(ENABLE_PLUGINS)
+#include "chrome/common/pepper_flash.h"
+#include "flapper_version.h"  // In SHARED_INTERMEDIATE_DIR.
+#include "ppapi/shared_impl/ppapi_permissions.h"
+#endif
+
 #if defined(ENABLE_REMOTING)
 #include "remoting/client/plugin/pepper_entrypoints.h"
 #endif
@@ -66,6 +69,7 @@
 
 namespace {
 
+#if defined(ENABLE_PLUGINS)
 const char kPDFPluginMimeType[] = "application/pdf";
 const char kPDFPluginExtension[] = "pdf";
 const char kPDFPluginDescription[] = "Portable Document Format";
@@ -408,6 +412,7 @@
   return false;
 #endif  // FLAPPER_AVAILABLE
 }
+#endif  // defined(ENABLE_PLUGINS)
 
 std::string GetProduct() {
   chrome::VersionInfo version_info;
@@ -462,12 +467,14 @@
 
 void ChromeContentClient::AddPepperPlugins(
     std::vector<content::PepperPluginInfo>* plugins) {
+#if defined(ENABLE_PLUGINS)
   ComputeBuiltInPlugins(plugins);
   AddPepperFlashFromCommandLine(plugins);
 
   content::PepperPluginInfo plugin;
   if (GetBundledPepperFlash(&plugin))
     plugins->push_back(plugin);
+#endif
 }
 
 void ChromeContentClient::AddAdditionalSchemes(
@@ -516,14 +523,16 @@
 }
 
 std::string ChromeContentClient::GetProcessTypeNameInEnglish(int type) {
+#if !defined(DISABLE_NACL)
   switch (type) {
     case PROCESS_TYPE_NACL_LOADER:
       return "Native Client module";
     case PROCESS_TYPE_NACL_BROKER:
       return "Native Client broker";
   }
+#endif
 
-  DCHECK(false) << "Unknown child process type!";
+  NOTREACHED() << "Unknown child process type!";
   return "Unknown";
 }