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

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: Revert to PS3 and rebase 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
jam 2011/09/22 21:10:59 nit: we should make this more forceful, i.e. "This
Robert Sesek 2011/09/22 23:26:51 Done. Happily.
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 };
59 72
73 typedef base::Callback<void(const std::vector<webkit::WebPluginInfo>&)>
74 GetPluginsCallback;
75 typedef base::Callback<void(const std::vector<webkit::npapi::PluginGroup>&)>
76 GetPluginGroupsCallback;
77
60 // Returns the PluginService singleton. 78 // Returns the PluginService singleton.
61 static PluginService* GetInstance(); 79 static PluginService* GetInstance();
62 80
63 // Starts watching for changes in the list of installed plug-ins. 81 // Starts watching for changes in the list of installed plug-ins.
64 void StartWatchingPlugins(); 82 void StartWatchingPlugins();
65 83
66 // Gets the browser's UI locale. 84 // Gets the browser's UI locale.
67 const std::string& GetUILocale(); 85 const std::string& GetUILocale();
68 86
69 // Returns the plugin process host corresponding to the plugin process that 87 // Returns the plugin process host corresponding to the plugin process that
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 int render_view_id, 126 int render_view_id,
109 const content::ResourceContext& context, 127 const content::ResourceContext& context,
110 const GURL& url, 128 const GURL& url,
111 const GURL& page_url, 129 const GURL& page_url,
112 const std::string& mime_type, 130 const std::string& mime_type,
113 bool allow_wildcard, 131 bool allow_wildcard,
114 bool* use_stale, 132 bool* use_stale,
115 webkit::WebPluginInfo* info, 133 webkit::WebPluginInfo* info,
116 std::string* actual_mime_type); 134 std::string* actual_mime_type);
117 135
118 // Returns a list of all plug-ins available to the resource context. Must be 136 // Marks the plugin list as dirty and will cause the plugins to be reloaded
119 // called on the FILE thread. 137 // on the next access through GetPlugins() or GetPluginGroups().
120 void GetPlugins(const content::ResourceContext& context, 138 void RefreshPluginList();
121 std::vector<webkit::WebPluginInfo>* plugins); 139
140 // Asynchronously loads plugins and then calls back to the provided function
jam 2011/09/22 21:10:59 nit: this doesn't always load the plugins, so how
Robert Sesek 2011/09/22 23:26:51 Done and below.
141 // on the calling MessageLoop on completion.
142 void GetPlugins(const GetPluginsCallback& callback);
143
144 // Gets the list of plugin groups, reloading them from disk if marked as dirty
jam 2011/09/22 21:10:59 nit, we should make this the same comment above. b
145 // with RefreshPluginList().
146 void GetPluginGroups(const GetPluginGroupsCallback& callback);
122 147
123 // Tells all the renderer processes to throw away their cache of the plugin 148 // Tells all the renderer processes to throw away their cache of the plugin
124 // list, and optionally also reload all the pages with plugins. 149 // list, and optionally also reload all the pages with plugins.
125 // NOTE: can only be called on the UI thread. 150 // NOTE: can only be called on the UI thread.
126 static void PurgePluginListCache(bool reload_pages); 151 static void PurgePluginListCache(bool reload_pages);
127 152
128 void set_filter(content::PluginServiceFilter* filter) { 153 void set_filter(content::PluginServiceFilter* filter) {
129 filter_ = filter; 154 filter_ = filter;
130 } 155 }
156 content::PluginServiceFilter* filter() { return filter_; }
131 157
132 private: 158 private:
133 friend struct DefaultSingletonTraits<PluginService>; 159 friend struct DefaultSingletonTraits<PluginService>;
134 160
135 // Creates the PluginService object, but doesn't actually build the plugin 161 // Creates the PluginService object, but doesn't actually build the plugin
136 // list yet. It's generated lazily. 162 // list yet. It's generated lazily.
137 PluginService(); 163 PluginService();
138 virtual ~PluginService(); 164 virtual ~PluginService();
139 165
140 // base::WaitableEventWatcher::Delegate implementation. 166 // base::WaitableEventWatcher::Delegate implementation.
141 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); 167 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event);
142 168
143 // NotificationObserver implementation 169 // NotificationObserver implementation
144 virtual void Observe(int type, const NotificationSource& source, 170 virtual void Observe(int type, const NotificationSource& source,
145 const NotificationDetails& details); 171 const NotificationDetails& details);
146 172
147 void RegisterPepperPlugins(); 173 void RegisterPepperPlugins();
148 174
149 PepperPluginInfo* GetRegisteredPpapiPluginInfo(const FilePath& plugin_path); 175 PepperPluginInfo* GetRegisteredPpapiPluginInfo(const FilePath& plugin_path);
150 176
177 // Function that is run on the FILE thread to load the plugins synchronously.
178 void GetPluginsInternal(base::MessageLoopProxy* target_loop,
179 const GetPluginsCallback& callback);
180
151 // Helper so we can do the plugin lookup on the FILE thread. 181 // Helper so we can do the plugin lookup on the FILE thread.
152 void GetAllowedPluginForOpenChannelToPlugin( 182 void GetAllowedPluginForOpenChannelToPlugin(
153 int render_process_id, 183 int render_process_id,
154 int render_view_id, 184 int render_view_id,
155 const GURL& url, 185 const GURL& url,
156 const GURL& page_url, 186 const GURL& page_url,
157 const std::string& mime_type, 187 const std::string& mime_type,
158 PluginProcessHost::Client* client, 188 PluginProcessHost::Client* client,
159 const content::ResourceContext* resource_context); 189 const content::ResourceContext* resource_context);
160 190
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 content::PluginServiceFilter* filter_; 228 content::PluginServiceFilter* filter_;
199 229
200 std::set<PluginProcessHost::Client*> pending_plugin_clients_; 230 std::set<PluginProcessHost::Client*> pending_plugin_clients_;
201 231
202 DISALLOW_COPY_AND_ASSIGN(PluginService); 232 DISALLOW_COPY_AND_ASSIGN(PluginService);
203 }; 233 };
204 234
205 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); 235 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService);
206 236
207 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ 237 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698