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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 // process during their lifetime. | 52 // process during their lifetime. |
53 START_NPAPI_FLASH_AT_LEAST_ONCE, | 53 START_NPAPI_FLASH_AT_LEAST_ONCE, |
54 // Number of browser processes that have started at least one PPAPI Flash | 54 // Number of browser processes that have started at least one PPAPI Flash |
55 // process during their lifetime. | 55 // process during their lifetime. |
56 START_PPAPI_FLASH_AT_LEAST_ONCE, | 56 START_PPAPI_FLASH_AT_LEAST_ONCE, |
57 // Total number of browser processes. | 57 // Total number of browser processes. |
58 TOTAL_BROWSER_PROCESSES, | 58 TOTAL_BROWSER_PROCESSES, |
59 FLASH_USAGE_ENUM_COUNT | 59 FLASH_USAGE_ENUM_COUNT |
60 }; | 60 }; |
61 | 61 |
62 enum NPAPIPluginStatus { | |
63 // Platform does not support NPAPI. | |
64 NPAPI_STATUS_UNSUPPORTED, | |
65 // Platform supports NPAPI and NPAPI is disabled. | |
66 NPAPI_STATUS_DISABLED, | |
67 // Platform supports NPAPI and NPAPI is enabled. | |
68 NPAPI_STATUS_ENABLED, | |
69 NPAPI_STATUS_ENUM_COUNT | |
70 }; | |
71 | |
62 bool LoadPluginListInProcess() { | 72 bool LoadPluginListInProcess() { |
63 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
64 return true; | 74 return true; |
65 #else | 75 #else |
66 // If on POSIX, we don't want to load the list of NPAPI plugins in-process as | 76 // If on POSIX, we don't want to load the list of NPAPI plugins in-process as |
67 // that causes instability. | 77 // that causes instability. |
68 | 78 |
69 // Can't load the plugins on the utility thread when in single process mode | 79 // Can't load the plugins on the utility thread when in single process mode |
70 // since that requires GTK which can only be used on the main thread. | 80 // since that requires GTK which can only be used on the main thread. |
71 if (RenderProcessHost::run_renderer_in_process()) | 81 if (RenderProcessHost::run_renderer_in_process()) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 host->Send(new ViewMsg_PurgePluginListCache(reload_pages)); | 146 host->Send(new ViewMsg_PurgePluginListCache(reload_pages)); |
137 } | 147 } |
138 } | 148 } |
139 | 149 |
140 // static | 150 // static |
141 PluginServiceImpl* PluginServiceImpl::GetInstance() { | 151 PluginServiceImpl* PluginServiceImpl::GetInstance() { |
142 return Singleton<PluginServiceImpl>::get(); | 152 return Singleton<PluginServiceImpl>::get(); |
143 } | 153 } |
144 | 154 |
145 PluginServiceImpl::PluginServiceImpl() | 155 PluginServiceImpl::PluginServiceImpl() |
146 : filter_(NULL) { | 156 : npapi_plugins_enabled_(false), filter_(NULL) { |
147 // Collect the total number of browser processes (which create | 157 // Collect the total number of browser processes (which create |
148 // PluginServiceImpl objects, to be precise). The number is used to normalize | 158 // PluginServiceImpl objects, to be precise). The number is used to normalize |
149 // the number of processes which start at least one NPAPI/PPAPI Flash process. | 159 // the number of processes which start at least one NPAPI/PPAPI Flash process. |
150 static bool counted = false; | 160 static bool counted = false; |
151 if (!counted) { | 161 if (!counted) { |
152 counted = true; | 162 counted = true; |
153 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES, | 163 UMA_HISTOGRAM_ENUMERATION("Plugin.FlashUsage", TOTAL_BROWSER_PROCESSES, |
154 FLASH_USAGE_ENUM_COUNT); | 164 FLASH_USAGE_ENUM_COUNT); |
155 } | 165 } |
156 } | 166 } |
(...skipping 16 matching lines...) Expand all Loading... | |
173 base::FilePath path = | 183 base::FilePath path = |
174 command_line->GetSwitchValuePath(switches::kLoadPlugin); | 184 command_line->GetSwitchValuePath(switches::kLoadPlugin); |
175 if (!path.empty()) | 185 if (!path.empty()) |
176 AddExtraPluginPath(path); | 186 AddExtraPluginPath(path); |
177 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); | 187 path = command_line->GetSwitchValuePath(switches::kExtraPluginDir); |
178 if (!path.empty()) | 188 if (!path.empty()) |
179 PluginList::Singleton()->AddExtraPluginDir(path); | 189 PluginList::Singleton()->AddExtraPluginDir(path); |
180 | 190 |
181 if (command_line->HasSwitch(switches::kDisablePluginsDiscovery)) | 191 if (command_line->HasSwitch(switches::kDisablePluginsDiscovery)) |
182 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 UMA_HISTOGRAM_ENUMERATION( | |
196 "Plugin.NPAPIStatus", | |
197 npapi_plugins_enabled_ ? NPAPI_STATUS_ENABLED : NPAPI_STATUS_DISABLED, | |
198 NPAPI_STATUS_ENUM_COUNT); | |
199 #else | |
200 UMA_HISTOGRAM_ENUMERATION("Plugin.NPAPIStatus", NPAPI_STATUS_UNSUPPORTED, | |
201 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.
| |
202 #endif | |
183 } | 203 } |
184 | 204 |
185 void PluginServiceImpl::StartWatchingPlugins() { | 205 void PluginServiceImpl::StartWatchingPlugins() { |
186 // Start watching for changes in the plugin list. This means watching | 206 // Start watching for changes in the plugin list. This means watching |
187 // for changes in the Windows registry keys and on both Windows and POSIX | 207 // for changes in the Windows registry keys and on both Windows and POSIX |
188 // watch for changes in the paths that are expected to contain plugins. | 208 // watch for changes in the paths that are expected to contain plugins. |
189 #if defined(OS_WIN) | 209 #if defined(OS_WIN) |
190 if (hkcu_key_.Create(HKEY_CURRENT_USER, | 210 if (hkcu_key_.Create(HKEY_CURRENT_USER, |
191 kRegistryMozillaPlugins, | 211 kRegistryMozillaPlugins, |
192 KEY_NOTIFY) == ERROR_SUCCESS) { | 212 KEY_NOTIFY) == ERROR_SUCCESS) { |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
771 void PluginServiceImpl::UnregisterInternalPlugin(const base::FilePath& path) { | 791 void PluginServiceImpl::UnregisterInternalPlugin(const base::FilePath& path) { |
772 PluginList::Singleton()->UnregisterInternalPlugin(path); | 792 PluginList::Singleton()->UnregisterInternalPlugin(path); |
773 } | 793 } |
774 | 794 |
775 void PluginServiceImpl::GetInternalPlugins( | 795 void PluginServiceImpl::GetInternalPlugins( |
776 std::vector<WebPluginInfo>* plugins) { | 796 std::vector<WebPluginInfo>* plugins) { |
777 PluginList::Singleton()->GetInternalPlugins(plugins); | 797 PluginList::Singleton()->GetInternalPlugins(plugins); |
778 } | 798 } |
779 | 799 |
780 bool PluginServiceImpl::NPAPIPluginsSupported() { | 800 bool PluginServiceImpl::NPAPIPluginsSupported() { |
781 #if defined(OS_WIN) || defined(OS_MACOSX) | 801 return npapi_plugins_enabled_; |
782 return true; | |
783 #else | |
784 return false; | |
785 #endif | |
786 } | 802 } |
787 | 803 |
788 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() { | 804 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() { |
789 PluginList::Singleton()->DisablePluginsDiscovery(); | 805 PluginList::Singleton()->DisablePluginsDiscovery(); |
790 } | 806 } |
791 | 807 |
808 void PluginServiceImpl::EnableNpapiPluginsForTesting() { | |
809 npapi_plugins_enabled_ = true; | |
810 } | |
811 | |
792 #if defined(OS_MACOSX) | 812 #if defined(OS_MACOSX) |
793 void PluginServiceImpl::AppActivated() { | 813 void PluginServiceImpl::AppActivated() { |
794 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 814 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
795 base::Bind(&NotifyPluginsOfActivation)); | 815 base::Bind(&NotifyPluginsOfActivation)); |
796 } | 816 } |
797 #elif defined(OS_WIN) | 817 #elif defined(OS_WIN) |
798 | 818 |
799 bool GetPluginPropertyFromWindow( | 819 bool GetPluginPropertyFromWindow( |
800 HWND window, const wchar_t* plugin_atom_property, | 820 HWND window, const wchar_t* plugin_atom_property, |
801 base::string16* plugin_property) { | 821 base::string16* plugin_property) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
837 #endif | 857 #endif |
838 | 858 |
839 bool PluginServiceImpl::PpapiDevChannelSupported( | 859 bool PluginServiceImpl::PpapiDevChannelSupported( |
840 BrowserContext* browser_context, | 860 BrowserContext* browser_context, |
841 const GURL& document_url) { | 861 const GURL& document_url) { |
842 return content::GetContentClient()->browser()-> | 862 return content::GetContentClient()->browser()-> |
843 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); | 863 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); |
844 } | 864 } |
845 | 865 |
846 } // namespace content | 866 } // namespace content |
OLD | NEW |