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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 virtual bool GetPluginInfo(int render_process_id, | 81 virtual bool GetPluginInfo(int render_process_id, |
82 int render_view_id, | 82 int render_view_id, |
83 ResourceContext* context, | 83 ResourceContext* context, |
84 const GURL& url, | 84 const GURL& url, |
85 const GURL& page_url, | 85 const GURL& page_url, |
86 const std::string& mime_type, | 86 const std::string& mime_type, |
87 bool allow_wildcard, | 87 bool allow_wildcard, |
88 bool* is_stale, | 88 bool* is_stale, |
89 webkit::WebPluginInfo* info, | 89 webkit::WebPluginInfo* info, |
90 std::string* actual_mime_type) OVERRIDE; | 90 std::string* actual_mime_type) OVERRIDE; |
91 virtual bool GetPluginInfoByPath(const FilePath& plugin_path, | 91 virtual bool GetPluginInfoByPath(const base::FilePath& plugin_path, |
92 webkit::WebPluginInfo* info) OVERRIDE; | 92 webkit::WebPluginInfo* info) OVERRIDE; |
93 virtual string16 GetPluginDisplayNameByPath(const FilePath& path) OVERRIDE; | 93 virtual string16 GetPluginDisplayNameByPath( |
| 94 const base::FilePath& path) OVERRIDE; |
94 virtual void GetPlugins(const GetPluginsCallback& callback) OVERRIDE; | 95 virtual void GetPlugins(const GetPluginsCallback& callback) OVERRIDE; |
95 virtual PepperPluginInfo* GetRegisteredPpapiPluginInfo( | 96 virtual PepperPluginInfo* GetRegisteredPpapiPluginInfo( |
96 const FilePath& plugin_path) OVERRIDE; | 97 const base::FilePath& plugin_path) OVERRIDE; |
97 virtual void SetFilter(PluginServiceFilter* filter) OVERRIDE; | 98 virtual void SetFilter(PluginServiceFilter* filter) OVERRIDE; |
98 virtual PluginServiceFilter* GetFilter() OVERRIDE; | 99 virtual PluginServiceFilter* GetFilter() OVERRIDE; |
99 virtual void ForcePluginShutdown(const FilePath& plugin_path) OVERRIDE; | 100 virtual void ForcePluginShutdown(const base::FilePath& plugin_path) OVERRIDE; |
100 virtual bool IsPluginUnstable(const FilePath& plugin_path) OVERRIDE; | 101 virtual bool IsPluginUnstable(const base::FilePath& plugin_path) OVERRIDE; |
101 virtual void RefreshPlugins() OVERRIDE; | 102 virtual void RefreshPlugins() OVERRIDE; |
102 virtual void AddExtraPluginPath(const FilePath& path) OVERRIDE; | 103 virtual void AddExtraPluginPath(const base::FilePath& path) OVERRIDE; |
103 virtual void AddExtraPluginDir(const FilePath& path) OVERRIDE; | 104 virtual void AddExtraPluginDir(const base::FilePath& path) OVERRIDE; |
104 virtual void RemoveExtraPluginPath(const FilePath& path) OVERRIDE; | 105 virtual void RemoveExtraPluginPath(const base::FilePath& path) OVERRIDE; |
105 virtual void UnregisterInternalPlugin(const FilePath& path) OVERRIDE; | 106 virtual void UnregisterInternalPlugin(const base::FilePath& path) OVERRIDE; |
106 virtual void RegisterInternalPlugin( | 107 virtual void RegisterInternalPlugin( |
107 const webkit::WebPluginInfo& info, bool add_at_beginning) OVERRIDE; | 108 const webkit::WebPluginInfo& info, bool add_at_beginning) OVERRIDE; |
108 virtual void GetInternalPlugins( | 109 virtual void GetInternalPlugins( |
109 std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; | 110 std::vector<webkit::WebPluginInfo>* plugins) OVERRIDE; |
110 virtual webkit::npapi::PluginList* GetPluginList() OVERRIDE; | 111 virtual webkit::npapi::PluginList* GetPluginList() OVERRIDE; |
111 virtual void SetPluginListForTesting( | 112 virtual void SetPluginListForTesting( |
112 webkit::npapi::PluginList* plugin_list) OVERRIDE; | 113 webkit::npapi::PluginList* plugin_list) OVERRIDE; |
113 #if defined(OS_MACOSX) | 114 #if defined(OS_MACOSX) |
114 virtual void AppActivated() OVERRIDE; | 115 virtual void AppActivated() OVERRIDE; |
115 #endif | 116 #endif |
116 | 117 |
117 // Returns the plugin process host corresponding to the plugin process that | 118 // Returns the plugin process host corresponding to the plugin process that |
118 // has been started by this service. This will start a process to host the | 119 // has been started by this service. This will start a process to host the |
119 // 'plugin_path' if needed. If the process fails to start, the return value | 120 // 'plugin_path' if needed. If the process fails to start, the return value |
120 // is NULL. Must be called on the IO thread. | 121 // is NULL. Must be called on the IO thread. |
121 PluginProcessHost* FindOrStartNpapiPluginProcess( | 122 PluginProcessHost* FindOrStartNpapiPluginProcess( |
122 int render_process_id, const FilePath& plugin_path); | 123 int render_process_id, const base::FilePath& plugin_path); |
123 PpapiPluginProcessHost* FindOrStartPpapiPluginProcess( | 124 PpapiPluginProcessHost* FindOrStartPpapiPluginProcess( |
124 int render_process_id, | 125 int render_process_id, |
125 const FilePath& plugin_path, | 126 const base::FilePath& plugin_path, |
126 const FilePath& profile_data_directory, | 127 const base::FilePath& profile_data_directory, |
127 PpapiPluginProcessHost::PluginClient* client); | 128 PpapiPluginProcessHost::PluginClient* client); |
128 PpapiPluginProcessHost* FindOrStartPpapiBrokerProcess( | 129 PpapiPluginProcessHost* FindOrStartPpapiBrokerProcess( |
129 int render_process_id, const FilePath& plugin_path); | 130 int render_process_id, const base::FilePath& plugin_path); |
130 | 131 |
131 // Opens a channel to a plugin process for the given mime type, starting | 132 // Opens a channel to a plugin process for the given mime type, starting |
132 // a new plugin process if necessary. This must be called on the IO thread | 133 // a new plugin process if necessary. This must be called on the IO thread |
133 // or else a deadlock can occur. | 134 // or else a deadlock can occur. |
134 void OpenChannelToNpapiPlugin(int render_process_id, | 135 void OpenChannelToNpapiPlugin(int render_process_id, |
135 int render_view_id, | 136 int render_view_id, |
136 const GURL& url, | 137 const GURL& url, |
137 const GURL& page_url, | 138 const GURL& page_url, |
138 const std::string& mime_type, | 139 const std::string& mime_type, |
139 PluginProcessHost::Client* client); | 140 PluginProcessHost::Client* client); |
140 void OpenChannelToPpapiPlugin(int render_process_id, | 141 void OpenChannelToPpapiPlugin(int render_process_id, |
141 const FilePath& plugin_path, | 142 const base::FilePath& plugin_path, |
142 const FilePath& profile_data_directory, | 143 const base::FilePath& profile_data_directory, |
143 PpapiPluginProcessHost::PluginClient* client); | 144 PpapiPluginProcessHost::PluginClient* client); |
144 void OpenChannelToPpapiBroker(int render_process_id, | 145 void OpenChannelToPpapiBroker(int render_process_id, |
145 const FilePath& path, | 146 const base::FilePath& path, |
146 PpapiPluginProcessHost::BrokerClient* client); | 147 PpapiPluginProcessHost::BrokerClient* client); |
147 | 148 |
148 // Cancels opening a channel to a NPAPI plugin. | 149 // Cancels opening a channel to a NPAPI plugin. |
149 void CancelOpenChannelToNpapiPlugin(PluginProcessHost::Client* client); | 150 void CancelOpenChannelToNpapiPlugin(PluginProcessHost::Client* client); |
150 | 151 |
151 // Used to monitor plug-in stability. | 152 // Used to monitor plug-in stability. |
152 void RegisterPluginCrash(const FilePath& plugin_path); | 153 void RegisterPluginCrash(const base::FilePath& plugin_path); |
153 | 154 |
154 private: | 155 private: |
155 friend struct DefaultSingletonTraits<PluginServiceImpl>; | 156 friend struct DefaultSingletonTraits<PluginServiceImpl>; |
156 | 157 |
157 // Creates the PluginServiceImpl object, but doesn't actually build the plugin | 158 // Creates the PluginServiceImpl object, but doesn't actually build the plugin |
158 // list yet. It's generated lazily. | 159 // list yet. It's generated lazily. |
159 PluginServiceImpl(); | 160 PluginServiceImpl(); |
160 virtual ~PluginServiceImpl(); | 161 virtual ~PluginServiceImpl(); |
161 | 162 |
162 void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); | 163 void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); |
163 | 164 |
164 // Returns the plugin process host corresponding to the plugin process that | 165 // Returns the plugin process host corresponding to the plugin process that |
165 // has been started by this service. Returns NULL if no process has been | 166 // has been started by this service. Returns NULL if no process has been |
166 // started. | 167 // started. |
167 PluginProcessHost* FindNpapiPluginProcess(const FilePath& plugin_path); | 168 PluginProcessHost* FindNpapiPluginProcess(const base::FilePath& plugin_path); |
168 PpapiPluginProcessHost* FindPpapiPluginProcess( | 169 PpapiPluginProcessHost* FindPpapiPluginProcess( |
169 const FilePath& plugin_path, | 170 const base::FilePath& plugin_path, |
170 const FilePath& profile_data_directory); | 171 const base::FilePath& profile_data_directory); |
171 PpapiPluginProcessHost* FindPpapiBrokerProcess(const FilePath& broker_path); | 172 PpapiPluginProcessHost* FindPpapiBrokerProcess( |
| 173 const base::FilePath& broker_path); |
172 | 174 |
173 void RegisterPepperPlugins(); | 175 void RegisterPepperPlugins(); |
174 | 176 |
175 // Run on the blocking pool to load the plugins synchronously. | 177 // Run on the blocking pool to load the plugins synchronously. |
176 void GetPluginsInternal(base::MessageLoopProxy* target_loop, | 178 void GetPluginsInternal(base::MessageLoopProxy* target_loop, |
177 const GetPluginsCallback& callback); | 179 const GetPluginsCallback& callback); |
178 | 180 |
179 // Binding directly to GetAllowedPluginForOpenChannelToPlugin() isn't possible | 181 // Binding directly to GetAllowedPluginForOpenChannelToPlugin() isn't possible |
180 // because more arity is needed <http://crbug.com/98542>. This just forwards. | 182 // because more arity is needed <http://crbug.com/98542>. This just forwards. |
181 void ForwardGetAllowedPluginForOpenChannelToPlugin( | 183 void ForwardGetAllowedPluginForOpenChannelToPlugin( |
182 const PluginServiceFilterParams& params, | 184 const PluginServiceFilterParams& params, |
183 const GURL& url, | 185 const GURL& url, |
184 const std::string& mime_type, | 186 const std::string& mime_type, |
185 PluginProcessHost::Client* client, | 187 PluginProcessHost::Client* client, |
186 const std::vector<webkit::WebPluginInfo>&); | 188 const std::vector<webkit::WebPluginInfo>&); |
187 // 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. |
188 void GetAllowedPluginForOpenChannelToPlugin( | 190 void GetAllowedPluginForOpenChannelToPlugin( |
189 int render_process_id, | 191 int render_process_id, |
190 int render_view_id, | 192 int render_view_id, |
191 const GURL& url, | 193 const GURL& url, |
192 const GURL& page_url, | 194 const GURL& page_url, |
193 const std::string& mime_type, | 195 const std::string& mime_type, |
194 PluginProcessHost::Client* client, | 196 PluginProcessHost::Client* client, |
195 ResourceContext* resource_context); | 197 ResourceContext* resource_context); |
196 | 198 |
197 // 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 |
198 // plugin. | 200 // plugin. |
199 void FinishOpenChannelToPlugin(int render_process_id, | 201 void FinishOpenChannelToPlugin(int render_process_id, |
200 const FilePath& plugin_path, | 202 const base::FilePath& plugin_path, |
201 PluginProcessHost::Client* client); | 203 PluginProcessHost::Client* client); |
202 | 204 |
203 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID) | 205 #if defined(OS_POSIX) && !defined(OS_OPENBSD) && !defined(OS_ANDROID) |
204 // Registers a new FilePathWatcher for a given path. | 206 // Registers a new FilePathWatcher for a given path. |
205 static void RegisterFilePathWatcher(base::FilePathWatcher* watcher, | 207 static void RegisterFilePathWatcher(base::FilePathWatcher* watcher, |
206 const FilePath& path); | 208 const base::FilePath& path); |
207 #endif | 209 #endif |
208 | 210 |
209 // The plugin list instance. | 211 // The plugin list instance. |
210 webkit::npapi::PluginList* plugin_list_; | 212 webkit::npapi::PluginList* plugin_list_; |
211 | 213 |
212 #if defined(OS_WIN) | 214 #if defined(OS_WIN) |
213 // Registry keys for getting notifications when new plugins are installed. | 215 // Registry keys for getting notifications when new plugins are installed. |
214 base::win::RegKey hkcu_key_; | 216 base::win::RegKey hkcu_key_; |
215 base::win::RegKey hklm_key_; | 217 base::win::RegKey hklm_key_; |
216 scoped_ptr<base::WaitableEvent> hkcu_event_; | 218 scoped_ptr<base::WaitableEvent> hkcu_event_; |
(...skipping 14 matching lines...) Expand all Loading... |
231 std::set<PluginProcessHost::Client*> pending_plugin_clients_; | 233 std::set<PluginProcessHost::Client*> pending_plugin_clients_; |
232 | 234 |
233 // Used to sequentialize loading plug-ins from disk. | 235 // Used to sequentialize loading plug-ins from disk. |
234 base::SequencedWorkerPool::SequenceToken plugin_list_token_; | 236 base::SequencedWorkerPool::SequenceToken plugin_list_token_; |
235 | 237 |
236 #if defined(OS_POSIX) | 238 #if defined(OS_POSIX) |
237 scoped_refptr<PluginLoaderPosix> plugin_loader_; | 239 scoped_refptr<PluginLoaderPosix> plugin_loader_; |
238 #endif | 240 #endif |
239 | 241 |
240 // Used to detect if a given plug-in is crashing over and over. | 242 // Used to detect if a given plug-in is crashing over and over. |
241 std::map<FilePath, std::vector<base::Time> > crash_times_; | 243 std::map<base::FilePath, std::vector<base::Time> > crash_times_; |
242 | 244 |
243 DISALLOW_COPY_AND_ASSIGN(PluginServiceImpl); | 245 DISALLOW_COPY_AND_ASSIGN(PluginServiceImpl); |
244 }; | 246 }; |
245 | 247 |
246 } // namespace content | 248 } // namespace content |
247 | 249 |
248 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_ | 250 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_IMPL_H_ |
OLD | NEW |