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

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

Issue 9019004: Rename PluginService to PluginServiceImpl. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | « content/browser/plugin_process_host.cc ('k') | content/browser/plugin_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // This class responds to requests from renderers for the list of plugins, and
6 // also a proxy object for plugin instances.
7
8 #ifndef CONTENT_BROWSER_PLUGIN_SERVICE_H_
9 #define CONTENT_BROWSER_PLUGIN_SERVICE_H_
10 #pragma once
11
12 #include <set>
13
14 #include "base/basictypes.h"
15 #include "base/compiler_specific.h"
16 #include "base/memory/scoped_vector.h"
17 #include "base/memory/singleton.h"
18 #include "base/synchronization/waitable_event_watcher.h"
19 #include "build/build_config.h"
20 #include "content/browser/plugin_process_host.h"
21 #include "content/browser/ppapi_plugin_process_host.h"
22 #include "content/common/content_export.h"
23 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h"
25 #include "content/public/browser/plugin_service.h"
26 #include "googleurl/src/gurl.h"
27 #include "ipc/ipc_channel_handle.h"
28
29 #if defined(OS_WIN)
30 #include "base/memory/scoped_ptr.h"
31 #include "base/win/registry.h"
32 #endif
33
34 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
35 #include "base/files/file_path_watcher.h"
36 #endif
37
38 class PluginDirWatcherDelegate;
39 class PluginLoaderPosix;
40
41 namespace base {
42 class MessageLoopProxy;
43 }
44
45 namespace content {
46 class BrowserContext;
47 class ResourceContext;
48 struct PepperPluginInfo;
49 class PluginServiceFilter;
50 struct PluginServiceFilterParams;
51 }
52
53 namespace webkit {
54 namespace npapi {
55 class PluginGroup;
56 class PluginList;
57 }
58 }
59
60 class CONTENT_EXPORT PluginService
61 : NON_EXPORTED_BASE(public content::PluginService),
62 public base::WaitableEventWatcher::Delegate,
63 public content::NotificationObserver {
64 public:
65 // Returns the PluginService singleton.
66 static PluginService* GetInstance();
67
68 // content::PluginService implementation:
69 virtual void Init() OVERRIDE;
70 virtual void StartWatchingPlugins() OVERRIDE;
71 virtual PluginProcessHost* FindNpapiPluginProcess(
72 const FilePath& plugin_path) OVERRIDE;
73 virtual bool GetPluginInfoArray(
74 const GURL& url,
75 const std::string& mime_type,
76 bool allow_wildcard,
77 std::vector<webkit::WebPluginInfo>* info,
78 std::vector<std::string>* actual_mime_types) OVERRIDE;
79 virtual bool GetPluginInfo(int render_process_id,
80 int render_view_id,
81 const content::ResourceContext& context,
82 const GURL& url,
83 const GURL& page_url,
84 const std::string& mime_type,
85 bool allow_wildcard,
86 bool* is_stale,
87 webkit::WebPluginInfo* info,
88 std::string* actual_mime_type) OVERRIDE;
89 virtual bool GetPluginInfoByPath(const FilePath& plugin_path,
90 webkit::WebPluginInfo* info) OVERRIDE;
91 virtual void GetPlugins(const GetPluginsCallback& callback) OVERRIDE;
92 virtual void GetPluginGroups(
93 const GetPluginGroupsCallback& callback) OVERRIDE;
94 virtual content::PepperPluginInfo* GetRegisteredPpapiPluginInfo(
95 const FilePath& plugin_path) OVERRIDE;
96 virtual void SetFilter(content::PluginServiceFilter* filter) OVERRIDE;
97 virtual content::PluginServiceFilter* GetFilter() OVERRIDE;
98 virtual void RefreshPlugins() OVERRIDE;
99 virtual void AddExtraPluginPath(const FilePath& path) OVERRIDE;
100 virtual void RemoveExtraPluginPath(const FilePath& path) OVERRIDE;
101 virtual void UnregisterInternalPlugin(const FilePath& path) OVERRIDE;
102 virtual void RegisterInternalPlugin(
103 const webkit::WebPluginInfo& info) OVERRIDE;
104 virtual string16 GetPluginGroupName(const std::string& plugin_name) OVERRIDE;
105 virtual webkit::npapi::PluginList* GetPluginList() OVERRIDE;
106
107 // Gets the browser's UI locale.
108 const std::string& GetUILocale();
109
110 // Like FindNpapiPluginProcess but for Pepper.
111 PpapiPluginProcessHost* FindPpapiPluginProcess(const FilePath& plugin_path);
112 PpapiPluginProcessHost* FindPpapiBrokerProcess(const FilePath& broker_path);
113
114 // Returns the plugin process host corresponding to the plugin process that
115 // has been started by this service. This will start a process to host the
116 // 'plugin_path' if needed. If the process fails to start, the return value
117 // is NULL. Must be called on the IO thread.
118 PluginProcessHost* FindOrStartNpapiPluginProcess(
119 const FilePath& plugin_path);
120 PpapiPluginProcessHost* FindOrStartPpapiPluginProcess(
121 const FilePath& plugin_path,
122 PpapiPluginProcessHost::PluginClient* client);
123 PpapiPluginProcessHost* FindOrStartPpapiBrokerProcess(
124 const FilePath& plugin_path);
125
126 // Opens a channel to a plugin process for the given mime type, starting
127 // a new plugin process if necessary. This must be called on the IO thread
128 // or else a deadlock can occur.
129 void OpenChannelToNpapiPlugin(int render_process_id,
130 int render_view_id,
131 const GURL& url,
132 const GURL& page_url,
133 const std::string& mime_type,
134 PluginProcessHost::Client* client);
135 void OpenChannelToPpapiPlugin(const FilePath& path,
136 PpapiPluginProcessHost::PluginClient* client);
137 void OpenChannelToPpapiBroker(const FilePath& path,
138 PpapiPluginProcessHost::BrokerClient* client);
139
140 // Cancels opening a channel to a NPAPI plugin.
141 void CancelOpenChannelToNpapiPlugin(PluginProcessHost::Client* client);
142
143 void SetPluginListForTesting(webkit::npapi::PluginList* plugin_list);
144
145 private:
146 friend struct DefaultSingletonTraits<PluginService>;
147
148 // Creates the PluginService object, but doesn't actually build the plugin
149 // list yet. It's generated lazily.
150 PluginService();
151 virtual ~PluginService();
152
153 // base::WaitableEventWatcher::Delegate implementation.
154 virtual void OnWaitableEventSignaled(
155 base::WaitableEvent* waitable_event) OVERRIDE;
156
157 // content::NotificationObserver implementation
158 virtual void Observe(int type,
159 const content::NotificationSource& source,
160 const content::NotificationDetails& details) OVERRIDE;
161
162 void RegisterPepperPlugins();
163
164 // Function that is run on the FILE thread to load the plugins synchronously.
165 void GetPluginsInternal(base::MessageLoopProxy* target_loop,
166 const GetPluginsCallback& callback);
167
168 // Binding directly to GetAllowedPluginForOpenChannelToPlugin() isn't possible
169 // because more arity is needed <http://crbug.com/98542>. This just forwards.
170 void ForwardGetAllowedPluginForOpenChannelToPlugin(
171 const content::PluginServiceFilterParams& params,
172 const GURL& url,
173 const std::string& mime_type,
174 PluginProcessHost::Client* client,
175 const std::vector<webkit::WebPluginInfo>&);
176 // Helper so we can do the plugin lookup on the FILE thread.
177 void GetAllowedPluginForOpenChannelToPlugin(
178 int render_process_id,
179 int render_view_id,
180 const GURL& url,
181 const GURL& page_url,
182 const std::string& mime_type,
183 PluginProcessHost::Client* client,
184 const content::ResourceContext* resource_context);
185
186 // Helper so we can finish opening the channel after looking up the
187 // plugin.
188 void FinishOpenChannelToPlugin(
189 const FilePath& plugin_path,
190 PluginProcessHost::Client* client);
191
192 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
193 // Registers a new FilePathWatcher for a given path.
194 static void RegisterFilePathWatcher(
195 base::files::FilePathWatcher* watcher,
196 const FilePath& path,
197 base::files::FilePathWatcher::Delegate* delegate);
198 #endif
199
200 // The plugin list instance.
201 webkit::npapi::PluginList* plugin_list_;
202
203 // The browser's UI locale.
204 const std::string ui_locale_;
205
206 content::NotificationRegistrar registrar_;
207
208 #if defined(OS_WIN)
209 // Registry keys for getting notifications when new plugins are installed.
210 base::win::RegKey hkcu_key_;
211 base::win::RegKey hklm_key_;
212 scoped_ptr<base::WaitableEvent> hkcu_event_;
213 scoped_ptr<base::WaitableEvent> hklm_event_;
214 base::WaitableEventWatcher hkcu_watcher_;
215 base::WaitableEventWatcher hklm_watcher_;
216 #endif
217
218 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
219 ScopedVector<base::files::FilePathWatcher> file_watchers_;
220 scoped_refptr<PluginDirWatcherDelegate> file_watcher_delegate_;
221 #endif
222
223 std::vector<content::PepperPluginInfo> ppapi_plugins_;
224
225 // Weak pointer; outlives us.
226 content::PluginServiceFilter* filter_;
227
228 std::set<PluginProcessHost::Client*> pending_plugin_clients_;
229
230 #if defined(OS_POSIX)
231 scoped_refptr<PluginLoaderPosix> plugin_loader_;
232 #endif
233
234 DISALLOW_COPY_AND_ASSIGN(PluginService);
235 };
236
237 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService);
238
239 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_
OLDNEW
« no previous file with comments | « content/browser/plugin_process_host.cc ('k') | content/browser/plugin_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698