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

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: Rebase ToT 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/browser/plugin_service.cc » ('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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 protected:
192 // Creates the PluginService object, but the actual plugin list is generated
193 // lazily. In tests, use MockPluginList for dependency injection.
194 PluginService(webkit::npapi::PluginList* plugin_list);
195 virtual ~PluginService();
196
192 private: 197 private:
193 friend struct DefaultSingletonTraits<PluginService>; 198 friend struct DefaultSingletonTraits<PluginService>;
194 199 friend struct PluginServiceSingletonTraits;
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
200 // base::WaitableEventWatcher::Delegate implementation. 201 // base::WaitableEventWatcher::Delegate implementation.
201 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); 202 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event);
202 203
203 // content::NotificationObserver implementation 204 // content::NotificationObserver implementation
204 virtual void Observe(int type, const content::NotificationSource& source, 205 virtual void Observe(int type, const content::NotificationSource& source,
205 const content::NotificationDetails& details); 206 const content::NotificationDetails& details);
206 207
207 void RegisterPepperPlugins(); 208 void RegisterPepperPlugins();
208 209
(...skipping 29 matching lines...) Expand all
238 PluginProcessHost::Client* client); 239 PluginProcessHost::Client* client);
239 240
240 #if defined(OS_POSIX) && !defined(OS_MACOSX) 241 #if defined(OS_POSIX) && !defined(OS_MACOSX)
241 // Registers a new FilePathWatcher for a given path. 242 // Registers a new FilePathWatcher for a given path.
242 static void RegisterFilePathWatcher( 243 static void RegisterFilePathWatcher(
243 base::files::FilePathWatcher* watcher, 244 base::files::FilePathWatcher* watcher,
244 const FilePath& path, 245 const FilePath& path,
245 base::files::FilePathWatcher::Delegate* delegate); 246 base::files::FilePathWatcher::Delegate* delegate);
246 #endif 247 #endif
247 248
249 // The plugin list instance.
250 webkit::npapi::PluginList* plugin_list_;
251
248 // The browser's UI locale. 252 // The browser's UI locale.
249 const std::string ui_locale_; 253 const std::string ui_locale_;
250 254
251 content::NotificationRegistrar registrar_; 255 content::NotificationRegistrar registrar_;
252 256
253 #if defined(OS_WIN) 257 #if defined(OS_WIN)
254 // Registry keys for getting notifications when new plugins are installed. 258 // Registry keys for getting notifications when new plugins are installed.
255 base::win::RegKey hkcu_key_; 259 base::win::RegKey hkcu_key_;
256 base::win::RegKey hklm_key_; 260 base::win::RegKey hklm_key_;
257 scoped_ptr<base::WaitableEvent> hkcu_event_; 261 scoped_ptr<base::WaitableEvent> hkcu_event_;
(...skipping 17 matching lines...) Expand all
275 #if defined(OS_POSIX) 279 #if defined(OS_POSIX)
276 scoped_refptr<PluginLoaderPosix> plugin_loader_; 280 scoped_refptr<PluginLoaderPosix> plugin_loader_;
277 #endif 281 #endif
278 282
279 DISALLOW_COPY_AND_ASSIGN(PluginService); 283 DISALLOW_COPY_AND_ASSIGN(PluginService);
280 }; 284 };
281 285
282 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); 286 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService);
283 287
284 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ 288 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/plugin_service.cc » ('j') | content/browser/plugin_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698