Disable NPAPI support by removing the --enable-npapi switch, chrome://flags and enterprise policy override.

--enable-npapi-for-testing will remain temporarily until the rest of the NPAPI code and tests are removed.

This is a selective revert of 0539f2f5214fc17fdd5d1964be0ceedf98fdb9ce and 26d09db19381c2236a2890c045761465c78bc958.

BUG=493212,489066

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

Cr-Commit-Position: refs/heads/master@{#332006}
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 26e2806..f3672bc 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5736,14 +5736,6 @@
           Disables the use of experimental DirectWrite font rendering system.
         </message>
       </if>
-      <if expr="is_win or is_macosx">
-        <message name="IDS_FLAGS_ENABLE_NPAPI_NAME" desc="Name of the 'Enable NPAPI' lab.">
-          Enable NPAPI
-        </message>
-        <message name="IDS_FLAGS_ENABLE_NPAPI_DESCRIPTION" desc="Description of the 'Enable NPAPI' lab.">
-          Enables the use of NPAPI plugins. This flag will be removed in Chrome 45, along with NPAPI support. See g.co/npapi
-        </message>
-      </if>
       <message name="IDS_FLAGS_ENABLE_EXPERIMENTAL_CANVAS_FEATURES_NAME" desc="Name of the 'Enable experimental canvas features' lab.">
         Enable experimental canvas features
       </message>
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index b82ef98..23bbce2 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -401,11 +401,6 @@
                              ".",
                              "//chrome")
     }
-    if (enable_plugins) {
-      sources += rebase_path(gypi_values.chrome_browser_policy_plugin_sources,
-                             ".",
-                             "//chrome")
-    }
     if (is_android || is_ios) {
       sources += rebase_path(gypi_values.chrome_browser_policy_mobile_sources,
                              ".",
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index d6a78e7..26678f0 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -600,15 +600,6 @@
     kOsAll,
     SINGLE_VALUE_TYPE(switches::kDisableExperimentalWebGL)
   },
-#if defined(OS_WIN) || defined(OS_MACOSX)
-  {
-    "enable-npapi",
-    IDS_FLAGS_ENABLE_NPAPI_NAME,
-    IDS_FLAGS_ENABLE_NPAPI_DESCRIPTION,
-    kOsWin | kOsMac,
-    SINGLE_VALUE_TYPE(switches::kEnableNpapi)
-  },
-#endif
   {
     "disable-webrtc",
     IDS_FLAGS_DISABLE_WEBRTC_NAME,
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc
index 1fb1785..8115527 100644
--- a/chrome/browser/content_settings/content_settings_browsertest.cc
+++ b/chrome/browser/content_settings/content_settings_browsertest.cc
@@ -327,7 +327,7 @@
 #endif
     command_line->AppendSwitch(switches::kAlwaysAuthorizePlugins);
     if (expect_loaded)
-      command_line->AppendSwitch(switches::kEnableNpapi);
+      command_line->AppendSwitch(switches::kEnableNpapiForTesting);
   }
 };
 
@@ -370,7 +370,7 @@
     // explicitly registered.
     command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir);
 #endif
-    command_line->AppendSwitch(switches::kEnableNpapi);
+    command_line->AppendSwitch(switches::kEnableNpapiForTesting);
   }
 };
 
diff --git a/chrome/browser/plugins/enable_npapi_plugins_policy_handler.cc b/chrome/browser/plugins/enable_npapi_plugins_policy_handler.cc
deleted file mode 100644
index c3419c9..0000000
--- a/chrome/browser/plugins/enable_npapi_plugins_policy_handler.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/plugins/enable_npapi_plugins_policy_handler.h"
-
-#include "base/logging.h"
-#include "base/prefs/pref_value_map.h"
-#include "base/values.h"
-#include "chrome/common/pref_names.h"
-#include "components/policy/core/browser/policy_error_map.h"
-#include "components/policy/core/common/policy_map.h"
-#include "policy/policy_constants.h"
-
-namespace policy {
-
-EnableNpapiPluginsPolicyHandler::EnableNpapiPluginsPolicyHandler() {
-}
-
-EnableNpapiPluginsPolicyHandler::~EnableNpapiPluginsPolicyHandler() {
-}
-
-void EnableNpapiPluginsPolicyHandler::ApplyPolicySettings(
-    const PolicyMap& policies,
-    PrefValueMap* prefs) {
-  const std::string plugin_policies[] = {key::kEnabledPlugins,
-                                         key::kPluginsAllowedForUrls,
-                                         key::kPluginsBlockedForUrls,
-                                         key::kDisabledPluginsExceptions,
-                                         key::kDisabledPlugins};
-
-  for (auto policy : plugin_policies) {
-    if (policies.GetValue(policy)) {
-      prefs->SetBoolean(prefs::kEnableNpapi, true);
-      break;
-    }
-  }
-}
-
-bool EnableNpapiPluginsPolicyHandler::CheckPolicySettings(
-    const PolicyMap& policies,
-    PolicyErrorMap* prefs) {
-  return true;
-}
-
-}  // namespace policy
diff --git a/chrome/browser/plugins/enable_npapi_plugins_policy_handler.h b/chrome/browser/plugins/enable_npapi_plugins_policy_handler.h
deleted file mode 100644
index 4ce549a..0000000
--- a/chrome/browser/plugins/enable_npapi_plugins_policy_handler.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_PLUGINS_ENABLE_NPAPI_PLUGINS_POLICY_HANDLER_H_
-#define CHROME_BROWSER_PLUGINS_ENABLE_NPAPI_PLUGINS_POLICY_HANDLER_H_
-
-#include "base/macros.h"
-#include "components/policy/core/browser/configuration_policy_handler.h"
-
-class PrefValueMap;
-
-namespace policy {
-
-class PolicyErrorMap;
-class PolicyMap;
-
-// ConfigurationPolicyHandler for the plugin policies that re-enable NPAPI.
-class EnableNpapiPluginsPolicyHandler : public ConfigurationPolicyHandler {
- public:
-  EnableNpapiPluginsPolicyHandler();
-
-  ~EnableNpapiPluginsPolicyHandler() override;
-
-  // ConfigurationPolicyHandler methods:
-  void ApplyPolicySettings(const PolicyMap& policies,
-                           PrefValueMap* prefs) override;
-  // ConfigurationPolicyHandler methods:
-  bool CheckPolicySettings(const PolicyMap& policies,
-                           PolicyErrorMap* prefs) override;
-
-  DISALLOW_COPY_AND_ASSIGN(EnableNpapiPluginsPolicyHandler);
-};
-
-}  // namespace policy
-
-#endif  // CHROME_BROWSER_PLUGINS_ENABLE_NPAPI_PLUGINS_POLICY_HANDLER_H_
diff --git a/chrome/browser/plugins/plugin_prefs.cc b/chrome/browser/plugins/plugin_prefs.cc
index b716a2a..15a8b0e 100644
--- a/chrome/browser/plugins/plugin_prefs.cc
+++ b/chrome/browser/plugins/plugin_prefs.cc
@@ -280,11 +280,6 @@
   NotifyPluginStatusChanged();
 }
 
-void PluginPrefs::EnableNpapi() {
-  PluginService::GetInstance()->EnableNpapiPlugins();
-  NotifyPluginStatusChanged();
-}
-
 /*static*/
 bool PluginPrefs::IsStringMatchedInSet(
     const base::string16& name,
@@ -491,9 +486,6 @@
   ListValueToStringSet(prefs_->GetList(prefs::kPluginsEnabledPlugins),
                        &policy_enabled_plugin_patterns_);
 
-  if (prefs_->GetBoolean(prefs::kEnableNpapi))
-    EnableNpapi();
-
   registrar_.Init(prefs_);
 
   // Because pointers to our own members will remain unchanged for the
@@ -512,9 +504,6 @@
                  base::Bind(&PluginPrefs::UpdatePatternsAndNotify,
                             base::Unretained(this),
                             &policy_enabled_plugin_patterns_));
-  registrar_.Add(prefs::kEnableNpapi,
-                 base::Bind(&PluginPrefs::EnableNpapi,
-                            base::Unretained(this)));
 
   NotifyPluginStatusChanged();
 }
diff --git a/chrome/browser/plugins/plugin_prefs.h b/chrome/browser/plugins/plugin_prefs.h
index 0407f1f..d95db2d 100644
--- a/chrome/browser/plugins/plugin_prefs.h
+++ b/chrome/browser/plugins/plugin_prefs.h
@@ -107,9 +107,6 @@
   void UpdatePatternsAndNotify(std::set<base::string16>* patterns,
                                const std::string& pref_name);
 
-  // Called to enable NPAPI if kEnableNpapi gets set by policy.
-  void EnableNpapi();
-
   // Allows unit tests to directly set enforced plugin patterns.
   void SetPolicyEnforcedPluginPatterns(
       const std::set<base::string16>& disabled_patterns,
diff --git a/chrome/browser/plugins/plugin_prefs_factory.cc b/chrome/browser/plugins/plugin_prefs_factory.cc
index 6e176b5..4bba9ad 100644
--- a/chrome/browser/plugins/plugin_prefs_factory.cc
+++ b/chrome/browser/plugins/plugin_prefs_factory.cc
@@ -64,7 +64,6 @@
   registry->RegisterListPref(prefs::kPluginsDisabledPlugins);
   registry->RegisterListPref(prefs::kPluginsDisabledPluginsExceptions);
   registry->RegisterListPref(prefs::kPluginsEnabledPlugins);
-  registry->RegisterBooleanPref(prefs::kEnableNpapi, false);
 }
 
 content::BrowserContext* PluginPrefsFactory::GetBrowserContextToUse(
diff --git a/chrome/browser/policy/configuration_policy_handler_list_factory.cc b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
index da1fba2..388fc68 100644
--- a/chrome/browser/policy/configuration_policy_handler_list_factory.cc
+++ b/chrome/browser/policy/configuration_policy_handler_list_factory.cc
@@ -62,10 +62,6 @@
 #include "extensions/common/manifest.h"
 #endif
 
-#if defined(ENABLE_PLUGINS)
-#include "chrome/browser/plugins/enable_npapi_plugins_policy_handler.h"
-#endif
-
 namespace policy {
 
 namespace {
@@ -632,10 +628,6 @@
       new extensions::ExtensionSettingsPolicyHandler(chrome_schema)));
 #endif
 
-#if defined(ENABLE_PLUGINS)
-  handlers->AddHandler(make_scoped_ptr(new EnableNpapiPluginsPolicyHandler()));
-#endif
-
 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
   handlers->AddHandler(make_scoped_ptr(new DiskCacheDirPolicyHandler()));
 
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a81946d..b9795a1 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2176,11 +2176,6 @@
       'browser/upgrade_detector_impl.cc',
       'browser/upgrade_detector_impl.h',
     ],
-    # Policy sources used if plugins are enabled.
-    'chrome_browser_policy_plugin_sources': [
-      'browser/plugins/enable_npapi_plugins_policy_handler.cc',
-      'browser/plugins/enable_npapi_plugins_policy_handler.h',
-    ],
     'chrome_browser_predictor_sources': [
       'browser/predictors/autocomplete_action_predictor.cc',
       'browser/predictors/autocomplete_action_predictor.h',
@@ -3390,9 +3385,6 @@
             ['OS=="win" or OS=="mac" or desktop_linux==1', {
               'sources': [ '<@(chrome_browser_policy_desktop_sources)' ],
             }],
-            ['enable_plugins==1', {
-              'sources': [ '<@(chrome_browser_policy_plugin_sources)' ],
-            }],
             ['OS=="android" or OS=="ios"', {  # Mobile.
               'sources': [ '<@(chrome_browser_policy_mobile_sources)' ],
             }, {  # Non-mobile.
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 41ff0eb0..c3b1f85 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -911,9 +911,6 @@
 // List pref containing names of plugins that are enabled by policy.
 const char kPluginsEnabledPlugins[] = "plugins.plugins_enabled";
 
-// Whether NPAPI plugins are enabled.
-const char kEnableNpapi[] = "plugins.enable_npapi";
-
 // When bundled NPAPI Flash is removed, if at that point it is enabled while
 // Pepper Flash is disabled, we would like to turn on Pepper Flash. And we will
 // want to do so only once.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 6936a46..504ab0d 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -313,7 +313,6 @@
 extern const char kPluginsDisabledPlugins[];
 extern const char kPluginsDisabledPluginsExceptions[];
 extern const char kPluginsEnabledPlugins[];
-extern const char kEnableNpapi[];
 extern const char kPluginsMigratedToPepperFlash[];
 extern const char kPluginsRemovedOldComponentPepperFlashSettings[];
 #if !defined(OS_ANDROID)
diff --git a/content/browser/plugin_browsertest.cc b/content/browser/plugin_browsertest.cc
index c37f7b7..efc5c8c 100644
--- a/content/browser/plugin_browsertest.cc
+++ b/content/browser/plugin_browsertest.cc
@@ -82,7 +82,7 @@
     // explicitly registered.
     command_line->AppendSwitchPath(switches::kExtraPluginDir, plugin_dir);
 #endif
-    command_line->AppendSwitch(switches::kEnableNpapi);
+    command_line->AppendSwitch(switches::kEnableNpapiForTesting);
   }
 
   void SetUpOnMainThread() override {
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index 12e7bfa..5e3f194 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -795,16 +795,14 @@
 }
 
 bool PluginServiceImpl::NPAPIPluginsSupported() {
-  if (npapi_plugins_enabled_)
-    return true;
-
   static bool command_line_checked = false;
 
   if (!command_line_checked) {
 #if defined(OS_WIN) || defined(OS_MACOSX)
     const base::CommandLine* command_line =
         base::CommandLine::ForCurrentProcess();
-    npapi_plugins_enabled_ = command_line->HasSwitch(switches::kEnableNpapi);
+    npapi_plugins_enabled_ =
+        command_line->HasSwitch(switches::kEnableNpapiForTesting);
     NPAPIPluginStatus status =
         npapi_plugins_enabled_ ? NPAPI_STATUS_ENABLED : NPAPI_STATUS_DISABLED;
 #else
@@ -821,18 +819,6 @@
   PluginList::Singleton()->DisablePluginsDiscovery();
 }
 
-void PluginServiceImpl::EnableNpapiPlugins() {
-#if defined(OS_WIN)
-  DisableWin32kRendererLockdown();
-#endif
-  npapi_plugins_enabled_ = true;
-  RefreshPlugins();
-  BrowserThread::PostTask(
-      BrowserThread::UI, FROM_HERE,
-      base::Bind(&PluginService::PurgePluginListCache,
-                 static_cast<BrowserContext*>(NULL), false));
-}
-
 #if defined(OS_MACOSX)
 void PluginServiceImpl::AppActivated() {
   BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
diff --git a/content/browser/plugin_service_impl.h b/content/browser/plugin_service_impl.h
index 1d419e0..2e107a6d 100644
--- a/content/browser/plugin_service_impl.h
+++ b/content/browser/plugin_service_impl.h
@@ -106,7 +106,6 @@
   void UnregisterInternalPlugin(const base::FilePath& path) override;
   void GetInternalPlugins(std::vector<WebPluginInfo>* plugins) override;
   bool NPAPIPluginsSupported() override;
-  void EnableNpapiPlugins() override;
   void DisablePluginsDiscoveryForTesting() override;
 #if defined(OS_MACOSX)
   void AppActivated() override;
diff --git a/content/public/browser/plugin_service.h b/content/public/browser/plugin_service.h
index c09331e..0fb20e9 100644
--- a/content/public/browser/plugin_service.h
+++ b/content/public/browser/plugin_service.h
@@ -143,9 +143,6 @@
   // This can be called from any thread.
   virtual bool NPAPIPluginsSupported() = 0;
 
-  // This is equivalent to specifying kEnableNpapi.
-  virtual void EnableNpapiPlugins() = 0;
-
   // This is equivalent to specifying kDisablePluginsDiscovery, but is useful
   // for unittests.
   virtual void DisablePluginsDiscoveryForTesting() = 0;
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index d258df5..2dbba59 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -1008,7 +1008,7 @@
 #endif
 
 // Enables the use of NPAPI plugins.
-const char kEnableNpapi[]                   = "enable-npapi";
+const char kEnableNpapiForTesting[] = "enable-npapi-for-testing";
 
 // Don't dump stuff here, follow the same order as the header.
 
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 110af98..0b192f6 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -298,7 +298,7 @@
 CONTENT_EXPORT extern const char kTraceExportEventsToETW[];
 #endif
 
-CONTENT_EXPORT extern const char kEnableNpapi[];
+CONTENT_EXPORT extern const char kEnableNpapiForTesting[];
 
 // DON'T ADD RANDOM STUFF HERE. Put it in the main section above in
 // alphabetical order, or in one of the ifdefs (also in order in each section).
diff --git a/content/shell/app/shell_main_delegate.cc b/content/shell/app/shell_main_delegate.cc
index f62d032..42fb382 100644
--- a/content/shell/app/shell_main_delegate.cc
+++ b/content/shell/app/shell_main_delegate.cc
@@ -203,7 +203,7 @@
                                    "MAP *.test 127.0.0.1");
 
     // TODO(wfh): crbug.com/295137 Remove this when NPAPI is gone.
-    command_line.AppendSwitch(switches::kEnableNpapi);
+    command_line.AppendSwitch(switches::kEnableNpapiForTesting);
 
     // Unless/until WebM files are added to the media layout tests, we need to
     // avoid removing MP4/H264/AAC so that layout tests can run on Android.
diff --git a/content/test/fake_plugin_service.cc b/content/test/fake_plugin_service.cc
index ae7d7a6..1d7767cb 100644
--- a/content/test/fake_plugin_service.cc
+++ b/content/test/fake_plugin_service.cc
@@ -101,9 +101,6 @@
   return false;
 }
 
-void FakePluginService::EnableNpapiPlugins() {
-}
-
 void FakePluginService::DisablePluginsDiscoveryForTesting() {
 }
 
diff --git a/content/test/fake_plugin_service.h b/content/test/fake_plugin_service.h
index 3a19932..b8d15d4c 100644
--- a/content/test/fake_plugin_service.h
+++ b/content/test/fake_plugin_service.h
@@ -52,7 +52,6 @@
   void UnregisterInternalPlugin(const base::FilePath& path) override;
   void GetInternalPlugins(std::vector<WebPluginInfo>* plugins) override;
   bool NPAPIPluginsSupported() override;
-  void EnableNpapiPlugins() override;
   void DisablePluginsDiscoveryForTesting() override;
 #if defined(OS_MACOSX)
   void AppActivated() override;