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 // This class responds to requests from renderers for the list of plugins, and | 5 // This class responds to requests from renderers for the list of plugins, and |
6 // also a proxy object for plugin instances. | 6 // also a proxy object for plugin instances. |
7 | 7 |
8 #ifndef CHROME_BROWSER_PLUGIN_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_PLUGIN_SERVICE_H_ |
9 #define CHROME_BROWSER_PLUGIN_SERVICE_H_ | 9 #define CHROME_BROWSER_PLUGIN_SERVICE_H_ |
10 | 10 |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
15 #include "base/lock.h" | 15 #include "base/lock.h" |
16 #include "base/ref_counted.h" | 16 #include "base/ref_counted.h" |
17 #include "base/singleton.h" | 17 #include "base/singleton.h" |
| 18 #include "base/waitable_event_watcher.h" |
18 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
19 #include "webkit/glue/webplugin.h" | 20 #include "webkit/glue/webplugin.h" |
20 | 21 |
| 22 #if defined(OS_WIN) |
| 23 #include "base/registry.h" |
| 24 #endif |
| 25 |
21 namespace IPC { | 26 namespace IPC { |
22 class Message; | 27 class Message; |
23 } | 28 } |
24 | 29 |
25 class MessageLoop; | 30 class MessageLoop; |
26 class PluginProcessHost; | 31 class PluginProcessHost; |
27 class URLRequestContext; | 32 class URLRequestContext; |
28 class ResourceDispatcherHost; | 33 class ResourceDispatcherHost; |
29 class ResourceMessageFilter; | 34 class ResourceMessageFilter; |
30 | 35 |
31 // This can be called on the main thread and IO thread. However it must | 36 // This can be called on the main thread and IO thread. However it must |
32 // be created on the main thread. | 37 // be created on the main thread. |
33 class PluginService { | 38 class PluginService : base::WaitableEventWatcher::Delegate { |
34 public: | 39 public: |
35 // Returns the PluginService singleton. | 40 // Returns the PluginService singleton. |
36 static PluginService* GetInstance(); | 41 static PluginService* GetInstance(); |
37 | 42 |
38 // Gets the list of available plugins. | 43 // Gets the list of available plugins. |
39 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); | 44 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); |
40 | 45 |
41 // Load all the plugins that should be loaded for the lifetime of the browser | 46 // Load all the plugins that should be loaded for the lifetime of the browser |
42 // (ie, with the LoadOnStartup flag set). | 47 // (ie, with the LoadOnStartup flag set). |
43 void LoadChromePlugins(ResourceDispatcherHost* resource_dispatcher_host); | 48 void LoadChromePlugins(ResourceDispatcherHost* resource_dispatcher_host); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 107 } |
103 | 108 |
104 private: | 109 private: |
105 friend struct DefaultSingletonTraits<PluginService>; | 110 friend struct DefaultSingletonTraits<PluginService>; |
106 | 111 |
107 // Creates the PluginService object, but doesn't actually build the plugin | 112 // Creates the PluginService object, but doesn't actually build the plugin |
108 // list yet. It's generated lazily. | 113 // list yet. It's generated lazily. |
109 PluginService(); | 114 PluginService(); |
110 ~PluginService(); | 115 ~PluginService(); |
111 | 116 |
| 117 // base::WaitableEventWatcher::Delegate implementation. |
| 118 void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
| 119 |
112 // mapping between plugin path and PluginProcessHost | 120 // mapping between plugin path and PluginProcessHost |
113 typedef base::hash_map<FilePath, PluginProcessHost*> PluginMap; | 121 typedef base::hash_map<FilePath, PluginProcessHost*> PluginMap; |
114 PluginMap plugin_hosts_; | 122 PluginMap plugin_hosts_; |
115 | 123 |
116 // The main thread's message loop. | 124 // The main thread's message loop. |
117 MessageLoop* main_message_loop_; | 125 MessageLoop* main_message_loop_; |
118 | 126 |
119 // The IO thread's resource dispatcher host. | 127 // The IO thread's resource dispatcher host. |
120 ResourceDispatcherHost* resource_dispatcher_host_; | 128 ResourceDispatcherHost* resource_dispatcher_host_; |
121 | 129 |
122 // The data directory that Chrome plugins should use to store persistent data. | 130 // The data directory that Chrome plugins should use to store persistent data. |
123 FilePath chrome_plugin_data_dir_; | 131 FilePath chrome_plugin_data_dir_; |
124 | 132 |
125 // The browser's UI locale. | 133 // The browser's UI locale. |
126 const std::wstring ui_locale_; | 134 const std::wstring ui_locale_; |
127 | 135 |
128 // Need synchronization whenever we access the plugin_list singelton through | 136 // Need synchronization whenever we access the plugin_list singelton through |
129 // webkit_glue since this class is called on the main and IO thread. | 137 // webkit_glue since this class is called on the main and IO thread. |
130 Lock lock_; | 138 Lock lock_; |
131 | 139 |
| 140 #if defined(OS_WIN) |
| 141 // Registry keys for getting notifications when new plugins are installed. |
| 142 RegKey hkcu_key_; |
| 143 RegKey hklm_key_; |
| 144 scoped_ptr<base::WaitableEvent> hkcu_event_; |
| 145 scoped_ptr<base::WaitableEvent> hklm_event_; |
| 146 base::WaitableEventWatcher hkcu_watcher_; |
| 147 base::WaitableEventWatcher hklm_watcher_; |
| 148 #endif |
| 149 |
132 DISALLOW_COPY_AND_ASSIGN(PluginService); | 150 DISALLOW_COPY_AND_ASSIGN(PluginService); |
133 }; | 151 }; |
134 | 152 |
135 #endif // CHROME_BROWSER_PLUGIN_SERVICE_H_ | 153 #endif // CHROME_BROWSER_PLUGIN_SERVICE_H_ |
OLD | NEW |