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

Side by Side 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: missing test file Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 base::FilePath path = 183 base::FilePath path =
184 command_line->GetSwitchValuePath(switches::kLoadPlugin); 184 command_line->GetSwitchValuePath(switches::kLoadPlugin);
185 if (!path.empty()) 185 if (!path.empty())
186 AddExtraPluginPath(path); 186 AddExtraPluginPath(path);
187 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); 187 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir);
188 if (!path.empty()) 188 if (!path.empty())
189 PluginList::Singleton()->AddExtraPluginDir(path); 189 PluginList::Singleton()->AddExtraPluginDir(path);
190 190
191 if (command_line->HasSwitch(switches::kDisablePluginsDiscovery)) 191 if (command_line->HasSwitch(switches::kDisablePluginsDiscovery))
192 PluginList::Singleton()->DisablePluginsDiscovery(); 192 PluginList::Singleton()->DisablePluginsDiscovery();
193 #if defined(OS_WIN) || defined(OS_MACOSX)
194 npapi_plugins_enabled_ = command_line->HasSwitch(switches::kEnableNpapi);
195 #endif
193 } 196 }
194 197
195 void PluginServiceImpl::StartWatchingPlugins() { 198 void PluginServiceImpl::StartWatchingPlugins() {
196 // Start watching for changes in the plugin list. This means watching 199 // Start watching for changes in the plugin list. This means watching
197 // for changes in the Windows registry keys and on both Windows and POSIX 200 // for changes in the Windows registry keys and on both Windows and POSIX
198 // watch for changes in the paths that are expected to contain plugins. 201 // watch for changes in the paths that are expected to contain plugins.
199 #if defined(OS_WIN) 202 #if defined(OS_WIN)
200 if (hkcu_key_.Create(HKEY_CURRENT_USER, 203 if (hkcu_key_.Create(HKEY_CURRENT_USER,
201 kRegistryMozillaPlugins, 204 kRegistryMozillaPlugins,
202 KEY_NOTIFY) == ERROR_SUCCESS) { 205 KEY_NOTIFY) == ERROR_SUCCESS) {
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 PluginList::Singleton()->UnregisterInternalPlugin(path); 797 PluginList::Singleton()->UnregisterInternalPlugin(path);
795 } 798 }
796 799
797 void PluginServiceImpl::GetInternalPlugins( 800 void PluginServiceImpl::GetInternalPlugins(
798 std::vector<WebPluginInfo>* plugins) { 801 std::vector<WebPluginInfo>* plugins) {
799 PluginList::Singleton()->GetInternalPlugins(plugins); 802 PluginList::Singleton()->GetInternalPlugins(plugins);
800 } 803 }
801 804
802 bool PluginServiceImpl::NPAPIPluginsSupported() { 805 bool PluginServiceImpl::NPAPIPluginsSupported() {
803 #if defined(OS_WIN) || defined(OS_MACOSX) 806 #if defined(OS_WIN) || defined(OS_MACOSX)
804 return true; 807 return npapi_plugins_enabled_;
805 #else 808 #else
806 return false; 809 return false;
807 #endif 810 #endif
808 } 811 }
809 812
810 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() { 813 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() {
811 PluginList::Singleton()->DisablePluginsDiscovery(); 814 PluginList::Singleton()->DisablePluginsDiscovery();
812 } 815 }
813 816
817 #if defined(OS_WIN) || defined(OS_MACOSX)
818 void PluginServiceImpl::EnableNpapiPluginsForTesting() {
819 npapi_plugins_enabled_ = true;
820 }
821 #endif
822
814 #if defined(OS_MACOSX) 823 #if defined(OS_MACOSX)
815 void PluginServiceImpl::AppActivated() { 824 void PluginServiceImpl::AppActivated() {
816 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 825 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
817 base::Bind(&NotifyPluginsOfActivation)); 826 base::Bind(&NotifyPluginsOfActivation));
818 } 827 }
819 #elif defined(OS_WIN) 828 #elif defined(OS_WIN)
820 829
821 bool GetPluginPropertyFromWindow( 830 bool GetPluginPropertyFromWindow(
822 HWND window, const wchar_t* plugin_atom_property, 831 HWND window, const wchar_t* plugin_atom_property,
823 base::string16* plugin_property) { 832 base::string16* plugin_property) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 #endif 868 #endif
860 869
861 bool PluginServiceImpl::PpapiDevChannelSupported( 870 bool PluginServiceImpl::PpapiDevChannelSupported(
862 BrowserContext* browser_context, 871 BrowserContext* browser_context,
863 const GURL& document_url) { 872 const GURL& document_url) {
864 return content::GetContentClient()->browser()-> 873 return content::GetContentClient()->browser()->
865 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); 874 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url);
866 } 875 }
867 876
868 } // namespace content 877 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698