OLD | NEW |
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 host->Send(new ViewMsg_PurgePluginListCache(reload_pages)); | 137 host->Send(new ViewMsg_PurgePluginListCache(reload_pages)); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 // static | 141 // static |
142 PluginServiceImpl* PluginServiceImpl::GetInstance() { | 142 PluginServiceImpl* PluginServiceImpl::GetInstance() { |
143 return Singleton<PluginServiceImpl>::get(); | 143 return Singleton<PluginServiceImpl>::get(); |
144 } | 144 } |
145 | 145 |
146 PluginServiceImpl::PluginServiceImpl() | 146 PluginServiceImpl::PluginServiceImpl() |
147 : filter_(NULL) { | 147 : npapi_plugins_enabled_(false), filter_(NULL) { |
148 // Collect the total number of browser processes (which create | 148 // Collect the total number of browser processes (which create |
149 // PluginServiceImpl objects, to be precise). The number is used to normalize | 149 // PluginServiceImpl objects, to be precise). The number is used to normalize |
150 // the number of processes which start at least one NPAPI/PPAPI Flash process. | 150 // the number of processes which start at least one NPAPI/PPAPI Flash process. |
151 static bool counted = false; | 151 static bool counted = false; |
152 if (!counted) { | 152 if (!counted) { |
153 counted = true; | 153 counted = true; |
154 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES, | 154 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES, |
155 FLASH_USAGE_ENUM_COUNT); | 155 FLASH_USAGE_ENUM_COUNT); |
156 } | 156 } |
157 } | 157 } |
(...skipping 16 matching lines...) Expand all Loading... |
174 base::FilePath path = | 174 base::FilePath path = |
175 command_line->GetSwitchValuePath(switches::kLoadPlugin); | 175 command_line->GetSwitchValuePath(switches::kLoadPlugin); |
176 if (!path.empty()) | 176 if (!path.empty()) |
177 AddExtraPluginPath(path); | 177 AddExtraPluginPath(path); |
178 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); | 178 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); |
179 if (!path.empty()) | 179 if (!path.empty()) |
180 PluginList::Singleton()->AddExtraPluginDir(path); | 180 PluginList::Singleton()->AddExtraPluginDir(path); |
181 | 181 |
182 if (command_line->HasSwitch(switches::kDisablePluginsDiscovery)) | 182 if (command_line->HasSwitch(switches::kDisablePluginsDiscovery)) |
183 PluginList::Singleton()->DisablePluginsDiscovery(); | 183 PluginList::Singleton()->DisablePluginsDiscovery(); |
| 184 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 185 npapi_plugins_enabled_ = command_line->HasSwitch(switches::kEnableNpapi); |
| 186 #endif |
184 } | 187 } |
185 | 188 |
186 void PluginServiceImpl::StartWatchingPlugins() { | 189 void PluginServiceImpl::StartWatchingPlugins() { |
187 // Start watching for changes in the plugin list. This means watching | 190 // Start watching for changes in the plugin list. This means watching |
188 // for changes in the Windows registry keys and on both Windows and POSIX | 191 // for changes in the Windows registry keys and on both Windows and POSIX |
189 // watch for changes in the paths that are expected to contain plugins. | 192 // watch for changes in the paths that are expected to contain plugins. |
190 #if defined(OS_WIN) | 193 #if defined(OS_WIN) |
191 if (hkcu_key_.Create(HKEY_CURRENT_USER, | 194 if (hkcu_key_.Create(HKEY_CURRENT_USER, |
192 kRegistryMozillaPlugins, | 195 kRegistryMozillaPlugins, |
193 KEY_NOTIFY) == ERROR_SUCCESS) { | 196 KEY_NOTIFY) == ERROR_SUCCESS) { |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 void PluginServiceImpl::UnregisterInternalPlugin(const base::FilePath& path) { | 775 void PluginServiceImpl::UnregisterInternalPlugin(const base::FilePath& path) { |
773 PluginList::Singleton()->UnregisterInternalPlugin(path); | 776 PluginList::Singleton()->UnregisterInternalPlugin(path); |
774 } | 777 } |
775 | 778 |
776 void PluginServiceImpl::GetInternalPlugins( | 779 void PluginServiceImpl::GetInternalPlugins( |
777 std::vector<WebPluginInfo>* plugins) { | 780 std::vector<WebPluginInfo>* plugins) { |
778 PluginList::Singleton()->GetInternalPlugins(plugins); | 781 PluginList::Singleton()->GetInternalPlugins(plugins); |
779 } | 782 } |
780 | 783 |
781 bool PluginServiceImpl::NPAPIPluginsSupported() { | 784 bool PluginServiceImpl::NPAPIPluginsSupported() { |
782 #if defined(OS_WIN) || defined(OS_MACOSX) | 785 return npapi_plugins_enabled_; |
783 return true; | |
784 #else | |
785 return false; | |
786 #endif | |
787 } | 786 } |
788 | 787 |
789 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() { | 788 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() { |
790 PluginList::Singleton()->DisablePluginsDiscovery(); | 789 PluginList::Singleton()->DisablePluginsDiscovery(); |
791 } | 790 } |
792 | 791 |
| 792 void PluginServiceImpl::EnableNpapiPluginsForTesting() { |
| 793 npapi_plugins_enabled_ = true; |
| 794 } |
| 795 |
793 #if defined(OS_MACOSX) | 796 #if defined(OS_MACOSX) |
794 void PluginServiceImpl::AppActivated() { | 797 void PluginServiceImpl::AppActivated() { |
795 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 798 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
796 base::Bind(&NotifyPluginsOfActivation)); | 799 base::Bind(&NotifyPluginsOfActivation)); |
797 } | 800 } |
798 #elif defined(OS_WIN) | 801 #elif defined(OS_WIN) |
799 | 802 |
800 bool GetPluginPropertyFromWindow( | 803 bool GetPluginPropertyFromWindow( |
801 HWND window, const wchar_t* plugin_atom_property, | 804 HWND window, const wchar_t* plugin_atom_property, |
802 base::string16* plugin_property) { | 805 base::string16* plugin_property) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 #endif | 841 #endif |
839 | 842 |
840 bool PluginServiceImpl::PpapiDevChannelSupported( | 843 bool PluginServiceImpl::PpapiDevChannelSupported( |
841 BrowserContext* browser_context, | 844 BrowserContext* browser_context, |
842 const GURL& document_url) { | 845 const GURL& document_url) { |
843 return content::GetContentClient()->browser()-> | 846 return content::GetContentClient()->browser()-> |
844 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); | 847 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); |
845 } | 848 } |
846 | 849 |
847 } // namespace content | 850 } // namespace content |
OLD | NEW |