summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwfh <wfh@chromium.org>2015-02-20 08:13:13 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-20 16:13:49 +0000
commita79d102fed6a32ad05901ff9eb2fa8b9241639fd (patch)
treeacc5deea9de11abd32b58667c2a91e15e6c947df
parentd2eea9397df6594f3e92aaa81328c8dd976adfea (diff)
downloadchromium_src-a79d102fed6a32ad05901ff9eb2fa8b9241639fd.zip
chromium_src-a79d102fed6a32ad05901ff9eb2fa8b9241639fd.tar.gz
chromium_src-a79d102fed6a32ad05901ff9eb2fa8b9241639fd.tar.bz2
Enable NPAPI plugins if any plugin policies are set.
Once NPAPI is pushed behind a flag in M42, enterprise polices that are set need to re-enable NPAPI plugins correctly. This CL covers all the policy cases and is intended to be a wide net to catch any/all policies. We don't particularly mind if this has a few false positives, because NPAPI will be totally gone soon. BUG=295137 TEST=Set e.g. EnabledPlugins policy. Check that NPAPI plugins are listed in chrome://plugins Review URL: https://codereview.chromium.org/930243008 Cr-Commit-Position: refs/heads/master@{#317329}
-rw-r--r--chrome/browser/plugins/plugin_prefs_unittest.cc7
-rw-r--r--chrome/browser/policy/chrome_browser_policy_connector.cc22
-rw-r--r--chrome/browser/policy/chrome_browser_policy_connector.h5
-rw-r--r--content/browser/download/download_browsertest.cc1
-rw-r--r--content/browser/plugin_service_impl.cc30
5 files changed, 48 insertions, 17 deletions
diff --git a/chrome/browser/plugins/plugin_prefs_unittest.cc b/chrome/browser/plugins/plugin_prefs_unittest.cc
index 70deb5d..49c76c0 100644
--- a/chrome/browser/plugins/plugin_prefs_unittest.cc
+++ b/chrome/browser/plugins/plugin_prefs_unittest.cc
@@ -208,7 +208,6 @@ TEST_F(PluginPrefsTest, UnifiedPepperFlashState) {
PluginService::GetInstance()->Init();
PluginService::GetInstance()->DisablePluginsDiscoveryForTesting();
- PluginService::GetInstance()->EnableNpapiPluginsForTesting();
base::string16 component_updated_plugin_name(
ASCIIToUTF16("Component-updated Pepper Flash"));
@@ -226,6 +225,12 @@ TEST_F(PluginPrefsTest, UnifiedPepperFlashState) {
GetBundledPepperFlashPath(),
ASCIIToUTF16("11.3.31.229"),
ASCIIToUTF16(""));
+ component_updated_plugin_1.type =
+ content::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS;
+ component_updated_plugin_2.type =
+ content::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS;
+ bundled_plugin.type =
+ content::WebPluginInfo::PLUGIN_TYPE_PEPPER_OUT_OF_PROCESS;
PluginService::GetInstance()->RegisterInternalPlugin(
component_updated_plugin_1, false);
diff --git a/chrome/browser/policy/chrome_browser_policy_connector.cc b/chrome/browser/policy/chrome_browser_policy_connector.cc
index 24ce2a6..e233a87 100644
--- a/chrome/browser/policy/chrome_browser_policy_connector.cc
+++ b/chrome/browser/policy/chrome_browser_policy_connector.cc
@@ -25,6 +25,7 @@
#include "components/policy/core/common/policy_types.h"
#include "components/signin/core/common/signin_switches.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/common/content_switches.h"
#include "net/url_request/url_request_context_getter.h"
#include "policy/policy_constants.h"
@@ -89,7 +90,7 @@ void ChromeBrowserPolicyConnector::Init(
BrowserPolicyConnector::Init(
local_state, request_context, device_management_service.Pass());
- AppendExtraFlagPerPolicy();
+ AppendExtraFlagsPerPolicy();
}
ConfigurationPolicyProvider*
@@ -123,7 +124,7 @@ ConfigurationPolicyProvider*
#endif
}
-void ChromeBrowserPolicyConnector::AppendExtraFlagPerPolicy() {
+void ChromeBrowserPolicyConnector::AppendExtraFlagsPerPolicy() {
PolicyService* policy_service = GetPolicyService();
PolicyNamespace chrome_ns = PolicyNamespace(POLICY_DOMAIN_CHROME, "");
const PolicyMap& chrome_policy = policy_service->GetPolicies(chrome_ns);
@@ -139,6 +140,23 @@ void ChromeBrowserPolicyConnector::AppendExtraFlagPerPolicy() {
if (!command_line->HasSwitch(switches::kEnableIframeBasedSignin))
command_line->AppendSwitch(switches::kEnableIframeBasedSignin);
}
+
+ if (command_line->HasSwitch(switches::kEnableNpapi))
+ return;
+
+ // The list of Plugin related policies that re-enable NPAPI. Remove once NPAPI
+ // is dead.
+ const std::string plugin_policies[] = { key::kEnabledPlugins,
+ key::kPluginsAllowedForUrls,
+ key::kPluginsBlockedForUrls,
+ key::kDisabledPluginsExceptions,
+ key::kDisabledPlugins };
+ for (auto policy : plugin_policies) {
+ if (chrome_policy.GetValue(policy)) {
+ command_line->AppendSwitch(switches::kEnableNpapi);
+ break;
+ }
+ }
}
} // namespace policy
diff --git a/chrome/browser/policy/chrome_browser_policy_connector.h b/chrome/browser/policy/chrome_browser_policy_connector.h
index 2d0fdde..78c8224 100644
--- a/chrome/browser/policy/chrome_browser_policy_connector.h
+++ b/chrome/browser/policy/chrome_browser_policy_connector.h
@@ -40,11 +40,10 @@ class ChromeBrowserPolicyConnector : public BrowserPolicyConnector {
private:
ConfigurationPolicyProvider* CreatePlatformProvider();
- // Appends the --enable-web-based-signin flag if the
- // enable-web-based-signin policy is enabled.
+ // Appends any required flags if certain policies are set.
// TODO(guohui): Needs to move this to a more proper place and also to handle
// dynamic refresh.
- void AppendExtraFlagPerPolicy();
+ void AppendExtraFlagsPerPolicy();
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserPolicyConnector);
};
diff --git a/content/browser/download/download_browsertest.cc b/content/browser/download/download_browsertest.cc
index a2e7524..b39e04e 100644
--- a/content/browser/download/download_browsertest.cc
+++ b/content/browser/download/download_browsertest.cc
@@ -854,6 +854,7 @@ IN_PROC_BROWSER_TEST_F(DownloadContentTest, DownloadOctetStream) {
plugin_info.name = base::ASCIIToUTF16(kTestPluginName);
plugin_info.mime_types.push_back(
WebPluginMimeType(kTestMimeType, kTestFileType, ""));
+ plugin_info.type = WebPluginInfo::PLUGIN_TYPE_PEPPER_IN_PROCESS;
PluginServiceImpl::GetInstance()->RegisterInternalPlugin(plugin_info, false);
// The following is served with a Content-Type of application/octet-stream.
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index 42ac63b..e431095 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -190,15 +190,6 @@ void PluginServiceImpl::Init() {
if (command_line->HasSwitch(switches::kDisablePluginsDiscovery))
PluginList::Singleton()->DisablePluginsDiscovery();
-#if defined(OS_WIN) || defined(OS_MACOSX)
- npapi_plugins_enabled_ = command_line->HasSwitch(switches::kEnableNpapi);
- NPAPIPluginStatus status =
- npapi_plugins_enabled_ ? NPAPI_STATUS_ENABLED : NPAPI_STATUS_DISABLED;
-#else
- NPAPIPluginStatus status = NPAPI_STATUS_UNSUPPORTED;
-#endif
- UMA_HISTOGRAM_ENUMERATION("Plugin.NPAPIStatus", status,
- NPAPI_STATUS_ENUM_COUNT);
}
void PluginServiceImpl::StartWatchingPlugins() {
@@ -779,8 +770,9 @@ void PluginServiceImpl::AddExtraPluginDir(const base::FilePath& path) {
void PluginServiceImpl::RegisterInternalPlugin(
const WebPluginInfo& info,
bool add_at_beginning) {
- if (!NPAPIPluginsSupported() &&
- info.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) {
+ // Internal plugins should never be NPAPI.
+ CHECK_NE(info.type, WebPluginInfo::PLUGIN_TYPE_NPAPI);
+ if (info.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) {
DVLOG(0) << "Don't register NPAPI plugins when they're not supported";
return;
}
@@ -797,6 +789,22 @@ void PluginServiceImpl::GetInternalPlugins(
}
bool PluginServiceImpl::NPAPIPluginsSupported() {
+ 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);
+ NPAPIPluginStatus status =
+ npapi_plugins_enabled_ ? NPAPI_STATUS_ENABLED : NPAPI_STATUS_DISABLED;
+#else
+ NPAPIPluginStatus status = NPAPI_STATUS_UNSUPPORTED;
+#endif
+ UMA_HISTOGRAM_ENUMERATION("Plugin.NPAPIStatus", status,
+ NPAPI_STATUS_ENUM_COUNT);
+ }
+
return npapi_plugins_enabled_;
}