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> | |
9 #include <set> | 8 #include <set> |
10 #include <string> | 9 #include <string> |
11 #include <vector> | 10 #include <vector> |
12 #include <set> | |
13 | 11 |
14 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
15 #include "base/file_path.h" | 13 #include "base/file_path.h" |
16 #include "base/linked_ptr.h" | 14 #include "base/linked_ptr.h" |
17 #include "base/lock.h" | 15 #include "base/lock.h" |
18 #include "third_party/npapi/bindings/nphostapi.h" | 16 #include "third_party/npapi/bindings/nphostapi.h" |
19 #include "webkit/glue/plugins/plugin_group.h" | 17 #include "webkit/glue/plugins/plugin_group.h" |
20 #include "webkit/glue/plugins/webplugininfo.h" | 18 #include "webkit/glue/plugins/webplugininfo.h" |
21 | 19 |
22 class GURL; | 20 class GURL; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 const std::string& mime_type, | 148 const std::string& mime_type, |
151 bool allow_wildcard, | 149 bool allow_wildcard, |
152 WebPluginInfo* info, | 150 WebPluginInfo* info, |
153 std::string* actual_mime_type); | 151 std::string* actual_mime_type); |
154 | 152 |
155 // Get plugin info by plugin path (including disabled plugins). Returns true | 153 // Get plugin info by plugin path (including disabled plugins). Returns true |
156 // if the plugin is found and WebPluginInfo has been filled in |info|. | 154 // if the plugin is found and WebPluginInfo has been filled in |info|. |
157 bool GetPluginInfoByPath(const FilePath& plugin_path, | 155 bool GetPluginInfoByPath(const FilePath& plugin_path, |
158 WebPluginInfo* info); | 156 WebPluginInfo* info); |
159 | 157 |
160 typedef std::map<std::string, linked_ptr<PluginGroup> > PluginMap; | 158 // Returns a vector with all available plugin groups. |
159 std::vector<PluginGroup> GetPluginGroups(bool load_if_necessary); | |
161 | 160 |
162 // Fill the map from identifier to plugin group for all plugin groups. If | 161 // Returns a copy of the PluginGroup corresponding to the given WebPluginInfo. |
163 // |load_if_necessary| is set, the plugins will be loaded if they haven't | 162 // If no such group exists, it is created and added to the cache. Since the |
164 // already been loaded, or if Refresh() has been called in the meantime; | 163 // returned object is a copy, callers cannot use it to modify the cached |
165 // otherwise a possibly empty or stale list may be returned. | 164 // instance. |
166 void GetPluginGroups(bool load_if_necessary, PluginMap* plugin_groups); | 165 PluginGroup GetPluginGroup(const WebPluginInfo& web_plugin_info); |
Bernhard Bauer
2010/12/03 16:13:28
I think you could return a const pointer instead o
Jakob Kummerow
2010/12/06 18:21:12
Done.
| |
166 | |
167 // Returns the name of the PluginGroup with the given identifier. | |
168 // If no such group exists, an empty string is returned. | |
169 string16 GetPluginGroupName(std::string identifier); | |
Bernhard Bauer
2010/12/03 16:13:28
I think you could also return a const PluginGroup*
Jakob Kummerow
2010/12/06 18:21:12
As discussed offline, we'll leave it as it is for
| |
170 | |
171 // Returns the identifier string of the PluginGroup corresponding to the given | |
172 // WebPluginInfo. If no such group exists, it is created and added to the | |
173 // cache. | |
174 std::string GetPluginGroupIdentifier(const WebPluginInfo& web_plugin_info); | |
167 | 175 |
168 // Load a specific plugin with full path. | 176 // Load a specific plugin with full path. |
169 void LoadPlugin(const FilePath& filename, | 177 void LoadPlugin(const FilePath& filename, |
170 std::vector<WebPluginInfo>* plugins); | 178 std::vector<WebPluginInfo>* plugins); |
171 | 179 |
172 // Enable a specific plugin, specified by path. Returns |true| iff a plugin | 180 // Enable a specific plugin, specified by path. Returns |true| iff a plugin |
173 // currently in the plugin list was actually enabled as a result; regardless | 181 // currently in the plugin list was actually enabled as a result; regardless |
174 // of return value, if a plugin is found in the future with the given name, it | 182 // of return value, if a plugin is found in the future with the given name, it |
175 // will be enabled. Note that plugins are enabled by default as far as | 183 // will be enabled. Note that plugins are enabled by default as far as |
176 // |PluginList| is concerned. | 184 // |PluginList| is concerned. |
(...skipping 17 matching lines...) Expand all Loading... | |
194 // be loaded on a web page and instead show a UI to update to the latest | 202 // be loaded on a web page and instead show a UI to update to the latest |
195 // version. | 203 // version. |
196 void DisableOutdatedPluginGroups(); | 204 void DisableOutdatedPluginGroups(); |
197 | 205 |
198 ~PluginList(); | 206 ~PluginList(); |
199 | 207 |
200 private: | 208 private: |
201 // Constructors are private for singletons | 209 // Constructors are private for singletons |
202 PluginList(); | 210 PluginList(); |
203 | 211 |
212 // Creates PluginGroups for the group definitions in PluginGroup.cc, and adds | |
213 // them to the PluginGroup cache of this PluginList. | |
214 void AddHardcodedPluginGroups(); | |
215 | |
216 // Creates a PluginGroup for the given WebPluginInfo and adds it to the cache. | |
Bernhard Bauer
2010/12/03 16:13:28
// Adds the given WebPluginInfo to its correspondi
Jakob Kummerow
2010/12/06 18:21:12
Done.
| |
217 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); | |
218 | |
204 // Load all plugins from the default plugins directory | 219 // Load all plugins from the default plugins directory |
205 void LoadPlugins(bool refresh); | 220 void LoadPlugins(bool refresh); |
206 | 221 |
207 // Load all plugins from a specific directory. | 222 // Load all plugins from a specific directory. |
208 // |plugins| is updated with loaded plugin information. | 223 // |plugins| is updated with loaded plugin information. |
209 // |visited_plugins| is updated with paths to all plugins that were considered | 224 // |visited_plugins| is updated with paths to all plugins that were considered |
210 // (including those we didn't load) | 225 // (including those we didn't load) |
211 void LoadPluginsFromDir(const FilePath& path, | 226 void LoadPluginsFromDir(const FilePath& path, |
212 std::vector<WebPluginInfo>* plugins, | 227 std::vector<WebPluginInfo>* plugins, |
213 std::set<FilePath>* visited_plugins); | 228 std::set<FilePath>* visited_plugins); |
214 | 229 |
215 // Returns true if we should load the given plugin, or false otherwise. | 230 // Returns true if we should load the given plugin, or false otherwise. |
216 // plugins is the list of plugins we have crawled in the current plugin | 231 // plugins is the list of plugins we have crawled in the current plugin |
217 // loading run. | 232 // loading run. |
218 bool ShouldLoadPlugin(const WebPluginInfo& info, | 233 bool ShouldLoadPlugin(const WebPluginInfo& info, |
219 std::vector<WebPluginInfo>* plugins); | 234 std::vector<WebPluginInfo>* plugins); |
220 | 235 |
221 // Return whether a plug-in group with the given name should be disabled, | 236 // Return whether a plug-in group with the given name should be disabled, |
222 // either because it already is on the list of disabled groups, or because it | 237 // either because it already is on the list of disabled groups, or because it |
223 // is blacklisted by a policy. In the latter case, add the plugin group to the | 238 // is blacklisted by a policy. In the latter case, add the plugin group to the |
224 // list of disabled groups as well. | 239 // list of disabled groups as well. |
225 bool ShouldDisableGroup(const string16& group_name); | 240 bool ShouldDisableGroup(const string16& group_name); |
226 | 241 |
227 // Like GetPluginGroups above, but works on a given vector of plugins. | |
228 static void GetPluginGroups(const std::vector<WebPluginInfo>* plugins, | |
229 PluginMap* plugin_groups); | |
230 | |
231 // Returns true if the given WebPluginInfo supports "mime-type". | 242 // Returns true if the given WebPluginInfo supports "mime-type". |
232 // mime_type should be all lower case. | 243 // mime_type should be all lower case. |
233 static bool SupportsType(const WebPluginInfo& info, | 244 static bool SupportsType(const WebPluginInfo& info, |
234 const std::string &mime_type, | 245 const std::string &mime_type, |
235 bool allow_wildcard); | 246 bool allow_wildcard); |
236 | 247 |
237 // Returns true if the given WebPluginInfo supports a given file extension. | 248 // Returns true if the given WebPluginInfo supports a given file extension. |
238 // extension should be all lower case. | 249 // extension should be all lower case. |
239 // If mime_type is not NULL, it will be set to the mime type if found. | 250 // If mime_type is not NULL, it will be set to the mime type if found. |
240 // The mime type which corresponds to the extension is optionally returned | 251 // The mime type which corresponds to the extension is optionally returned |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 | 295 |
285 // Extra plugin directories that we want to search when loading. | 296 // Extra plugin directories that we want to search when loading. |
286 std::vector<FilePath> extra_plugin_dirs_; | 297 std::vector<FilePath> extra_plugin_dirs_; |
287 | 298 |
288 // Holds information about internal plugins. | 299 // Holds information about internal plugins. |
289 std::vector<PluginVersionInfo> internal_plugins_; | 300 std::vector<PluginVersionInfo> internal_plugins_; |
290 | 301 |
291 // Path names of plugins to disable (the default is to enable them all). | 302 // Path names of plugins to disable (the default is to enable them all). |
292 std::set<FilePath> disabled_plugins_; | 303 std::set<FilePath> disabled_plugins_; |
293 | 304 |
294 // Group names disable (the default is to enable them all). | 305 // Group names to disable (the default is to enable them all). |
295 std::set<string16> disabled_groups_; | 306 std::set<string16> disabled_groups_; |
296 | 307 |
297 bool disable_outdated_plugins_; | 308 bool disable_outdated_plugins_; |
298 | 309 |
310 // Holds the currently available plugin groups. | |
311 PluginGroup::PluginMap plugin_groups_; | |
312 | |
313 int next_priority_; | |
314 | |
299 // Need synchronization for the above members since this object can be | 315 // Need synchronization for the above members since this object can be |
300 // accessed on multiple threads. | 316 // accessed on multiple threads. |
301 Lock lock_; | 317 Lock lock_; |
302 | 318 |
303 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 319 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
304 | 320 |
305 DISALLOW_COPY_AND_ASSIGN(PluginList); | 321 DISALLOW_COPY_AND_ASSIGN(PluginList); |
306 }; | 322 }; |
307 | 323 |
308 } // namespace NPAPI | 324 } // namespace NPAPI |
309 | 325 |
310 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 326 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
OLD | NEW |