| 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 #ifndef CONTENT_COMMON_PLUGIN_LIST_H_ | 5 #ifndef CONTENT_COMMON_PLUGIN_LIST_H_ |
| 6 #define CONTENT_COMMON_PLUGIN_LIST_H_ | 6 #define CONTENT_COMMON_PLUGIN_LIST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // of strings. This function parses those strings into a WebPluginMimeType | 92 // of strings. This function parses those strings into a WebPluginMimeType |
| 93 // vector. | 93 // vector. |
| 94 // TODO(evan): move this code into plugin_list_win. | 94 // TODO(evan): move this code into plugin_list_win. |
| 95 static bool ParseMimeTypes( | 95 static bool ParseMimeTypes( |
| 96 const std::string& mime_types, | 96 const std::string& mime_types, |
| 97 const std::string& file_extensions, | 97 const std::string& file_extensions, |
| 98 const base::string16& mime_type_descriptions, | 98 const base::string16& mime_type_descriptions, |
| 99 std::vector<webkit::WebPluginMimeType>* parsed_mime_types); | 99 std::vector<webkit::WebPluginMimeType>* parsed_mime_types); |
| 100 | 100 |
| 101 // Get all the plugins synchronously, loading them if necessary. | 101 // Get all the plugins synchronously, loading them if necessary. |
| 102 void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins); | 102 void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins, |
| 103 bool include_npapi); |
| 103 | 104 |
| 104 // Copies the list of plug-ins into |plugins| without loading them. | 105 // Copies the list of plug-ins into |plugins| without loading them. |
| 105 // Returns true if the list of plugins is up-to-date. | 106 // Returns true if the list of plugins is up-to-date. |
| 106 bool GetPluginsNoRefresh( | 107 bool GetPluginsNoRefresh( |
| 107 std::vector<webkit::WebPluginInfo>* plugins); | 108 std::vector<webkit::WebPluginInfo>* plugins); |
| 108 | 109 |
| 109 // Returns a list in |info| containing plugins that are found for | 110 // Returns a list in |info| containing plugins that are found for |
| 110 // the given url and mime type (including disabled plugins, for | 111 // the given url and mime type (including disabled plugins, for |
| 111 // which |info->enabled| is false). The mime type which corresponds | 112 // which |info->enabled| is false). The mime type which corresponds |
| 112 // to the URL is optionally returned back in |actual_mime_types| (if | 113 // to the URL is optionally returned back in |actual_mime_types| (if |
| 113 // it is non-NULL), one for each of the plugin info objects found. | 114 // it is non-NULL), one for each of the plugin info objects found. |
| 114 // The |allow_wildcard| parameter controls whether this function | 115 // The |allow_wildcard| parameter controls whether this function |
| 115 // returns plugins which support wildcard mime types (* as the mime | 116 // returns plugins which support wildcard mime types (* as the mime |
| 116 // type). The |info| parameter is required to be non-NULL. The | 117 // type). The |info| parameter is required to be non-NULL. The |
| 117 // list is in order of "most desirable" to "least desirable". | 118 // list is in order of "most desirable" to "least desirable". |
| 118 // If |use_stale| is NULL, this will load the plug-in list if necessary. | 119 // If |use_stale| is NULL, this will load the plug-in list if necessary. |
| 119 // If it is not NULL, the plug-in list will not be loaded, and |*use_stale| | 120 // If it is not NULL, the plug-in list will not be loaded, and |*use_stale| |
| 120 // will be true iff the plug-in list was stale. | 121 // will be true iff the plug-in list was stale. |
| 121 void GetPluginInfoArray(const GURL& url, | 122 void GetPluginInfoArray(const GURL& url, |
| 122 const std::string& mime_type, | 123 const std::string& mime_type, |
| 123 bool allow_wildcard, | 124 bool allow_wildcard, |
| 124 bool* use_stale, | 125 bool* use_stale, |
| 126 bool include_npapi, |
| 125 std::vector<webkit::WebPluginInfo>* info, | 127 std::vector<webkit::WebPluginInfo>* info, |
| 126 std::vector<std::string>* actual_mime_types); | 128 std::vector<std::string>* actual_mime_types); |
| 127 | 129 |
| 128 // Load a specific plugin with full path. Return true iff loading the plug-in | 130 // Load a specific plugin with full path. Return true iff loading the plug-in |
| 129 // was successful. | 131 // was successful. |
| 130 bool LoadPluginIntoPluginList(const base::FilePath& filename, | 132 bool LoadPluginIntoPluginList(const base::FilePath& filename, |
| 131 std::vector<webkit::WebPluginInfo>* plugins, | 133 std::vector<webkit::WebPluginInfo>* plugins, |
| 132 webkit::WebPluginInfo* plugin_info); | 134 webkit::WebPluginInfo* plugin_info); |
| 133 | 135 |
| 134 // The following functions are used to support probing for WebPluginInfo | 136 // The following functions are used to support probing for WebPluginInfo |
| 135 // using a different instance of this class. | 137 // using a different instance of this class. |
| 136 | 138 |
| 137 // Computes a list of all plugins to potentially load from all sources. | 139 // Computes a list of all plugins to potentially load from all sources. |
| 138 void GetPluginPathsToLoad(std::vector<base::FilePath>* plugin_paths); | 140 void GetPluginPathsToLoad(std::vector<base::FilePath>* plugin_paths, |
| 141 bool include_npapi); |
| 139 | 142 |
| 140 // Clears the internal list of Plugins and copies them from the vector. | 143 // Clears the internal list of Plugins and copies them from the vector. |
| 141 void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins); | 144 void SetPlugins(const std::vector<webkit::WebPluginInfo>& plugins); |
| 142 | 145 |
| 143 void set_will_load_plugins_callback(const base::Closure& callback); | 146 void set_will_load_plugins_callback(const base::Closure& callback); |
| 144 | 147 |
| 145 virtual ~PluginList(); | 148 virtual ~PluginList(); |
| 146 | 149 |
| 147 // Creates a WebPluginInfo structure given a plugin's path. On success | 150 // Creates a WebPluginInfo structure given a plugin's path. On success |
| 148 // returns true, with the information being put into "info". | 151 // returns true, with the information being put into "info". |
| (...skipping 18 matching lines...) Expand all Loading... |
| 167 LOADING_STATE_NEEDS_REFRESH, | 170 LOADING_STATE_NEEDS_REFRESH, |
| 168 LOADING_STATE_REFRESHING, | 171 LOADING_STATE_REFRESHING, |
| 169 LOADING_STATE_UP_TO_DATE, | 172 LOADING_STATE_UP_TO_DATE, |
| 170 }; | 173 }; |
| 171 | 174 |
| 172 friend class PluginListTest; | 175 friend class PluginListTest; |
| 173 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 176 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
| 174 | 177 |
| 175 PluginList(); | 178 PluginList(); |
| 176 | 179 |
| 177 // Implements all IO dependent operations of the LoadPlugins method so that | |
| 178 // test classes can mock these out. | |
| 179 virtual void LoadPluginsIntoPluginListInternal( | |
| 180 std::vector<webkit::WebPluginInfo>* plugins); | |
| 181 | |
| 182 // Load all plugins from the default plugins directory. | 180 // Load all plugins from the default plugins directory. |
| 183 void LoadPlugins(); | 181 void LoadPlugins(bool include_npapi); |
| 184 | 182 |
| 185 // Walks a directory and produces a list of all the plugins to potentially | 183 // Walks a directory and produces a list of all the plugins to potentially |
| 186 // load in that directory. | 184 // load in that directory. |
| 187 void GetPluginsInDir(const base::FilePath& path, | 185 void GetPluginsInDir(const base::FilePath& path, |
| 188 std::vector<base::FilePath>* plugins); | 186 std::vector<base::FilePath>* plugins); |
| 189 | 187 |
| 190 // Returns true if we should load the given plugin, or false otherwise. | 188 // Returns true if we should load the given plugin, or false otherwise. |
| 191 // |plugins| is the list of plugins we have crawled in the current plugin | 189 // |plugins| is the list of plugins we have crawled in the current plugin |
| 192 // loading run. | 190 // loading run. |
| 193 bool ShouldLoadPluginUsingPluginList( | 191 bool ShouldLoadPluginUsingPluginList( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // Flag indicating whether third_party plugins will be searched for | 240 // Flag indicating whether third_party plugins will be searched for |
| 243 // in common places. | 241 // in common places. |
| 244 bool plugins_discovery_disabled_; | 242 bool plugins_discovery_disabled_; |
| 245 | 243 |
| 246 DISALLOW_COPY_AND_ASSIGN(PluginList); | 244 DISALLOW_COPY_AND_ASSIGN(PluginList); |
| 247 }; | 245 }; |
| 248 | 246 |
| 249 } // namespace content | 247 } // namespace content |
| 250 | 248 |
| 251 #endif // CONTENT_COMMON_PLUGIN_LIST_H_ | 249 #endif // CONTENT_COMMON_PLUGIN_LIST_H_ |
| OLD | NEW |