Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Unified Diff: content/browser/plugin_service_impl.cc

Issue 645203002: Block NPAPI plugins by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add NPAPI UMA histogram Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/public/browser/plugin_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/plugin_service_impl.cc
diff --git a/content/browser/plugin_service_impl.cc b/content/browser/plugin_service_impl.cc
index 49b66389dd3703de6c9f4cd91d8e228cdc7d7db9..610ee3a7923cb5bef71c9d311a3881db61b1c8bc 100644
--- a/content/browser/plugin_service_impl.cc
+++ b/content/browser/plugin_service_impl.cc
@@ -59,6 +59,16 @@ enum FlashUsage {
FLASH_USAGE_ENUM_COUNT
};
+enum NPAPIPluginStatus {
+ // Platform does not support NPAPI.
+ NPAPI_STATUS_UNSUPPORTED,
+ // Platform supports NPAPI and NPAPI is disabled.
+ NPAPI_STATUS_DISABLED,
+ // Platform supports NPAPI and NPAPI is enabled.
+ NPAPI_STATUS_ENABLED,
+ NPAPI_STATUS_ENUM_COUNT
+};
+
bool LoadPluginListInProcess() {
#if defined(OS_WIN)
return true;
@@ -143,7 +153,7 @@ PluginServiceImpl* PluginServiceImpl::GetInstance() {
}
PluginServiceImpl::PluginServiceImpl()
- : filter_(NULL) {
+ : npapi_plugins_enabled_(false), filter_(NULL) {
// Collect the total number of browser processes (which create
// PluginServiceImpl objects, to be precise). The number is used to normalize
// the number of processes which start at least one NPAPI/PPAPI Flash process.
@@ -180,6 +190,16 @@ 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);
+ UMA_HISTOGRAM_ENUMERATION(
+ "Plugin.NPAPIStatus",
+ npapi_plugins_enabled_ ? NPAPI_STATUS_ENABLED : NPAPI_STATUS_DISABLED,
+ NPAPI_STATUS_ENUM_COUNT);
+#else
+ UMA_HISTOGRAM_ENUMERATION("Plugin.NPAPIStatus", NPAPI_STATUS_UNSUPPORTED,
+ NPAPI_STATUS_ENUM_COUNT);
Ilya Sherman 2015/01/20 20:45:18 nit: To reduce the risk of typos creeping in to on
Will Harris 2015/01/20 22:35:11 Done.
+#endif
}
void PluginServiceImpl::StartWatchingPlugins() {
@@ -778,17 +798,17 @@ void PluginServiceImpl::GetInternalPlugins(
}
bool PluginServiceImpl::NPAPIPluginsSupported() {
-#if defined(OS_WIN) || defined(OS_MACOSX)
- return true;
-#else
- return false;
-#endif
+ return npapi_plugins_enabled_;
}
void PluginServiceImpl::DisablePluginsDiscoveryForTesting() {
PluginList::Singleton()->DisablePluginsDiscovery();
}
+void PluginServiceImpl::EnableNpapiPluginsForTesting() {
+ npapi_plugins_enabled_ = true;
+}
+
#if defined(OS_MACOSX)
void PluginServiceImpl::AppActivated() {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/public/browser/plugin_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698