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 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // This second version is for "plugins" that have been compiled directly into | 92 // This second version is for "plugins" that have been compiled directly into |
93 // the binary -- callers must provide the plugin information and the entry | 93 // the binary -- callers must provide the plugin information and the entry |
94 // points. | 94 // points. |
95 void RegisterInternalPluginWithEntryPoints( | 95 void RegisterInternalPluginWithEntryPoints( |
96 const webkit::WebPluginInfo& info, | 96 const webkit::WebPluginInfo& info, |
97 bool add_at_beginning, | 97 bool add_at_beginning, |
98 const PluginEntryPoints& entry_points); | 98 const PluginEntryPoints& entry_points); |
99 | 99 |
100 // Removes a specified internal plugin from the list. The search will match | 100 // Removes a specified internal plugin from the list. The search will match |
101 // on the path from the version info previously registered. | 101 // on the path from the version info previously registered. |
102 // | |
103 // This is generally only necessary for tests. | |
104 void UnregisterInternalPlugin(const base::FilePath& path); | 102 void UnregisterInternalPlugin(const base::FilePath& path); |
105 | 103 |
106 // Gets a list of all the registered internal plugins. | 104 // Gets a list of all the registered internal plugins. |
107 void GetInternalPlugins(std::vector<webkit::WebPluginInfo>* plugins); | 105 void GetInternalPlugins(std::vector<webkit::WebPluginInfo>* plugins); |
108 | 106 |
109 // Creates a WebPluginInfo structure given a plugin's path. On success | 107 // Creates a WebPluginInfo structure given a plugin's path. On success |
110 // returns true, with the information being put into "info". If it's an | 108 // returns true, with the information being put into "info". If it's an |
111 // internal plugin, "entry_points" is filled in as well with a | 109 // internal plugin, "entry_points" is filled in as well with a |
112 // internally-owned PluginEntryPoints pointer. | 110 // internally-owned PluginEntryPoints pointer. |
113 // Returns false if the library couldn't be found, or if it's not a plugin. | 111 // Returns false if the library couldn't be found, or if it's not a plugin. |
114 bool ReadPluginInfo(const base::FilePath& filename, | 112 bool ReadPluginInfo(const base::FilePath& filename, |
115 webkit::WebPluginInfo* info, | 113 webkit::WebPluginInfo* info, |
116 const PluginEntryPoints** entry_points); | 114 const PluginEntryPoints** entry_points); |
117 | 115 |
118 // In Windows plugins, the mime types are passed as a specially formatted list | 116 // In Windows plugins, the mime types are passed as a specially formatted list |
119 // of strings. This function parses those strings into a WebPluginMimeType | 117 // of strings. This function parses those strings into a WebPluginMimeType |
120 // vector. | 118 // vector. |
121 // TODO(evan): move this code into plugin_list_win. | 119 // TODO(evan): move this code into plugin_list_win. |
122 static bool ParseMimeTypes( | 120 static bool ParseMimeTypes( |
123 const std::string& mime_types, | 121 const std::string& mime_types, |
124 const std::string& file_extensions, | 122 const std::string& file_extensions, |
125 const base::string16& mime_type_descriptions, | 123 const base::string16& mime_type_descriptions, |
126 std::vector<webkit::WebPluginMimeType>* parsed_mime_types); | 124 std::vector<webkit::WebPluginMimeType>* parsed_mime_types); |
127 | 125 |
128 // Get all the plugins synchronously, loading them if necessary. | 126 // Get all the plugins synchronously, loading them if necessary. |
129 void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins); | 127 void GetPlugins(std::vector<webkit::WebPluginInfo>* plugins); |
130 | 128 |
131 // Copies the list of plug-ins into |plugins| without loading them. | 129 // Copies the list of plug-ins into |plugins| without loading them. |
132 // Returns true if the list of plugins is up-to-date. | 130 // Returns true if the list of plugins is up-to-date. |
133 virtual bool GetPluginsNoRefresh( | 131 bool GetPluginsNoRefresh( |
134 std::vector<webkit::WebPluginInfo>* plugins); | 132 std::vector<webkit::WebPluginInfo>* plugins); |
135 | 133 |
136 // Returns a list in |info| containing plugins that are found for | 134 // Returns a list in |info| containing plugins that are found for |
137 // the given url and mime type (including disabled plugins, for | 135 // the given url and mime type (including disabled plugins, for |
138 // which |info->enabled| is false). The mime type which corresponds | 136 // which |info->enabled| is false). The mime type which corresponds |
139 // to the URL is optionally returned back in |actual_mime_types| (if | 137 // to the URL is optionally returned back in |actual_mime_types| (if |
140 // it is non-NULL), one for each of the plugin info objects found. | 138 // it is non-NULL), one for each of the plugin info objects found. |
141 // The |allow_wildcard| parameter controls whether this function | 139 // The |allow_wildcard| parameter controls whether this function |
142 // returns plugins which support wildcard mime types (* as the mime | 140 // returns plugins which support wildcard mime types (* as the mime |
143 // type). The |info| parameter is required to be non-NULL. The | 141 // type). The |info| parameter is required to be non-NULL. The |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // This API is only used on Unixes, and is exposed here for testing. | 180 // This API is only used on Unixes, and is exposed here for testing. |
183 static void ParseMIMEDescription(const std::string& description, | 181 static void ParseMIMEDescription(const std::string& description, |
184 std::vector<webkit::WebPluginMimeType>* mime_types); | 182 std::vector<webkit::WebPluginMimeType>* mime_types); |
185 | 183 |
186 // Extract a version number from a description string. | 184 // Extract a version number from a description string. |
187 // This API is only used on Unixes, and is exposed here for testing. | 185 // This API is only used on Unixes, and is exposed here for testing. |
188 static void ExtractVersionString(const std::string& version, | 186 static void ExtractVersionString(const std::string& version, |
189 webkit::WebPluginInfo* info); | 187 webkit::WebPluginInfo* info); |
190 #endif | 188 #endif |
191 | 189 |
192 protected: | |
193 // Constructors are private for singletons but we expose this one | |
194 // for subclasses for test purposes. | |
195 PluginList(); | |
196 | |
197 private: | 190 private: |
198 enum LoadingState { | 191 enum LoadingState { |
199 LOADING_STATE_NEEDS_REFRESH, | 192 LOADING_STATE_NEEDS_REFRESH, |
200 LOADING_STATE_REFRESHING, | 193 LOADING_STATE_REFRESHING, |
201 LOADING_STATE_UP_TO_DATE, | 194 LOADING_STATE_UP_TO_DATE, |
202 }; | 195 }; |
203 | 196 |
204 struct InternalPlugin { | 197 struct InternalPlugin { |
205 webkit::WebPluginInfo info; | 198 webkit::WebPluginInfo info; |
206 PluginEntryPoints entry_points; | 199 PluginEntryPoints entry_points; |
207 }; | 200 }; |
208 | 201 |
209 friend class PluginListTest; | 202 friend class PluginListTest; |
210 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 203 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
211 | 204 |
| 205 PluginList(); |
| 206 |
212 // Implements all IO dependent operations of the LoadPlugins method so that | 207 // Implements all IO dependent operations of the LoadPlugins method so that |
213 // test classes can mock these out. | 208 // test classes can mock these out. |
214 virtual void LoadPluginsIntoPluginListInternal( | 209 virtual void LoadPluginsIntoPluginListInternal( |
215 std::vector<webkit::WebPluginInfo>* plugins); | 210 std::vector<webkit::WebPluginInfo>* plugins); |
216 | 211 |
217 // Load all plugins from the default plugins directory. | 212 // Load all plugins from the default plugins directory. |
218 void LoadPlugins(); | 213 void LoadPlugins(); |
219 | 214 |
220 // Walks a directory and produces a list of all the plugins to potentially | 215 // Walks a directory and produces a list of all the plugins to potentially |
221 // load in that directory. | 216 // load in that directory. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // in common places. | 273 // in common places. |
279 bool plugins_discovery_disabled_; | 274 bool plugins_discovery_disabled_; |
280 | 275 |
281 DISALLOW_COPY_AND_ASSIGN(PluginList); | 276 DISALLOW_COPY_AND_ASSIGN(PluginList); |
282 }; | 277 }; |
283 | 278 |
284 } // namespace npapi | 279 } // namespace npapi |
285 } // namespace webkit | 280 } // namespace webkit |
286 | 281 |
287 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 282 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |
OLD | NEW |