OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
7 | 7 |
8 #include <map> | |
8 #include <set> | 9 #include <set> |
9 #include <string> | 10 #include <string> |
11 #include <utility> | |
10 #include <vector> | 12 #include <vector> |
11 | 13 |
12 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
13 #include "base/file_path.h" | 15 #include "base/file_path.h" |
14 #include "base/linked_ptr.h" | 16 #include "base/linked_ptr.h" |
15 #include "base/lock.h" | 17 #include "base/lock.h" |
16 #include "third_party/npapi/bindings/nphostapi.h" | 18 #include "third_party/npapi/bindings/nphostapi.h" |
17 #include "webkit/glue/plugins/plugin_group.h" | 19 #include "webkit/glue/plugins/plugin_group.h" |
18 #include "webkit/glue/plugins/webplugininfo.h" | 20 #include "webkit/glue/plugins/webplugininfo.h" |
19 | 21 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 185 |
184 // Load a specific plugin with full path. | 186 // Load a specific plugin with full path. |
185 void LoadPlugin(const FilePath& filename, | 187 void LoadPlugin(const FilePath& filename, |
186 std::vector<WebPluginInfo>* plugins); | 188 std::vector<WebPluginInfo>* plugins); |
187 | 189 |
188 // Enable a specific plugin, specified by path. Returns |true| iff a plugin | 190 // Enable a specific plugin, specified by path. Returns |true| iff a plugin |
189 // currently in the plugin list was actually enabled as a result; regardless | 191 // currently in the plugin list was actually enabled as a result; regardless |
190 // of return value, if a plugin is found in the future with the given name, it | 192 // of return value, if a plugin is found in the future with the given name, it |
191 // will be enabled. Note that plugins are enabled by default as far as | 193 // will be enabled. Note that plugins are enabled by default as far as |
192 // |PluginList| is concerned. | 194 // |PluginList| is concerned. |
193 bool EnablePlugin(const FilePath& filename); | 195 bool EnablePlugin(const FilePath& filename, const string16& name); |
Bernhard Bauer
2010/12/17 18:50:59
Can you explain what |name| is for? Are both requi
pastarmovj
2010/12/20 19:57:37
Done.
| |
194 | 196 |
195 // Disable a specific plugin, specified by path. Returns |true| iff a plugin | 197 // Disable a specific plugin, specified by path. Returns |true| iff a plugin |
196 // currently in the plugin list was actually disabled as a result; regardless | 198 // currently in the plugin list was actually disabled as a result; regardless |
197 // of return value, if a plugin is found in the future with the given name, it | 199 // of return value, if a plugin is found in the future with the given name, it |
198 // will be disabled. | 200 // will be disabled. The boolean flag should be set to true if the plugin is |
199 bool DisablePlugin(const FilePath& filename); | 201 // disabled by a policy and not a user. |
Bernhard Bauer
2010/12/17 18:50:59
That comment doesn't seem right.
jam
2010/12/17 19:14:45
nit: using boolean to specify whether it's user/po
pastarmovj
2010/12/20 19:57:37
I fixed the comment to make clear what the return
jam
2010/12/20 20:56:59
oops, i meant to add this comment on line 209. so
pastarmovj
2010/12/20 21:47:22
In any case these functions doesn't differentiate
| |
202 bool DisablePlugin(const FilePath& filename, const string16& name); | |
200 | 203 |
201 // Enable/disable a plugin group, specified by group_name. Returns |true| iff | 204 // Enable/disable a plugin group, specified by group_name. Returns |true| iff |
202 // a plugin currently in the plugin list was actually enabled/disabled as a | 205 // a plugin currently in the plugin list was actually enabled/disabled as a |
203 // result; regardless of return value, if a plugin is found in the future with | 206 // result; regardless of return value, if a plugin is found in the future with |
204 // the given name, it will be enabled/disabled. Note that plugins are enabled | 207 // the given name, it will be enabled/disabled. Note that plugins are enabled |
205 // by default as far as |PluginList| is concerned. | 208 // by default as far as |PluginList| is concerned. |
206 bool EnableGroup(bool enable, const string16& name); | 209 bool EnableGroup(bool enable, const string16& name); |
207 | 210 |
208 // Disable all plugins groups that are known to be outdated, according to | 211 // Disable all plugins groups that are known to be outdated, according to |
209 // the information hardcoded in PluginGroup, to make sure that they can't | 212 // the information hardcoded in PluginGroup, to make sure that they can't |
210 // be loaded on a web page and instead show a UI to update to the latest | 213 // be loaded on a web page and instead show a UI to update to the latest |
211 // version. | 214 // version. |
212 void DisableOutdatedPluginGroups(); | 215 void DisableOutdatedPluginGroups(); |
213 | 216 |
214 ~PluginList(); | 217 virtual ~PluginList(); |
215 | 218 |
216 private: | 219 private: |
217 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); | 220 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); |
218 | 221 |
219 // Constructors are private for singletons | 222 // Constructors are private for singletons |
220 PluginList(); | 223 PluginList(); |
221 | 224 |
222 // Creates PluginGroups for the static group definitions, and adds them to | 225 // Creates PluginGroups for the static group definitions, and adds them to |
223 // the PluginGroup cache of this PluginList. | 226 // the PluginGroup cache of this PluginList. |
224 void AddHardcodedPluginGroups(); | 227 void AddHardcodedPluginGroups(); |
225 | 228 |
226 // Adds the given WebPluginInfo to its corresponding group, creating it if | 229 // Adds the given WebPluginInfo to its corresponding group, creating it if |
227 // necessary, and returns the group. | 230 // necessary, and returns the group. |
228 // Callers need to protect calls to this method by a lock themselves. | 231 // Callers need to protect calls to this method by a lock themselves. |
229 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); | 232 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); |
230 | 233 |
234 // Adds the Plugin given by its path and name to its corresponding group, | |
235 // creating it if necessary, and returns the group. | |
236 // Callers need to protect calls to this method by a lock themselves. | |
237 PluginGroup* AddToPluginGroups(const FilePath& filename, | |
238 const string16& name); | |
239 | |
231 // Load all plugins from the default plugins directory | 240 // Load all plugins from the default plugins directory |
232 void LoadPlugins(bool refresh); | 241 void LoadPlugins(bool refresh); |
233 | 242 |
234 // Load all plugins from a specific directory. | 243 // Load all plugins from a specific directory. |
235 // |plugins| is updated with loaded plugin information. | 244 // |plugins| is updated with loaded plugin information. |
236 // |visited_plugins| is updated with paths to all plugins that were considered | 245 // |visited_plugins| is updated with paths to all plugins that were considered |
237 // (including those we didn't load) | 246 // (including those we didn't load) |
238 void LoadPluginsFromDir(const FilePath& path, | 247 void LoadPluginsFromDir(const FilePath& path, |
239 std::vector<WebPluginInfo>* plugins, | 248 std::vector<WebPluginInfo>* plugins, |
240 std::set<FilePath>* visited_plugins); | 249 std::set<FilePath>* visited_plugins); |
241 | 250 |
242 // Returns true if we should load the given plugin, or false otherwise. | 251 // Returns true if we should load the given plugin, or false otherwise. |
243 // plugins is the list of plugins we have crawled in the current plugin | 252 // plugins is the list of plugins we have crawled in the current plugin |
244 // loading run. | 253 // loading run. |
245 bool ShouldLoadPlugin(const WebPluginInfo& info, | 254 bool ShouldLoadPlugin(const WebPluginInfo& info, |
246 std::vector<WebPluginInfo>* plugins); | 255 std::vector<WebPluginInfo>* plugins); |
247 | 256 |
248 // Return whether a plug-in group with the given name should be disabled, | 257 // Return whether a plug-in group with the given name should be disabled, |
249 // either because it already is on the list of disabled groups, or because it | 258 // either because it already is on the list of disabled groups, or because it |
250 // is blacklisted by a policy. In the latter case, add the plugin group to the | 259 // is blacklisted by a policy. In the latter case, add the plugin group to the |
251 // list of disabled groups as well. | 260 // list of disabled groups as well. |
252 bool ShouldDisableGroup(const string16& group_name); | 261 bool ShouldDisableGroup(const string16& group_name); |
253 | 262 |
254 // Returns true if the given WebPluginInfo supports "mime-type". | |
255 // mime_type should be all lower case. | |
256 static bool SupportsType(const WebPluginInfo& info, | |
257 const std::string &mime_type, | |
258 bool allow_wildcard); | |
259 | |
260 // Returns true if the given WebPluginInfo supports a given file extension. | |
261 // extension should be all lower case. | |
262 // If mime_type is not NULL, it will be set to the mime type if found. | |
263 // The mime type which corresponds to the extension is optionally returned | |
264 // back. | |
265 static bool SupportsExtension(const WebPluginInfo& info, | |
266 const std::string &extension, | |
267 std::string* actual_mime_type); | |
268 | |
269 // | 263 // |
270 // Platform functions | 264 // Platform functions |
271 // | 265 // |
272 | 266 |
273 // Do any initialization. | 267 // Do any initialization. |
274 void PlatformInit(); | 268 void PlatformInit(); |
275 | 269 |
276 // Get the ordered list of directories from which to load plugins | 270 // Get the ordered list of directories from which to load plugins |
277 void GetPluginDirectories(std::vector<FilePath>* plugin_dirs); | 271 void GetPluginDirectories(std::vector<FilePath>* plugin_dirs); |
278 | 272 |
279 // | 273 // |
280 // Command-line switches | 274 // Command-line switches |
281 // | 275 // |
282 | 276 |
283 #if defined(OS_WIN) | 277 #if defined(OS_WIN) |
284 // true if we shouldn't load the new WMP plugin. | 278 // true if we shouldn't load the new WMP plugin. |
285 bool dont_load_new_wmp_; | 279 bool dont_load_new_wmp_; |
286 | 280 |
287 // Loads plugins registered under HKCU\Software\MozillaPlugins and | 281 // Loads plugins registered under HKCU\Software\MozillaPlugins and |
288 // HKLM\Software\MozillaPlugins. | 282 // HKLM\Software\MozillaPlugins. |
289 void LoadPluginsFromRegistry(std::vector<WebPluginInfo>* plugins, | 283 void LoadPluginsFromRegistry(std::set<FilePath>* visited_plugins, |
jam
2010/12/17 19:14:45
why switch these parameters' order?
pastarmovj
2010/12/20 19:57:37
Not by intention. Fixed.
| |
290 std::set<FilePath>* visited_plugins); | 284 std::vector<WebPluginInfo>* plugins); |
291 #endif | 285 #endif |
292 | 286 |
293 // | 287 // |
294 // Internals | 288 // Internals |
295 // | 289 // |
296 | 290 |
297 bool plugins_loaded_; | 291 bool plugins_loaded_; |
298 | 292 |
299 // If true, we reload plugins even if they've been loaded already. | 293 // If true, we reload plugins even if they've been loaded already. |
300 bool plugins_need_refresh_; | 294 bool plugins_need_refresh_; |
301 | 295 |
302 // Contains information about the available plugins. | |
303 std::vector<WebPluginInfo> plugins_; | |
304 | |
305 // Extra plugin paths that we want to search when loading. | 296 // Extra plugin paths that we want to search when loading. |
306 std::vector<FilePath> extra_plugin_paths_; | 297 std::vector<FilePath> extra_plugin_paths_; |
307 | 298 |
308 // Extra plugin directories that we want to search when loading. | 299 // Extra plugin directories that we want to search when loading. |
309 std::vector<FilePath> extra_plugin_dirs_; | 300 std::vector<FilePath> extra_plugin_dirs_; |
310 | 301 |
311 // Holds information about internal plugins. | 302 // Holds information about internal plugins. |
312 std::vector<PluginVersionInfo> internal_plugins_; | 303 std::vector<PluginVersionInfo> internal_plugins_; |
313 | 304 |
314 // Path names of plugins to disable (the default is to enable them all). | |
315 std::set<FilePath> disabled_plugins_; | |
316 | |
317 // Group names to disable (the default is to enable them all). | |
318 std::set<string16> disabled_groups_; | |
319 | |
320 bool disable_outdated_plugins_; | 305 bool disable_outdated_plugins_; |
321 | 306 |
322 // Holds the currently available plugin groups. | 307 // Holds the currently available plugin groups. |
323 PluginGroup::PluginMap plugin_groups_; | 308 PluginGroup::PluginMap plugin_groups_; |
324 | 309 |
325 int next_priority_; | 310 int next_priority_; |
326 | 311 |
327 // Need synchronization for the above members since this object can be | 312 // Need synchronization for the above members since this object can be |
328 // accessed on multiple threads. | 313 // accessed on multiple threads. |
329 Lock lock_; | 314 mutable Lock lock_; |
jam
2010/12/17 19:14:45
why make this mutable? if locking is required, se
pastarmovj
2010/12/20 19:57:37
I lock some getters to prevent writing happening w
| |
330 | 315 |
331 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 316 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
332 | 317 |
333 DISALLOW_COPY_AND_ASSIGN(PluginList); | 318 DISALLOW_COPY_AND_ASSIGN(PluginList); |
334 }; | 319 }; |
335 | 320 |
336 } // namespace NPAPI | 321 } // namespace NPAPI |
337 | 322 |
338 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 323 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
OLD | NEW |