| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 5 #ifndef WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |
| 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 6 #define WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // In Windows plugins, the mime types are passed as a specially formatted list | 111 // In Windows plugins, the mime types are passed as a specially formatted list |
| 112 // of strings. This function parses those strings into a WebPluginMimeType | 112 // of strings. This function parses those strings into a WebPluginMimeType |
| 113 // vector. | 113 // vector. |
| 114 // TODO(evan): move this code into plugin_list_win. | 114 // TODO(evan): move this code into plugin_list_win. |
| 115 static bool ParseMimeTypes(const std::string& mime_types, | 115 static bool ParseMimeTypes(const std::string& mime_types, |
| 116 const std::string& file_extensions, | 116 const std::string& file_extensions, |
| 117 const string16& mime_type_descriptions, | 117 const string16& mime_type_descriptions, |
| 118 std::vector<WebPluginMimeType>* parsed_mime_types); | 118 std::vector<WebPluginMimeType>* parsed_mime_types); |
| 119 | 119 |
| 120 // Get all the plugins. | 120 // Get all the plugins. |
| 121 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); | 121 void GetPlugins(std::vector<WebPluginInfo>* plugins); |
| 122 | |
| 123 // Get all the enabled plugins. | |
| 124 void GetEnabledPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); | |
| 125 | 122 |
| 126 // Returns a list in |info| containing plugins that are found for | 123 // Returns a list in |info| containing plugins that are found for |
| 127 // the given url and mime type (including disabled plugins, for | 124 // the given url and mime type (including disabled plugins, for |
| 128 // which |info->enabled| is false). The mime type which corresponds | 125 // which |info->enabled| is false). The mime type which corresponds |
| 129 // to the URL is optionally returned back in |actual_mime_types| (if | 126 // to the URL is optionally returned back in |actual_mime_types| (if |
| 130 // it is non-NULL), one for each of the plugin info objects found. | 127 // it is non-NULL), one for each of the plugin info objects found. |
| 131 // The |allow_wildcard| parameter controls whether this function | 128 // The |allow_wildcard| parameter controls whether this function |
| 132 // returns plugins which support wildcard mime types (* as the mime | 129 // returns plugins which support wildcard mime types (* as the mime |
| 133 // type). The |info| parameter is required to be non-NULL. The | 130 // type). The |info| parameter is required to be non-NULL. The |
| 134 // list is in order of "most desirable" to "least desirable", | 131 // list is in order of "most desirable" to "least desirable", |
| 135 // meaning that the default plugin is at the end of the list. | 132 // meaning that the default plugin is at the end of the list. |
| 133 // If |use_stale| is NULL, this will load the plug-in list if necessary. |
| 134 // If it is not NULL, the plug-in list will not be loaded, and |*use_stale| |
| 135 // will be true iff the plug-in list was stale. |
| 136 void GetPluginInfoArray(const GURL& url, | 136 void GetPluginInfoArray(const GURL& url, |
| 137 const std::string& mime_type, | 137 const std::string& mime_type, |
| 138 bool allow_wildcard, | 138 bool allow_wildcard, |
| 139 bool* use_stale, |
| 139 std::vector<WebPluginInfo>* info, | 140 std::vector<WebPluginInfo>* info, |
| 140 std::vector<std::string>* actual_mime_types); | 141 std::vector<std::string>* actual_mime_types); |
| 141 | 142 |
| 142 // Returns the first item from the list returned in GetPluginInfo in |info|. | |
| 143 // Returns true if it found a match. |actual_mime_type| may be NULL. | |
| 144 bool GetPluginInfo(const GURL& url, | |
| 145 const std::string& mime_type, | |
| 146 bool allow_wildcard, | |
| 147 WebPluginInfo* info, | |
| 148 std::string* actual_mime_type); | |
| 149 | |
| 150 // Get plugin info by plugin path (including disabled plugins). Returns true | 143 // Get plugin info by plugin path (including disabled plugins). Returns true |
| 151 // if the plugin is found and WebPluginInfo has been filled in |info|. | 144 // if the plugin is found and WebPluginInfo has been filled in |info|. |
| 152 bool GetPluginInfoByPath(const FilePath& plugin_path, | 145 bool GetPluginInfoByPath(const FilePath& plugin_path, |
| 153 WebPluginInfo* info); | 146 WebPluginInfo* info); |
| 154 | 147 |
| 155 // Populates the given vector with all available plugin groups. | 148 // Populates the given vector with all available plugin groups. |
| 156 void GetPluginGroups(bool load_if_necessary, | 149 void GetPluginGroups(bool load_if_necessary, |
| 157 std::vector<PluginGroup>* plugin_groups); | 150 std::vector<PluginGroup>* plugin_groups); |
| 158 | 151 |
| 159 // Returns the PluginGroup corresponding to the given WebPluginInfo. If no | 152 // Returns the PluginGroup corresponding to the given WebPluginInfo. If no |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // result; regardless of return value, if a plugin is found in the future with | 189 // result; regardless of return value, if a plugin is found in the future with |
| 197 // the given name, it will be enabled/disabled. | 190 // the given name, it will be enabled/disabled. |
| 198 bool EnableGroup(bool enable, const string16& name); | 191 bool EnableGroup(bool enable, const string16& name); |
| 199 | 192 |
| 200 // Disable all plugins groups that are known to be outdated, according to | 193 // Disable all plugins groups that are known to be outdated, according to |
| 201 // the information hardcoded in PluginGroup, to make sure that they can't | 194 // the information hardcoded in PluginGroup, to make sure that they can't |
| 202 // be loaded on a web page and instead show a UI to update to the latest | 195 // be loaded on a web page and instead show a UI to update to the latest |
| 203 // version. | 196 // version. |
| 204 void DisableOutdatedPluginGroups(); | 197 void DisableOutdatedPluginGroups(); |
| 205 | 198 |
| 206 // Returns true if the plugin list is stale, i.e. it will need to be | |
| 207 // (re)loaded on the next access. | |
| 208 bool stale() { return plugins_need_refresh_; } | |
| 209 | |
| 210 virtual ~PluginList(); | 199 virtual ~PluginList(); |
| 211 | 200 |
| 212 protected: | 201 protected: |
| 213 // This constructor is used in unit tests to override the platform-dependent | 202 // This constructor is used in unit tests to override the platform-dependent |
| 214 // real-world plugin group definitions with custom ones. | 203 // real-world plugin group definitions with custom ones. |
| 215 PluginList(const PluginGroupDefinition* definitions, size_t num_definitions); | 204 PluginList(const PluginGroupDefinition* definitions, size_t num_definitions); |
| 216 | 205 |
| 217 // Adds the given WebPluginInfo to its corresponding group, creating it if | 206 // Adds the given WebPluginInfo to its corresponding group, creating it if |
| 218 // necessary, and returns the group. | 207 // necessary, and returns the group. |
| 219 // Callers need to protect calls to this method by a lock themselves. | 208 // Callers need to protect calls to this method by a lock themselves. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 231 // Creates PluginGroups for the static group definitions, and adds them to | 220 // Creates PluginGroups for the static group definitions, and adds them to |
| 232 // the list of PluginGroups. | 221 // the list of PluginGroups. |
| 233 void AddHardcodedPluginGroups(ScopedVector<PluginGroup>* groups); | 222 void AddHardcodedPluginGroups(ScopedVector<PluginGroup>* groups); |
| 234 | 223 |
| 235 // Implements all IO dependant operations of the LoadPlugins method so that | 224 // Implements all IO dependant operations of the LoadPlugins method so that |
| 236 // test classes can mock these out. Return value false means LoadPlugins | 225 // test classes can mock these out. Return value false means LoadPlugins |
| 237 // should not go on with the loading. | 226 // should not go on with the loading. |
| 238 virtual void LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups); | 227 virtual void LoadPluginsInternal(ScopedVector<PluginGroup>* plugin_groups); |
| 239 | 228 |
| 240 // Load all plugins from the default plugins directory | 229 // Load all plugins from the default plugins directory |
| 241 void LoadPlugins(bool refresh); | 230 void LoadPlugins(); |
| 242 | 231 |
| 243 // Load all plugins from a specific directory. | 232 // Load all plugins from a specific directory. |
| 244 // |plugins| is updated with loaded plugin information. | 233 // |plugins| is updated with loaded plugin information. |
| 245 // |visited_plugins| is updated with paths to all plugins that were considered | 234 // |visited_plugins| is updated with paths to all plugins that were considered |
| 246 // (including those we didn't load) | 235 // (including those we didn't load) |
| 247 void LoadPluginsFromDir(const FilePath& path, | 236 void LoadPluginsFromDir(const FilePath& path, |
| 248 ScopedVector<PluginGroup>* plugin_groups, | 237 ScopedVector<PluginGroup>* plugin_groups, |
| 249 std::set<FilePath>* visited_plugins); | 238 std::set<FilePath>* visited_plugins); |
| 250 | 239 |
| 251 // Returns true if we should load the given plugin, or false otherwise. | 240 // Returns true if we should load the given plugin, or false otherwise. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // Set to true if the default plugin is enabled. | 333 // Set to true if the default plugin is enabled. |
| 345 bool default_plugin_enabled_; | 334 bool default_plugin_enabled_; |
| 346 | 335 |
| 347 DISALLOW_COPY_AND_ASSIGN(PluginList); | 336 DISALLOW_COPY_AND_ASSIGN(PluginList); |
| 348 }; | 337 }; |
| 349 | 338 |
| 350 } // namespace npapi | 339 } // namespace npapi |
| 351 } // namespace webkit | 340 } // namespace webkit |
| 352 | 341 |
| 353 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 342 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |
| OLD | NEW |