OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_IMPL_H_ | 8 #ifndef CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_ |
9 #define CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_ | 9 #define CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_ |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
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_OPENBSD) | 35 #if defined(OS_POSIX) && !defined(OS_OPENBSD) |
36 #include "base/files/file_path_watcher.h" | 36 #include "base/files/file_path_watcher.h" |
37 #endif | 37 #endif |
38 | 38 |
39 class PluginDirWatcherDelegate; | |
40 class PluginLoaderPosix; | |
41 | |
42 namespace base { | 39 namespace base { |
43 class MessageLoopProxy; | 40 class MessageLoopProxy; |
44 } | 41 } |
45 | 42 |
46 namespace content { | |
47 class BrowserContext; | |
48 class PluginServiceFilter; | |
49 class ResourceContext; | |
50 struct PepperPluginInfo; | |
51 } | |
52 | |
53 namespace webkit { | 43 namespace webkit { |
54 namespace npapi { | 44 namespace npapi { |
55 class PluginList; | 45 class PluginList; |
56 } | 46 } |
57 } | 47 } |
58 | 48 |
| 49 namespace content { |
| 50 class BrowserContext; |
| 51 class PluginDirWatcherDelegate; |
| 52 class PluginLoaderPosix; |
| 53 class PluginServiceFilter; |
| 54 class ResourceContext; |
| 55 struct PepperPluginInfo; |
| 56 |
59 // base::Bind() has limited arity, and the filter-related methods tend to | 57 // base::Bind() has limited arity, and the filter-related methods tend to |
60 // surpass that limit. | 58 // surpass that limit. |
61 struct PluginServiceFilterParams { | 59 struct PluginServiceFilterParams { |
62 int render_process_id; | 60 int render_process_id; |
63 int render_view_id; | 61 int render_view_id; |
64 GURL page_url; | 62 GURL page_url; |
65 content::ResourceContext* resource_context; | 63 ResourceContext* resource_context; |
66 }; | 64 }; |
67 | 65 |
68 class CONTENT_EXPORT PluginServiceImpl | 66 class CONTENT_EXPORT PluginServiceImpl |
69 : NON_EXPORTED_BASE(public content::PluginService), | 67 : NON_EXPORTED_BASE(public PluginService), |
70 public base::WaitableEventWatcher::Delegate { | 68 public base::WaitableEventWatcher::Delegate { |
71 public: | 69 public: |
72 // Returns the PluginServiceImpl singleton. | 70 // Returns the PluginServiceImpl singleton. |
73 static PluginServiceImpl* GetInstance(); | 71 static PluginServiceImpl* GetInstance(); |
74 | 72 |
75 // content::PluginService implementation: | 73 // PluginService implementation: |
76 virtual void Init() OVERRIDE; | 74 virtual void Init() OVERRIDE; |
77 virtual void StartWatchingPlugins() OVERRIDE; | 75 virtual void StartWatchingPlugins() OVERRIDE; |
78 virtual bool GetPluginInfoArray( | 76 virtual bool GetPluginInfoArray( |
79 const GURL& url, | 77 const GURL& url, |
80 const std::string& mime_type, | 78 const std::string& mime_type, |
81 bool allow_wildcard, | 79 bool allow_wildcard, |
82 std::vector<webkit::WebPluginInfo>* info, | 80 std::vector<webkit::WebPluginInfo>* info, |
83 std::vector<std::string>* actual_mime_types) OVERRIDE; | 81 std::vector<std::string>* actual_mime_types) OVERRIDE; |
84 virtual bool GetPluginInfo(int render_process_id, | 82 virtual bool GetPluginInfo(int render_process_id, |
85 int render_view_id, | 83 int render_view_id, |
86 content::ResourceContext* context, | 84 ResourceContext* context, |
87 const GURL& url, | 85 const GURL& url, |
88 const GURL& page_url, | 86 const GURL& page_url, |
89 const std::string& mime_type, | 87 const std::string& mime_type, |
90 bool allow_wildcard, | 88 bool allow_wildcard, |
91 bool* is_stale, | 89 bool* is_stale, |
92 webkit::WebPluginInfo* info, | 90 webkit::WebPluginInfo* info, |
93 std::string* actual_mime_type) OVERRIDE; | 91 std::string* actual_mime_type) OVERRIDE; |
94 virtual bool GetPluginInfoByPath(const FilePath& plugin_path, | 92 virtual bool GetPluginInfoByPath(const FilePath& plugin_path, |
95 webkit::WebPluginInfo* info) OVERRIDE; | 93 webkit::WebPluginInfo* info) OVERRIDE; |
96 virtual string16 GetPluginDisplayNameByPath(const FilePath& path) OVERRIDE; | 94 virtual string16 GetPluginDisplayNameByPath(const FilePath& path) OVERRIDE; |
97 virtual void GetPlugins(const GetPluginsCallback& callback) OVERRIDE; | 95 virtual void GetPlugins(const GetPluginsCallback& callback) OVERRIDE; |
98 virtual content::PepperPluginInfo* GetRegisteredPpapiPluginInfo( | 96 virtual PepperPluginInfo* GetRegisteredPpapiPluginInfo( |
99 const FilePath& plugin_path) OVERRIDE; | 97 const FilePath& plugin_path) OVERRIDE; |
100 virtual void SetFilter(content::PluginServiceFilter* filter) OVERRIDE; | 98 virtual void SetFilter(PluginServiceFilter* filter) OVERRIDE; |
101 virtual content::PluginServiceFilter* GetFilter() OVERRIDE; | 99 virtual PluginServiceFilter* GetFilter() OVERRIDE; |
102 virtual void ForcePluginShutdown(const FilePath& plugin_path) OVERRIDE; | 100 virtual void ForcePluginShutdown(const FilePath& plugin_path) OVERRIDE; |
103 virtual bool IsPluginUnstable(const FilePath& plugin_path) OVERRIDE; | 101 virtual bool IsPluginUnstable(const FilePath& plugin_path) OVERRIDE; |
104 virtual void RefreshPlugins() OVERRIDE; | 102 virtual void RefreshPlugins() OVERRIDE; |
105 virtual void AddExtraPluginPath(const FilePath& path) OVERRIDE; | 103 virtual void AddExtraPluginPath(const FilePath& path) OVERRIDE; |
106 virtual void AddExtraPluginDir(const FilePath& path) OVERRIDE; | 104 virtual void AddExtraPluginDir(const FilePath& path) OVERRIDE; |
107 virtual void RemoveExtraPluginPath(const FilePath& path) OVERRIDE; | 105 virtual void RemoveExtraPluginPath(const FilePath& path) OVERRIDE; |
108 virtual void UnregisterInternalPlugin(const FilePath& path) OVERRIDE; | 106 virtual void UnregisterInternalPlugin(const FilePath& path) OVERRIDE; |
109 virtual void RegisterInternalPlugin( | 107 virtual void RegisterInternalPlugin( |
110 const webkit::WebPluginInfo& info, bool add_at_beginning) OVERRIDE; | 108 const webkit::WebPluginInfo& info, bool add_at_beginning) OVERRIDE; |
111 virtual void GetInternalPlugins( | 109 virtual void GetInternalPlugins( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 PluginProcessHost::Client* client, | 187 PluginProcessHost::Client* client, |
190 const std::vector<webkit::WebPluginInfo>&); | 188 const std::vector<webkit::WebPluginInfo>&); |
191 // Helper so we can do the plugin lookup on the FILE thread. | 189 // Helper so we can do the plugin lookup on the FILE thread. |
192 void GetAllowedPluginForOpenChannelToPlugin( | 190 void GetAllowedPluginForOpenChannelToPlugin( |
193 int render_process_id, | 191 int render_process_id, |
194 int render_view_id, | 192 int render_view_id, |
195 const GURL& url, | 193 const GURL& url, |
196 const GURL& page_url, | 194 const GURL& page_url, |
197 const std::string& mime_type, | 195 const std::string& mime_type, |
198 PluginProcessHost::Client* client, | 196 PluginProcessHost::Client* client, |
199 content::ResourceContext* resource_context); | 197 ResourceContext* resource_context); |
200 | 198 |
201 // Helper so we can finish opening the channel after looking up the | 199 // Helper so we can finish opening the channel after looking up the |
202 // plugin. | 200 // plugin. |
203 void FinishOpenChannelToPlugin( | 201 void FinishOpenChannelToPlugin( |
204 const FilePath& plugin_path, | 202 const FilePath& plugin_path, |
205 PluginProcessHost::Client* client); | 203 PluginProcessHost::Client* client); |
206 | 204 |
207 #if defined(OS_POSIX) && !defined(OS_OPENBSD) | 205 #if defined(OS_POSIX) && !defined(OS_OPENBSD) |
208 // Registers a new FilePathWatcher for a given path. | 206 // Registers a new FilePathWatcher for a given path. |
209 static void RegisterFilePathWatcher( | 207 static void RegisterFilePathWatcher( |
(...skipping 13 matching lines...) Expand all Loading... |
223 scoped_ptr<base::WaitableEvent> hklm_event_; | 221 scoped_ptr<base::WaitableEvent> hklm_event_; |
224 base::WaitableEventWatcher hkcu_watcher_; | 222 base::WaitableEventWatcher hkcu_watcher_; |
225 base::WaitableEventWatcher hklm_watcher_; | 223 base::WaitableEventWatcher hklm_watcher_; |
226 #endif | 224 #endif |
227 | 225 |
228 #if defined(OS_POSIX) && !defined(OS_OPENBSD) | 226 #if defined(OS_POSIX) && !defined(OS_OPENBSD) |
229 ScopedVector<base::files::FilePathWatcher> file_watchers_; | 227 ScopedVector<base::files::FilePathWatcher> file_watchers_; |
230 scoped_refptr<PluginDirWatcherDelegate> file_watcher_delegate_; | 228 scoped_refptr<PluginDirWatcherDelegate> file_watcher_delegate_; |
231 #endif | 229 #endif |
232 | 230 |
233 std::vector<content::PepperPluginInfo> ppapi_plugins_; | 231 std::vector<PepperPluginInfo> ppapi_plugins_; |
234 | 232 |
235 // Weak pointer; outlives us. | 233 // Weak pointer; outlives us. |
236 content::PluginServiceFilter* filter_; | 234 PluginServiceFilter* filter_; |
237 | 235 |
238 std::set<PluginProcessHost::Client*> pending_plugin_clients_; | 236 std::set<PluginProcessHost::Client*> pending_plugin_clients_; |
239 | 237 |
240 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
241 // Used to sequentialize loading plug-ins from disk. | 239 // Used to sequentialize loading plug-ins from disk. |
242 base::SequencedWorkerPool::SequenceToken plugin_list_token_; | 240 base::SequencedWorkerPool::SequenceToken plugin_list_token_; |
243 #endif | 241 #endif |
244 #if defined(OS_POSIX) | 242 #if defined(OS_POSIX) |
245 scoped_refptr<PluginLoaderPosix> plugin_loader_; | 243 scoped_refptr<PluginLoaderPosix> plugin_loader_; |
246 #endif | 244 #endif |
247 | 245 |
248 // Used to detect if a given plug-in is crashing over and over. | 246 // Used to detect if a given plug-in is crashing over and over. |
249 std::map<FilePath, std::vector<base::Time> > crash_times_; | 247 std::map<FilePath, std::vector<base::Time> > crash_times_; |
250 | 248 |
251 DISALLOW_COPY_AND_ASSIGN(PluginServiceImpl); | 249 DISALLOW_COPY_AND_ASSIGN(PluginServiceImpl); |
252 }; | 250 }; |
253 | 251 |
| 252 } // namespace content |
| 253 |
254 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_ | 254 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_ |
OLD | NEW |