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

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

Issue 7980011: Convert the PluginService interface to be an async wrapper around PluginList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New interface as discussed Created 9 years, 3 months 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
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
11 11
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/callback.h"
16 #include "base/memory/scoped_vector.h" 17 #include "base/memory/scoped_vector.h"
17 #include "base/memory/singleton.h" 18 #include "base/memory/singleton.h"
18 #include "base/synchronization/waitable_event_watcher.h" 19 #include "base/synchronization/waitable_event_watcher.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "content/browser/plugin_process_host.h" 21 #include "content/browser/plugin_process_host.h"
21 #include "content/browser/ppapi_plugin_process_host.h" 22 #include "content/browser/ppapi_plugin_process_host.h"
22 #include "content/browser/ppapi_broker_process_host.h" 23 #include "content/browser/ppapi_broker_process_host.h"
23 #include "content/common/content_export.h" 24 #include "content/common/content_export.h"
24 #include "content/common/notification_observer.h" 25 #include "content/common/notification_observer.h"
25 #include "content/common/notification_registrar.h" 26 #include "content/common/notification_registrar.h"
26 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
27 #include "ipc/ipc_channel_handle.h" 28 #include "ipc/ipc_channel_handle.h"
28 #include "webkit/plugins/webplugininfo.h"
29 29
30 #if defined(OS_WIN) 30 #if defined(OS_WIN)
31 #include "base/memory/scoped_ptr.h" 31 #include "base/memory/scoped_ptr.h"
32 #include "base/win/registry.h" 32 #include "base/win/registry.h"
33 #endif 33 #endif
34 34
35 #if defined(OS_POSIX) && !defined(OS_MACOSX) 35 #if defined(OS_POSIX) && !defined(OS_MACOSX)
36 #include "base/files/file_path_watcher.h" 36 #include "base/files/file_path_watcher.h"
37 #endif 37 #endif
38 38
39 struct PepperPluginInfo; 39 struct PepperPluginInfo;
40 class PluginDirWatcherDelegate; 40 class PluginDirWatcherDelegate;
41 41
42 namespace base {
43 class MessageLoopProxy;
44 }
45
42 namespace content { 46 namespace content {
43 class ResourceContext; 47 class ResourceContext;
44 class PluginServiceFilter; 48 class PluginServiceFilter;
45 } 49 }
46 50
51 namespace webkit {
52 namespace npapi {
53 class PluginGroup;
54 class PluginList;
55 }
56 }
57
47 // This must be created on the main thread but it's only called on the IO/file 58 // This must be created on the main thread but it's only called on the IO/file
48 // thread. 59 // thread. This is an asynchronous wrapper around the PluginList interface for
60 // querying plugin information, and this should instead of that class wherever
61 // possible.
49 class CONTENT_EXPORT PluginService 62 class CONTENT_EXPORT PluginService
50 : public base::WaitableEventWatcher::Delegate, 63 : public base::WaitableEventWatcher::Delegate,
51 public NotificationObserver { 64 public NotificationObserver {
52 public: 65 public:
53 struct OverriddenPlugin { 66 struct OverriddenPlugin {
54 int render_process_id; 67 int render_process_id;
55 int render_view_id; 68 int render_view_id;
56 GURL url; // If empty, the override applies to all urls in render_view. 69 GURL url; // If empty, the override applies to all urls in render_view.
57 webkit::WebPluginInfo plugin; 70 webkit::WebPluginInfo plugin;
58 }; 71 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 int render_view_id, 121 int render_view_id,
109 const content::ResourceContext& context, 122 const content::ResourceContext& context,
110 const GURL& url, 123 const GURL& url,
111 const GURL& page_url, 124 const GURL& page_url,
112 const std::string& mime_type, 125 const std::string& mime_type,
113 bool allow_wildcard, 126 bool allow_wildcard,
114 bool* use_stale, 127 bool* use_stale,
115 webkit::WebPluginInfo* info, 128 webkit::WebPluginInfo* info,
116 std::string* actual_mime_type); 129 std::string* actual_mime_type);
117 130
118 // Returns a list of all plug-ins available to the resource context. Must be 131 // Causes the plugin list to be reloaded if necessary. If |refresh| is true,
119 // called on the FILE thread. 132 // a reload will be forced.
120 void GetPlugins(const content::ResourceContext& context, 133 void LoadPluginList(bool refresh, const base::Closure& completion_callback);
jam 2011/09/21 23:45:13 i think having only one GetPlugins function is bet
jam 2011/09/21 23:45:55 please ignore this comment, i put before i wrote t
121 std::vector<webkit::WebPluginInfo>* plugins); 134
135 // Returns the list of cached plugin information. This can be called from any
136 // thread, but the data can be stale.
Bernhard Bauer 2011/09/21 22:47:05 Nit: I think the more common case will be that the
137 void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins);
138
139 // Returns the list of cached plugin groups. This can be called from any
140 // thread, but note that the data can be stale.
141 void GetPluginGroups(std::vector<webkit::npapi::PluginGroup>* groups);
122 142
123 // Tells all the renderer processes to throw away their cache of the plugin 143 // Tells all the renderer processes to throw away their cache of the plugin
124 // list, and optionally also reload all the pages with plugins. 144 // list, and optionally also reload all the pages with plugins.
125 // NOTE: can only be called on the UI thread. 145 // NOTE: can only be called on the UI thread.
126 static void PurgePluginListCache(bool reload_pages); 146 static void PurgePluginListCache(bool reload_pages);
127 147
128 void set_filter(content::PluginServiceFilter* filter) { 148 void set_filter(content::PluginServiceFilter* filter) {
129 filter_ = filter; 149 filter_ = filter;
130 } 150 }
151 content::PluginServiceFilter* filter() { return filter_; }
131 152
132 private: 153 private:
133 friend struct DefaultSingletonTraits<PluginService>; 154 friend struct DefaultSingletonTraits<PluginService>;
134 155
135 // Creates the PluginService object, but doesn't actually build the plugin 156 // Creates the PluginService object, but doesn't actually build the plugin
136 // list yet. It's generated lazily. 157 // list yet. It's generated lazily.
137 PluginService(); 158 PluginService();
138 virtual ~PluginService(); 159 virtual ~PluginService();
139 160
140 // base::WaitableEventWatcher::Delegate implementation. 161 // base::WaitableEventWatcher::Delegate implementation.
141 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); 162 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event);
142 163
143 // NotificationObserver implementation 164 // NotificationObserver implementation
144 virtual void Observe(int type, const NotificationSource& source, 165 virtual void Observe(int type, const NotificationSource& source,
145 const NotificationDetails& details); 166 const NotificationDetails& details);
146 167
147 void RegisterPepperPlugins(); 168 void RegisterPepperPlugins();
148 169
149 PepperPluginInfo* GetRegisteredPpapiPluginInfo(const FilePath& plugin_path); 170 PepperPluginInfo* GetRegisteredPpapiPluginInfo(const FilePath& plugin_path);
150 171
172 // Function that is run on the FILE thread to load the plugins synchronously.
173 void GetPluginsInternal(base::MessageLoopProxy* target_loop,
174 const base::Closure& completion_callback);
175
151 // Helper so we can do the plugin lookup on the FILE thread. 176 // Helper so we can do the plugin lookup on the FILE thread.
152 void GetAllowedPluginForOpenChannelToPlugin( 177 void GetAllowedPluginForOpenChannelToPlugin(
153 int render_process_id, 178 int render_process_id,
154 int render_view_id, 179 int render_view_id,
155 const GURL& url, 180 const GURL& url,
156 const GURL& page_url, 181 const GURL& page_url,
157 const std::string& mime_type, 182 const std::string& mime_type,
158 PluginProcessHost::Client* client, 183 PluginProcessHost::Client* client,
159 const content::ResourceContext* resource_context); 184 const content::ResourceContext* resource_context);
160 185
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 content::PluginServiceFilter* filter_; 223 content::PluginServiceFilter* filter_;
199 224
200 std::set<PluginProcessHost::Client*> pending_plugin_clients_; 225 std::set<PluginProcessHost::Client*> pending_plugin_clients_;
201 226
202 DISALLOW_COPY_AND_ASSIGN(PluginService); 227 DISALLOW_COPY_AND_ASSIGN(PluginService);
203 }; 228 };
204 229
205 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); 230 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService);
206 231
207 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ 232 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698