OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 8 #ifndef CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
9 #define CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 9 #define CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 std::string* actual_mime_type); | 147 std::string* actual_mime_type); |
148 | 148 |
149 // Get plugin info by plugin path (including disabled plugins). Returns true | 149 // Get plugin info by plugin path (including disabled plugins). Returns true |
150 // if the plugin is found and WebPluginInfo has been filled in |info|. This | 150 // if the plugin is found and WebPluginInfo has been filled in |info|. This |
151 // will use cached data in the plugin list. | 151 // will use cached data in the plugin list. |
152 bool GetPluginInfoByPath(const FilePath& plugin_path, | 152 bool GetPluginInfoByPath(const FilePath& plugin_path, |
153 webkit::WebPluginInfo* info); | 153 webkit::WebPluginInfo* info); |
154 | 154 |
155 // Asynchronously loads plugins if necessary and then calls back to the | 155 // Asynchronously loads plugins if necessary and then calls back to the |
156 // provided function on the calling MessageLoop on completion. | 156 // provided function on the calling MessageLoop on completion. |
157 void GetPlugins(const GetPluginsCallback& callback); | 157 virtual void GetPlugins(const GetPluginsCallback& callback); |
158 | 158 |
159 // Asynchronously loads the list of plugin groups if necessary and then calls | 159 // Asynchronously loads the list of plugin groups if necessary and then calls |
160 // back to the provided function on the calling MessageLoop on completion. | 160 // back to the provided function on the calling MessageLoop on completion. |
161 void GetPluginGroups(const GetPluginGroupsCallback& callback); | 161 virtual void GetPluginGroups(const GetPluginGroupsCallback& callback); |
162 | 162 |
163 // Tells all the renderer processes associated with the given browser context | 163 // Tells all the renderer processes associated with the given browser context |
164 // to throw away their cache of the plugin list, and optionally also reload | 164 // to throw away their cache of the plugin list, and optionally also reload |
165 // all the pages with plugins. If |browser_context| is NULL, purges the cache | 165 // all the pages with plugins. If |browser_context| is NULL, purges the cache |
166 // in all renderers. | 166 // in all renderers. |
167 // NOTE: can only be called on the UI thread. | 167 // NOTE: can only be called on the UI thread. |
168 static void PurgePluginListCache(content::BrowserContext* browser_context, | 168 static void PurgePluginListCache(content::BrowserContext* browser_context, |
169 bool reload_pages); | 169 bool reload_pages); |
170 | 170 |
171 void set_filter(content::PluginServiceFilter* filter) { | 171 void set_filter(content::PluginServiceFilter* filter) { |
172 filter_ = filter; | 172 filter_ = filter; |
173 } | 173 } |
174 content::PluginServiceFilter* filter() { return filter_; } | 174 content::PluginServiceFilter* filter() { return filter_; } |
175 | 175 |
176 | |
177 // The following functions are wrappers around webkit::npapi::PluginList. | 176 // The following functions are wrappers around webkit::npapi::PluginList. |
178 // These must be used instead of those in order to ensure that we have a | 177 // These must be used instead of those in order to ensure that we have a |
179 // single global list in the component build and so that we don't | 178 // single global list in the component build and so that we don't |
180 // accidentally load plugins in the wrong process or thread. Refer to | 179 // accidentally load plugins in the wrong process or thread. Refer to |
181 // PluginList for further documentation of these functions. | 180 // PluginList for further documentation of these functions. |
182 void RefreshPlugins(); | 181 void RefreshPlugins(); |
183 void AddExtraPluginPath(const FilePath& path); | 182 void AddExtraPluginPath(const FilePath& path); |
184 void RemoveExtraPluginPath(const FilePath& path); | 183 void RemoveExtraPluginPath(const FilePath& path); |
185 void UnregisterInternalPlugin(const FilePath& path); | 184 void UnregisterInternalPlugin(const FilePath& path); |
186 void RegisterInternalPlugin(const webkit::WebPluginInfo& info); | 185 void RegisterInternalPlugin(const webkit::WebPluginInfo& info); |
187 string16 GetPluginGroupName(const std::string& plugin_name); | 186 string16 GetPluginGroupName(const std::string& plugin_name); |
188 | 187 |
189 // TODO(dpranke): This should be private. | 188 // TODO(dpranke): This should be private. |
190 webkit::npapi::PluginList* plugin_list(); | 189 webkit::npapi::PluginList* plugin_list(); |
191 | 190 |
| 191 void SetPluginListForTesting(webkit::npapi::PluginList* plugin_list); |
| 192 |
| 193 protected: |
| 194 // Creates the PluginService object, but the actual plugin list is generated |
| 195 // lazily. In tests, use MockPluginList for dependency injection. |
| 196 PluginService(); |
| 197 virtual ~PluginService(); |
| 198 |
| 199 void Init(); |
| 200 |
192 private: | 201 private: |
193 friend struct DefaultSingletonTraits<PluginService>; | 202 friend struct DefaultSingletonTraits<PluginService>; |
194 | 203 |
195 // Creates the PluginService object, but doesn't actually build the plugin | |
196 // list yet. It's generated lazily. | |
197 PluginService(); | |
198 virtual ~PluginService(); | |
199 | |
200 // base::WaitableEventWatcher::Delegate implementation. | 204 // base::WaitableEventWatcher::Delegate implementation. |
201 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); | 205 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
202 | 206 |
203 // content::NotificationObserver implementation | 207 // content::NotificationObserver implementation |
204 virtual void Observe(int type, const content::NotificationSource& source, | 208 virtual void Observe(int type, const content::NotificationSource& source, |
205 const content::NotificationDetails& details); | 209 const content::NotificationDetails& details); |
206 | 210 |
207 void RegisterPepperPlugins(); | 211 void RegisterPepperPlugins(); |
208 | 212 |
209 content::PepperPluginInfo* GetRegisteredPpapiPluginInfo( | 213 content::PepperPluginInfo* GetRegisteredPpapiPluginInfo( |
(...skipping 28 matching lines...) Expand all Loading... |
238 PluginProcessHost::Client* client); | 242 PluginProcessHost::Client* client); |
239 | 243 |
240 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 244 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
241 // Registers a new FilePathWatcher for a given path. | 245 // Registers a new FilePathWatcher for a given path. |
242 static void RegisterFilePathWatcher( | 246 static void RegisterFilePathWatcher( |
243 base::files::FilePathWatcher* watcher, | 247 base::files::FilePathWatcher* watcher, |
244 const FilePath& path, | 248 const FilePath& path, |
245 base::files::FilePathWatcher::Delegate* delegate); | 249 base::files::FilePathWatcher::Delegate* delegate); |
246 #endif | 250 #endif |
247 | 251 |
| 252 // Whether or not the Init() method was called. |
| 253 bool did_init_; |
| 254 |
| 255 // The plugin list instance. |
| 256 webkit::npapi::PluginList* plugin_list_; |
| 257 |
248 // The browser's UI locale. | 258 // The browser's UI locale. |
249 const std::string ui_locale_; | 259 const std::string ui_locale_; |
250 | 260 |
251 content::NotificationRegistrar registrar_; | 261 content::NotificationRegistrar registrar_; |
252 | 262 |
253 #if defined(OS_WIN) | 263 #if defined(OS_WIN) |
254 // Registry keys for getting notifications when new plugins are installed. | 264 // Registry keys for getting notifications when new plugins are installed. |
255 base::win::RegKey hkcu_key_; | 265 base::win::RegKey hkcu_key_; |
256 base::win::RegKey hklm_key_; | 266 base::win::RegKey hklm_key_; |
257 scoped_ptr<base::WaitableEvent> hkcu_event_; | 267 scoped_ptr<base::WaitableEvent> hkcu_event_; |
(...skipping 17 matching lines...) Expand all Loading... |
275 #if defined(OS_POSIX) | 285 #if defined(OS_POSIX) |
276 scoped_refptr<PluginLoaderPosix> plugin_loader_; | 286 scoped_refptr<PluginLoaderPosix> plugin_loader_; |
277 #endif | 287 #endif |
278 | 288 |
279 DISALLOW_COPY_AND_ASSIGN(PluginService); | 289 DISALLOW_COPY_AND_ASSIGN(PluginService); |
280 }; | 290 }; |
281 | 291 |
282 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); | 292 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); |
283 | 293 |
284 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 294 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
OLD | NEW |