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 NPAPIPluginStatus status = |
| 196 npapi_plugins_enabled_ ? NPAPI_STATUS_ENABLED : NPAPI_STATUS_DISABLED; |
| 197 #else |
| 198 NPAPIPluginStatus status = NPAPI_STATUS_UNSUPPORTED; |
| 199 #endif |
| 200 UMA_HISTOGRAM_ENUMERATION("Plugin.NPAPIStatus", status, |
| 201 NPAPI_STATUS_ENUM_COUNT); |
183 } | 202 } |
184 | 203 |
185 void PluginServiceImpl::StartWatchingPlugins() { | 204 void PluginServiceImpl::StartWatchingPlugins() { |
186 // Start watching for changes in the plugin list. This means watching | 205 // 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 | 206 // 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. | 207 // watch for changes in the paths that are expected to contain plugins. |
189 #if defined(OS_WIN) | 208 #if defined(OS_WIN) |
190 if (hkcu_key_.Create(HKEY_CURRENT_USER, | 209 if (hkcu_key_.Create(HKEY_CURRENT_USER, |
191 kRegistryMozillaPlugins, | 210 kRegistryMozillaPlugins, |
192 KEY_NOTIFY) == ERROR_SUCCESS) { | 211 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) { | 790 void PluginServiceImpl::UnregisterInternalPlugin(const base::FilePath& path) { |
772 PluginList::Singleton()->UnregisterInternalPlugin(path); | 791 PluginList::Singleton()->UnregisterInternalPlugin(path); |
773 } | 792 } |
774 | 793 |
775 void PluginServiceImpl::GetInternalPlugins( | 794 void PluginServiceImpl::GetInternalPlugins( |
776 std::vector<WebPluginInfo>* plugins) { | 795 std::vector<WebPluginInfo>* plugins) { |
777 PluginList::Singleton()->GetInternalPlugins(plugins); | 796 PluginList::Singleton()->GetInternalPlugins(plugins); |
778 } | 797 } |
779 | 798 |
780 bool PluginServiceImpl::NPAPIPluginsSupported() { | 799 bool PluginServiceImpl::NPAPIPluginsSupported() { |
781 #if defined(OS_WIN) || defined(OS_MACOSX) | 800 return npapi_plugins_enabled_; |
782 return true; | |
783 #else | |
784 return false; | |
785 #endif | |
786 } | 801 } |
787 | 802 |
788 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() { | 803 void PluginServiceImpl::DisablePluginsDiscoveryForTesting() { |
789 PluginList::Singleton()->DisablePluginsDiscovery(); | 804 PluginList::Singleton()->DisablePluginsDiscovery(); |
790 } | 805 } |
791 | 806 |
| 807 void PluginServiceImpl::EnableNpapiPluginsForTesting() { |
| 808 npapi_plugins_enabled_ = true; |
| 809 } |
| 810 |
792 #if defined(OS_MACOSX) | 811 #if defined(OS_MACOSX) |
793 void PluginServiceImpl::AppActivated() { | 812 void PluginServiceImpl::AppActivated() { |
794 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 813 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
795 base::Bind(&NotifyPluginsOfActivation)); | 814 base::Bind(&NotifyPluginsOfActivation)); |
796 } | 815 } |
797 #elif defined(OS_WIN) | 816 #elif defined(OS_WIN) |
798 | 817 |
799 bool GetPluginPropertyFromWindow( | 818 bool GetPluginPropertyFromWindow( |
800 HWND window, const wchar_t* plugin_atom_property, | 819 HWND window, const wchar_t* plugin_atom_property, |
801 base::string16* plugin_property) { | 820 base::string16* plugin_property) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 #endif | 856 #endif |
838 | 857 |
839 bool PluginServiceImpl::PpapiDevChannelSupported( | 858 bool PluginServiceImpl::PpapiDevChannelSupported( |
840 BrowserContext* browser_context, | 859 BrowserContext* browser_context, |
841 const GURL& document_url) { | 860 const GURL& document_url) { |
842 return content::GetContentClient()->browser()-> | 861 return content::GetContentClient()->browser()-> |
843 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); | 862 IsPluginAllowedToUseDevChannelAPIs(browser_context, document_url); |
844 } | 863 } |
845 | 864 |
846 } // namespace content | 865 } // namespace content |
OLD | NEW |