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 <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 // The PluginList is responsible for loading our NPAPI based plugins. It does | 64 // The PluginList is responsible for loading our NPAPI based plugins. It does |
65 // so in whatever manner is appropriate for the platform. On Windows, it loads | 65 // so in whatever manner is appropriate for the platform. On Windows, it loads |
66 // plugins from a known directory by looking for DLLs which start with "NP", | 66 // plugins from a known directory by looking for DLLs which start with "NP", |
67 // and checking to see if they are valid NPAPI libraries. On the Mac, it walks | 67 // and checking to see if they are valid NPAPI libraries. On the Mac, it walks |
68 // the machine-wide and user plugin directories and loads anything that has | 68 // the machine-wide and user plugin directories and loads anything that has |
69 // the correct types. On Linux, it walks the plugin directories as well | 69 // the correct types. On Linux, it walks the plugin directories as well |
70 // (e.g. /usr/lib/browser-plugins/). | 70 // (e.g. /usr/lib/browser-plugins/). |
71 // This object is thread safe. | 71 // This object is thread safe. |
72 class PluginList { | 72 class PluginList { |
73 public: | 73 public: |
74 // Enum of possible reasons for plugin or group being disabled. Used in the | |
75 // |disabled_plugins_| and |disabled_groups_| maps. | |
76 enum DisabledElementReason { USER = 0, POLICY, POLICY_AND_USER }; | |
danno
2010/12/14 09:43:39
How about PluginDisabledReason?
pastarmovj
2010/12/15 14:44:51
Done.
| |
77 typedef std::map<FilePath, DisabledElementReason> DisabledPluginsList; | |
78 typedef std::map<string16, DisabledElementReason> DisabledGroupsList; | |
danno
2010/12/14 09:43:39
This is a map, so the list name is misleading. con
pastarmovj
2010/12/15 14:44:51
Done.
| |
79 | |
74 // Gets the one instance of the PluginList. | 80 // Gets the one instance of the PluginList. |
75 static PluginList* Singleton(); | 81 static PluginList* Singleton(); |
76 | 82 |
77 // Returns true if we're in debug-plugin-loading mode. This is controlled | 83 // Returns true if we're in debug-plugin-loading mode. This is controlled |
78 // by a command line switch. | 84 // by a command line switch. |
79 static bool DebugPluginLoading(); | 85 static bool DebugPluginLoading(); |
80 | 86 |
81 static const PluginGroupDefinition* GetPluginGroupDefinitions(); | 87 static const PluginGroupDefinition* GetPluginGroupDefinitions(); |
82 static size_t GetPluginGroupDefinitionsSize(); | 88 static size_t GetPluginGroupDefinitionsSize(); |
83 | 89 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 // Returns the name of the PluginGroup with the given identifier. | 181 // Returns the name of the PluginGroup with the given identifier. |
176 // If no such group exists, an empty string is returned. | 182 // If no such group exists, an empty string is returned. |
177 string16 GetPluginGroupName(std::string identifier); | 183 string16 GetPluginGroupName(std::string identifier); |
178 | 184 |
179 // Returns the identifier string of the PluginGroup corresponding to the given | 185 // Returns the identifier string of the PluginGroup corresponding to the given |
180 // WebPluginInfo. If no such group exists, it is created and added to the | 186 // WebPluginInfo. If no such group exists, it is created and added to the |
181 // cache. | 187 // cache. |
182 std::string GetPluginGroupIdentifier(const WebPluginInfo& web_plugin_info); | 188 std::string GetPluginGroupIdentifier(const WebPluginInfo& web_plugin_info); |
183 | 189 |
184 // Load a specific plugin with full path. | 190 // Load a specific plugin with full path. |
185 void LoadPlugin(const FilePath& filename, | 191 void LoadPlugin(const FilePath& filename); |
186 std::vector<WebPluginInfo>* plugins); | |
187 | 192 |
188 // Enable a specific plugin, specified by path. Returns |true| iff a plugin | 193 // 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 | 194 // 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 | 195 // 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 | 196 // will be enabled. Note that plugins are enabled by default as far as |
192 // |PluginList| is concerned. | 197 // |PluginList| is concerned. |
193 bool EnablePlugin(const FilePath& filename); | 198 bool EnablePlugin(const FilePath& filename); |
194 | 199 |
195 // Disable a specific plugin, specified by path. Returns |true| iff a plugin | 200 // 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 | 201 // 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 | 202 // of return value, if a plugin is found in the future with the given name, it |
198 // will be disabled. | 203 // will be disabled. The boolean flag should be set to true if the operation |
danno
2010/12/14 09:43:39
... if the plugin is disabled by a policy and not
pastarmovj
2010/12/15 14:44:51
Done.
| |
199 bool DisablePlugin(const FilePath& filename); | 204 // has been trigerred by a policy and not by the user. |
205 bool DisablePlugin(const FilePath& filename, bool policy_disabled); | |
200 | 206 |
201 // Enable/disable a plugin group, specified by group_name. Returns |true| iff | 207 // 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 | 208 // 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 | 209 // 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 | 210 // the given name, it will be enabled/disabled. Note that plugins are enabled |
205 // by default as far as |PluginList| is concerned. | 211 // by default as far as |PluginList| is concerned. |
206 bool EnableGroup(bool enable, const string16& name); | 212 bool EnableGroup(bool enable, const string16& name); |
207 | 213 |
208 // Disable all plugins groups that are known to be outdated, according to | 214 // 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 | 215 // 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 | 216 // be loaded on a web page and instead show a UI to update to the latest |
211 // version. | 217 // version. |
212 void DisableOutdatedPluginGroups(); | 218 void DisableOutdatedPluginGroups(); |
213 | 219 |
220 void GetDisabledPlugins(DisabledPluginsList* disabled_plugins); | |
221 | |
222 void GetDisabledGroups(DisabledGroupsList* disabled_groups); | |
danno
2010/12/14 09:43:39
Do these copy? If so, why (probably should documen
pastarmovj
2010/12/15 14:44:51
Done.
| |
223 | |
214 ~PluginList(); | 224 ~PluginList(); |
215 | 225 |
216 private: | 226 private: |
217 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); | 227 FRIEND_TEST_ALL_PREFIXES(PluginGroupTest, PluginGroupDefinition); |
218 | 228 |
219 // Constructors are private for singletons | 229 // Constructors are private for singletons |
220 PluginList(); | 230 PluginList(); |
221 | 231 |
222 // Creates PluginGroups for the static group definitions, and adds them to | 232 // Creates PluginGroups for the static group definitions, and adds them to |
223 // the PluginGroup cache of this PluginList. | 233 // the PluginGroup cache of this PluginList. |
224 void AddHardcodedPluginGroups(); | 234 void AddHardcodedPluginGroups(); |
225 | 235 |
226 // Adds the given WebPluginInfo to its corresponding group, creating it if | 236 // Adds the given WebPluginInfo to its corresponding group, creating it if |
227 // necessary, and returns the group. | 237 // necessary, and returns the group. |
228 // Callers need to protect calls to this method by a lock themselves. | 238 // Callers need to protect calls to this method by a lock themselves. |
229 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); | 239 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); |
230 | 240 |
231 // Load all plugins from the default plugins directory | 241 // Load all plugins from the default plugins directory |
232 void LoadPlugins(bool refresh); | 242 void LoadPlugins(bool refresh); |
233 | 243 |
244 // Populates the |plugins_| vector if is has been marked as dirty. | |
danno
2010/12/14 09:43:39
"it" missing?
pastarmovj
2010/12/15 14:44:51
Done. s/is/it/
| |
245 void RebuildPluginsList(); | |
246 | |
234 // Load all plugins from a specific directory. | 247 // Load all plugins from a specific directory. |
235 // |plugins| is updated with loaded plugin information. | 248 // |plugins| is updated with loaded plugin information. |
236 // |visited_plugins| is updated with paths to all plugins that were considered | 249 // |visited_plugins| is updated with paths to all plugins that were considered |
237 // (including those we didn't load) | 250 // (including those we didn't load) |
238 void LoadPluginsFromDir(const FilePath& path, | 251 void LoadPluginsFromDir(const FilePath& path, |
239 std::vector<WebPluginInfo>* plugins, | |
240 std::set<FilePath>* visited_plugins); | 252 std::set<FilePath>* visited_plugins); |
241 | 253 |
242 // Returns true if we should load the given plugin, or false otherwise. | 254 // 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 | 255 // plugins is the list of plugins we have crawled in the current plugin |
244 // loading run. | 256 // loading run. |
245 bool ShouldLoadPlugin(const WebPluginInfo& info, | 257 bool ShouldLoadPlugin(const WebPluginInfo& info); |
246 std::vector<WebPluginInfo>* plugins); | |
247 | 258 |
248 // Return whether a plug-in group with the given name should be disabled, | 259 // 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 | 260 // 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 | 261 // is blacklisted by a policy. In the latter case, add the plugin group to the |
251 // list of disabled groups as well. | 262 // list of disabled groups as well. |
252 bool ShouldDisableGroup(const string16& group_name); | 263 bool ShouldDisableGroup(const string16& group_name); |
253 | 264 |
254 // Returns true if the given WebPluginInfo supports "mime-type". | 265 // Returns true if the given WebPluginInfo supports "mime-type". |
255 // mime_type should be all lower case. | 266 // mime_type should be all lower case. |
256 static bool SupportsType(const WebPluginInfo& info, | 267 static bool SupportsType(const WebPluginInfo& info, |
(...skipping 22 matching lines...) Expand all Loading... | |
279 // | 290 // |
280 // Command-line switches | 291 // Command-line switches |
281 // | 292 // |
282 | 293 |
283 #if defined(OS_WIN) | 294 #if defined(OS_WIN) |
284 // true if we shouldn't load the new WMP plugin. | 295 // true if we shouldn't load the new WMP plugin. |
285 bool dont_load_new_wmp_; | 296 bool dont_load_new_wmp_; |
286 | 297 |
287 // Loads plugins registered under HKCU\Software\MozillaPlugins and | 298 // Loads plugins registered under HKCU\Software\MozillaPlugins and |
288 // HKLM\Software\MozillaPlugins. | 299 // HKLM\Software\MozillaPlugins. |
289 void LoadPluginsFromRegistry(std::vector<WebPluginInfo>* plugins, | 300 void LoadPluginsFromRegistry(std::vector<WebPluginInfo*>* plugins, |
290 std::set<FilePath>* visited_plugins); | 301 std::set<FilePath>* visited_plugins); |
291 #endif | 302 #endif |
292 | 303 |
293 // | 304 // |
294 // Internals | 305 // Internals |
295 // | 306 // |
296 | 307 |
297 bool plugins_loaded_; | 308 bool plugins_loaded_; |
298 | 309 |
299 // If true, we reload plugins even if they've been loaded already. | 310 // If true, we reload plugins even if they've been loaded already. |
300 bool plugins_need_refresh_; | 311 bool plugins_need_refresh_; |
301 | 312 |
302 // Contains information about the available plugins. | 313 // Contains information about the available plugins. |
303 std::vector<WebPluginInfo> plugins_; | 314 std::vector<WebPluginInfo*> plugins_; |
danno
2010/12/14 09:43:39
I see that you don't explicitly manage the memory
| |
315 bool plugins_vector_is_dirty_; | |
danno
2010/12/14 09:43:39
Please document when this actually happens.
pastarmovj
2010/12/15 14:44:51
Obsoleted,
| |
304 | 316 |
305 // Extra plugin paths that we want to search when loading. | 317 // Extra plugin paths that we want to search when loading. |
306 std::vector<FilePath> extra_plugin_paths_; | 318 std::vector<FilePath> extra_plugin_paths_; |
307 | 319 |
308 // Extra plugin directories that we want to search when loading. | 320 // Extra plugin directories that we want to search when loading. |
309 std::vector<FilePath> extra_plugin_dirs_; | 321 std::vector<FilePath> extra_plugin_dirs_; |
310 | 322 |
311 // Holds information about internal plugins. | 323 // Holds information about internal plugins. |
312 std::vector<PluginVersionInfo> internal_plugins_; | 324 std::vector<PluginVersionInfo> internal_plugins_; |
313 | 325 |
326 // An element of the disabled list saves the reason for being disabled in the | |
327 // second element of the pair. | |
328 typedef std::pair<FilePath, DisabledElementReason> DisabledPluginsListElement; | |
314 // Path names of plugins to disable (the default is to enable them all). | 329 // Path names of plugins to disable (the default is to enable them all). |
315 std::set<FilePath> disabled_plugins_; | 330 DisabledPluginsList disabled_plugins_; |
316 | 331 |
332 typedef std::pair<string16, DisabledElementReason> DisabledGroupsListElement; | |
317 // Group names to disable (the default is to enable them all). | 333 // Group names to disable (the default is to enable them all). |
318 std::set<string16> disabled_groups_; | 334 DisabledGroupsList disabled_groups_; |
319 | 335 |
320 bool disable_outdated_plugins_; | 336 bool disable_outdated_plugins_; |
321 | 337 |
322 // Holds the currently available plugin groups. | 338 // Holds the currently available plugin groups. |
323 PluginGroup::PluginMap plugin_groups_; | 339 PluginGroup::PluginMap plugin_groups_; |
324 | 340 |
325 int next_priority_; | 341 int next_priority_; |
326 | 342 |
327 // Need synchronization for the above members since this object can be | 343 // Need synchronization for the above members since this object can be |
328 // accessed on multiple threads. | 344 // accessed on multiple threads. |
329 Lock lock_; | 345 Lock lock_; |
330 | 346 |
331 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 347 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
332 | 348 |
333 DISALLOW_COPY_AND_ASSIGN(PluginList); | 349 DISALLOW_COPY_AND_ASSIGN(PluginList); |
334 }; | 350 }; |
335 | 351 |
336 } // namespace NPAPI | 352 } // namespace NPAPI |
337 | 353 |
338 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 354 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
OLD | NEW |