Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: content/browser/plugin_service.h

Issue 8493019: Refactor PluginService to take PluginList as a dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/plugin_service.cc » ('j') | content/test/mock_plugin_service.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // will use cached data in the plugin list. 150 // will use cached data in the plugin list.
151 bool GetPluginInfoByPath(const FilePath& plugin_path, 151 bool GetPluginInfoByPath(const FilePath& plugin_path,
152 webkit::WebPluginInfo* info); 152 webkit::WebPluginInfo* info);
153 153
154 // Marks the plugin list as dirty and will cause the plugins to be reloaded 154 // Marks the plugin list as dirty and will cause the plugins to be reloaded
155 // on the next access through GetPlugins() or GetPluginGroups(). 155 // on the next access through GetPlugins() or GetPluginGroups().
156 void RefreshPluginList(); 156 void RefreshPluginList();
157 157
158 // Asynchronously loads plugins if necessary and then calls back to the 158 // Asynchronously loads plugins if necessary and then calls back to the
159 // provided function on the calling MessageLoop on completion. 159 // provided function on the calling MessageLoop on completion.
160 void GetPlugins(const GetPluginsCallback& callback); 160 virtual void GetPlugins(const GetPluginsCallback& callback);
161 161
162 // Asynchronously loads the list of plugin groups if necessary and then calls 162 // Asynchronously loads the list of plugin groups if necessary and then calls
163 // back to the provided function on the calling MessageLoop on completion. 163 // back to the provided function on the calling MessageLoop on completion.
164 void GetPluginGroups(const GetPluginGroupsCallback& callback); 164 virtual void GetPluginGroups(const GetPluginGroupsCallback& callback);
165 165
166 // Tells all the renderer processes associated with the given browser context 166 // Tells all the renderer processes associated with the given browser context
167 // to throw away their cache of the plugin list, and optionally also reload 167 // to throw away their cache of the plugin list, and optionally also reload
168 // all the pages with plugins. If |browser_context| is NULL, purges the cache 168 // all the pages with plugins. If |browser_context| is NULL, purges the cache
169 // in all renderers. 169 // in all renderers.
170 // NOTE: can only be called on the UI thread. 170 // NOTE: can only be called on the UI thread.
171 static void PurgePluginListCache(content::BrowserContext* browser_context, 171 static void PurgePluginListCache(content::BrowserContext* browser_context,
172 bool reload_pages); 172 bool reload_pages);
173 173
174 void set_filter(content::PluginServiceFilter* filter) { 174 void set_filter(content::PluginServiceFilter* filter) {
175 filter_ = filter; 175 filter_ = filter;
176 } 176 }
177 content::PluginServiceFilter* filter() { return filter_; } 177 content::PluginServiceFilter* filter() { return filter_; }
178 178
179 webkit::npapi::PluginList* plugin_list() const { return plugin_list_; }
180
181 protected:
182 // Creates the PluginService object, but the actual plugin list is generated
183 // lazily. If |plugin_list| is NULL, the singleton will be used. In tests,
184 // use MockPluginList for dependency injection.
185 PluginService(webkit::npapi::PluginList* plugin_list = NULL);
Bernhard Bauer 2011/11/07 22:37:50 Could you have a protected mutator to set the plug
Robert Sesek 2011/11/07 23:05:49 No, but I can create a custom singleton traits.
186 virtual ~PluginService();
187
179 private: 188 private:
180 friend struct DefaultSingletonTraits<PluginService>; 189 friend struct DefaultSingletonTraits<PluginService>;
181 190
182 // Creates the PluginService object, but doesn't actually build the plugin
183 // list yet. It's generated lazily.
184 PluginService();
185 virtual ~PluginService();
186
187 // base::WaitableEventWatcher::Delegate implementation. 191 // base::WaitableEventWatcher::Delegate implementation.
188 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); 192 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event);
189 193
190 // content::NotificationObserver implementation 194 // content::NotificationObserver implementation
191 virtual void Observe(int type, const content::NotificationSource& source, 195 virtual void Observe(int type, const content::NotificationSource& source,
192 const content::NotificationDetails& details); 196 const content::NotificationDetails& details);
193 197
194 void RegisterPepperPlugins(); 198 void RegisterPepperPlugins();
195 199
196 content::PepperPluginInfo* GetRegisteredPpapiPluginInfo( 200 content::PepperPluginInfo* GetRegisteredPpapiPluginInfo(
(...skipping 28 matching lines...) Expand all
225 PluginProcessHost::Client* client); 229 PluginProcessHost::Client* client);
226 230
227 #if defined(OS_POSIX) && !defined(OS_MACOSX) 231 #if defined(OS_POSIX) && !defined(OS_MACOSX)
228 // Registers a new FilePathWatcher for a given path. 232 // Registers a new FilePathWatcher for a given path.
229 static void RegisterFilePathWatcher( 233 static void RegisterFilePathWatcher(
230 base::files::FilePathWatcher* watcher, 234 base::files::FilePathWatcher* watcher,
231 const FilePath& path, 235 const FilePath& path,
232 base::files::FilePathWatcher::Delegate* delegate); 236 base::files::FilePathWatcher::Delegate* delegate);
233 #endif 237 #endif
234 238
239 // The plugin list instance.
240 webkit::npapi::PluginList* plugin_list_;
241
235 // The browser's UI locale. 242 // The browser's UI locale.
236 const std::string ui_locale_; 243 const std::string ui_locale_;
237 244
238 content::NotificationRegistrar registrar_; 245 content::NotificationRegistrar registrar_;
239 246
240 #if defined(OS_WIN) 247 #if defined(OS_WIN)
241 // Registry keys for getting notifications when new plugins are installed. 248 // Registry keys for getting notifications when new plugins are installed.
242 base::win::RegKey hkcu_key_; 249 base::win::RegKey hkcu_key_;
243 base::win::RegKey hklm_key_; 250 base::win::RegKey hklm_key_;
244 scoped_ptr<base::WaitableEvent> hkcu_event_; 251 scoped_ptr<base::WaitableEvent> hkcu_event_;
(...skipping 17 matching lines...) Expand all
262 #if defined(OS_POSIX) 269 #if defined(OS_POSIX)
263 scoped_refptr<PluginLoaderPosix> plugin_loader_; 270 scoped_refptr<PluginLoaderPosix> plugin_loader_;
264 #endif 271 #endif
265 272
266 DISALLOW_COPY_AND_ASSIGN(PluginService); 273 DISALLOW_COPY_AND_ASSIGN(PluginService);
267 }; 274 };
268 275
269 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); 276 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService);
270 277
271 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ 278 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/plugin_service.cc » ('j') | content/test/mock_plugin_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698