OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/plugin_service.h" | 7 #include "chrome/browser/plugin_service.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/thread.h" | 10 #include "base/thread.h" |
| 11 #include "base/waitable_event.h" |
11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/chrome_plugin_host.h" | 13 #include "chrome/browser/chrome_plugin_host.h" |
13 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
14 #include "chrome/browser/plugin_process_host.h" | 15 #include "chrome/browser/plugin_process_host.h" |
15 #include "chrome/browser/renderer_host/render_process_host.h" | 16 #include "chrome/browser/renderer_host/render_process_host.h" |
16 #include "chrome/browser/renderer_host/resource_message_filter.h" | |
17 #include "chrome/common/chrome_plugin_lib.h" | 17 #include "chrome/common/chrome_plugin_lib.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/logging_chrome.h" | 19 #include "chrome/common/logging_chrome.h" |
| 20 #include "chrome/common/render_messages.h" |
| 21 #include "webkit/glue/plugins/plugin_constants_win.h" |
20 #include "webkit/glue/plugins/plugin_list.h" | 22 #include "webkit/glue/plugins/plugin_list.h" |
21 | 23 |
22 // static | 24 // static |
23 PluginService* PluginService::GetInstance() { | 25 PluginService* PluginService::GetInstance() { |
24 return Singleton<PluginService>::get(); | 26 return Singleton<PluginService>::get(); |
25 } | 27 } |
26 | 28 |
27 PluginService::PluginService() | 29 PluginService::PluginService() |
28 : main_message_loop_(MessageLoop::current()), | 30 : main_message_loop_(MessageLoop::current()), |
29 resource_dispatcher_host_(NULL), | 31 resource_dispatcher_host_(NULL), |
30 ui_locale_(g_browser_process->GetApplicationLocale()) { | 32 ui_locale_(g_browser_process->GetApplicationLocale()) { |
31 // Have the NPAPI plugin list search for Chrome plugins as well. | 33 // Have the NPAPI plugin list search for Chrome plugins as well. |
32 ChromePluginLib::RegisterPluginsWithNPAPI(); | 34 ChromePluginLib::RegisterPluginsWithNPAPI(); |
33 // Load the one specified on the command line as well. | 35 // Load the one specified on the command line as well. |
34 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 36 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
35 std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin); | 37 std::wstring path = command_line->GetSwitchValue(switches::kLoadPlugin); |
36 if (!path.empty()) | 38 if (!path.empty()) |
37 NPAPI::PluginList::AddExtraPluginPath(FilePath::FromWStringHack(path)); | 39 NPAPI::PluginList::AddExtraPluginPath(FilePath::FromWStringHack(path)); |
| 40 |
| 41 #if defined(OS_WIN) |
| 42 hkcu_key_.Create( |
| 43 HKEY_CURRENT_USER, kRegistryMozillaPlugins, KEY_NOTIFY); |
| 44 hklm_key_.Create( |
| 45 HKEY_LOCAL_MACHINE, kRegistryMozillaPlugins, KEY_NOTIFY); |
| 46 if (hkcu_key_.StartWatching()) { |
| 47 hkcu_event_.reset(new base::WaitableEvent(hkcu_key_.watch_event())); |
| 48 hkcu_watcher_.StartWatching(hkcu_event_.get(), this); |
| 49 } |
| 50 |
| 51 if (hklm_key_.StartWatching()) { |
| 52 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); |
| 53 hklm_watcher_.StartWatching(hklm_event_.get(), this); |
| 54 } |
| 55 #endif |
38 } | 56 } |
39 | 57 |
40 PluginService::~PluginService() { | 58 PluginService::~PluginService() { |
| 59 #if defined(OS_WIN) |
| 60 // Release the events since they're owned by RegKey, not WaitableEvent. |
| 61 hkcu_watcher_.StopWatching(); |
| 62 hklm_watcher_.StopWatching(); |
| 63 hkcu_event_->Release(); |
| 64 hklm_event_->Release(); |
| 65 #endif |
41 } | 66 } |
42 | 67 |
43 void PluginService::GetPlugins(bool refresh, | 68 void PluginService::GetPlugins(bool refresh, |
44 std::vector<WebPluginInfo>* plugins) { | 69 std::vector<WebPluginInfo>* plugins) { |
45 AutoLock lock(lock_); | 70 AutoLock lock(lock_); |
46 NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); | 71 NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); |
47 } | 72 } |
48 | 73 |
49 void PluginService::LoadChromePlugins( | 74 void PluginService::LoadChromePlugins( |
50 ResourceDispatcherHost* resource_dispatcher_host) { | 75 ResourceDispatcherHost* resource_dispatcher_host) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 bool PluginService::HavePluginFor(const std::string& mime_type, | 189 bool PluginService::HavePluginFor(const std::string& mime_type, |
165 bool allow_wildcard) { | 190 bool allow_wildcard) { |
166 AutoLock lock(lock_); | 191 AutoLock lock(lock_); |
167 | 192 |
168 GURL url; | 193 GURL url; |
169 WebPluginInfo info; | 194 WebPluginInfo info; |
170 return NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, "", | 195 return NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, "", |
171 allow_wildcard, &info, | 196 allow_wildcard, &info, |
172 NULL); | 197 NULL); |
173 } | 198 } |
| 199 |
| 200 void PluginService::OnWaitableEventSignaled(base::WaitableEvent* waitable_event)
{ |
| 201 #if defined(OS_WIN) |
| 202 if (waitable_event == hkcu_event_.get()) { |
| 203 hkcu_key_.StartWatching(); |
| 204 } else { |
| 205 hklm_key_.StartWatching(); |
| 206 } |
| 207 |
| 208 AutoLock lock(lock_); |
| 209 NPAPI::PluginList::ResetPluginsLoaded(); |
| 210 |
| 211 for (RenderProcessHost::iterator it = RenderProcessHost::begin(); |
| 212 it != RenderProcessHost::end(); ++it) { |
| 213 it->second->Send(new ViewMsg_PurgePluginListCache()); |
| 214 } |
| 215 #endif |
| 216 } |
OLD | NEW |