Chromium Code Reviews| 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 // Populates the given vector with all available plugin groups. |
| 159 void GetPluginGroups(bool load_if_necessary, | |
| 160 std::vector<PluginGroup>* plugin_groups); | |
| 161 | 161 |
| 162 // Fill the map from identifier to plugin group for all plugin groups. If | 162 // Returns the PluginGroup corresponding to the given WebPluginInfo. If no |
| 163 // |load_if_necessary| is set, the plugins will be loaded if they haven't | 163 // such group exists, it is created and added to the cache. |
| 164 // already been loaded, or if Refresh() has been called in the meantime; | 164 // Beware: when calling this from the Browser prrocess, the group that the |
|
Bernhard Bauer
2010/12/07 10:32:05
Nit: process
Jakob Kummerow
2010/12/07 11:43:08
Done.
| |
| 165 // otherwise a possibly empty or stale list may be returned. | 165 // returned pointer points to might disappear suddenly. |
|
Bernhard Bauer
2010/12/07 10:32:05
Also, please elaborate on under what circumstances
Jakob Kummerow
2010/12/07 11:43:08
Done.
| |
| 166 void GetPluginGroups(bool load_if_necessary, PluginMap* plugin_groups); | 166 const PluginGroup* GetPluginGroup(const WebPluginInfo& web_plugin_info); |
| 167 | |
| 168 // Returns the name of the PluginGroup with the given identifier. | |
| 169 // If no such group exists, an empty string is returned. | |
| 170 string16 GetPluginGroupName(std::string identifier); | |
| 171 | |
| 172 // Returns the identifier string of the PluginGroup corresponding to the given | |
| 173 // WebPluginInfo. If no such group exists, it is created and added to the | |
| 174 // cache. | |
| 175 std::string GetPluginGroupIdentifier(const WebPluginInfo& web_plugin_info); | |
| 167 | 176 |
| 168 // Load a specific plugin with full path. | 177 // Load a specific plugin with full path. |
| 169 void LoadPlugin(const FilePath& filename, | 178 void LoadPlugin(const FilePath& filename, |
| 170 std::vector<WebPluginInfo>* plugins); | 179 std::vector<WebPluginInfo>* plugins); |
| 171 | 180 |
| 172 // Enable a specific plugin, specified by path. Returns |true| iff a plugin | 181 // 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 | 182 // 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 | 183 // 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 | 184 // will be enabled. Note that plugins are enabled by default as far as |
| 176 // |PluginList| is concerned. | 185 // |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 | 203 // be loaded on a web page and instead show a UI to update to the latest |
| 195 // version. | 204 // version. |
| 196 void DisableOutdatedPluginGroups(); | 205 void DisableOutdatedPluginGroups(); |
| 197 | 206 |
| 198 ~PluginList(); | 207 ~PluginList(); |
| 199 | 208 |
| 200 private: | 209 private: |
| 201 // Constructors are private for singletons | 210 // Constructors are private for singletons |
| 202 PluginList(); | 211 PluginList(); |
| 203 | 212 |
| 213 // Creates PluginGroups for the group definitions in PluginGroup.cc, and adds | |
|
Bernhard Bauer
2010/12/07 10:32:05
Nit: The file is called plugin_group.cc.
Jakob Kummerow
2010/12/07 11:43:08
Done.
| |
| 214 // them to the PluginGroup cache of this PluginList. | |
| 215 void AddHardcodedPluginGroups(); | |
| 216 | |
| 217 // Adds the given WebPluginInfo to its corresponding group, creating it if | |
| 218 // necessary, and returns the group. | |
| 219 PluginGroup* AddToPluginGroups(const WebPluginInfo& web_plugin_info); | |
| 220 | |
| 204 // Load all plugins from the default plugins directory | 221 // Load all plugins from the default plugins directory |
| 205 void LoadPlugins(bool refresh); | 222 void LoadPlugins(bool refresh); |
| 206 | 223 |
| 207 // Load all plugins from a specific directory. | 224 // Load all plugins from a specific directory. |
| 208 // |plugins| is updated with loaded plugin information. | 225 // |plugins| is updated with loaded plugin information. |
| 209 // |visited_plugins| is updated with paths to all plugins that were considered | 226 // |visited_plugins| is updated with paths to all plugins that were considered |
| 210 // (including those we didn't load) | 227 // (including those we didn't load) |
| 211 void LoadPluginsFromDir(const FilePath& path, | 228 void LoadPluginsFromDir(const FilePath& path, |
| 212 std::vector<WebPluginInfo>* plugins, | 229 std::vector<WebPluginInfo>* plugins, |
| 213 std::set<FilePath>* visited_plugins); | 230 std::set<FilePath>* visited_plugins); |
| 214 | 231 |
| 215 // Returns true if we should load the given plugin, or false otherwise. | 232 // 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 | 233 // plugins is the list of plugins we have crawled in the current plugin |
| 217 // loading run. | 234 // loading run. |
| 218 bool ShouldLoadPlugin(const WebPluginInfo& info, | 235 bool ShouldLoadPlugin(const WebPluginInfo& info, |
| 219 std::vector<WebPluginInfo>* plugins); | 236 std::vector<WebPluginInfo>* plugins); |
| 220 | 237 |
| 221 // Return whether a plug-in group with the given name should be disabled, | 238 // 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 | 239 // 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 | 240 // is blacklisted by a policy. In the latter case, add the plugin group to the |
| 224 // list of disabled groups as well. | 241 // list of disabled groups as well. |
| 225 bool ShouldDisableGroup(const string16& group_name); | 242 bool ShouldDisableGroup(const string16& group_name); |
| 226 | 243 |
| 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". | 244 // Returns true if the given WebPluginInfo supports "mime-type". |
| 232 // mime_type should be all lower case. | 245 // mime_type should be all lower case. |
| 233 static bool SupportsType(const WebPluginInfo& info, | 246 static bool SupportsType(const WebPluginInfo& info, |
| 234 const std::string &mime_type, | 247 const std::string &mime_type, |
| 235 bool allow_wildcard); | 248 bool allow_wildcard); |
| 236 | 249 |
| 237 // Returns true if the given WebPluginInfo supports a given file extension. | 250 // Returns true if the given WebPluginInfo supports a given file extension. |
| 238 // extension should be all lower case. | 251 // extension should be all lower case. |
| 239 // If mime_type is not NULL, it will be set to the mime type if found. | 252 // 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 | 253 // 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 | 297 |
| 285 // Extra plugin directories that we want to search when loading. | 298 // Extra plugin directories that we want to search when loading. |
| 286 std::vector<FilePath> extra_plugin_dirs_; | 299 std::vector<FilePath> extra_plugin_dirs_; |
| 287 | 300 |
| 288 // Holds information about internal plugins. | 301 // Holds information about internal plugins. |
| 289 std::vector<PluginVersionInfo> internal_plugins_; | 302 std::vector<PluginVersionInfo> internal_plugins_; |
| 290 | 303 |
| 291 // Path names of plugins to disable (the default is to enable them all). | 304 // Path names of plugins to disable (the default is to enable them all). |
| 292 std::set<FilePath> disabled_plugins_; | 305 std::set<FilePath> disabled_plugins_; |
| 293 | 306 |
| 294 // Group names disable (the default is to enable them all). | 307 // Group names to disable (the default is to enable them all). |
| 295 std::set<string16> disabled_groups_; | 308 std::set<string16> disabled_groups_; |
| 296 | 309 |
| 297 bool disable_outdated_plugins_; | 310 bool disable_outdated_plugins_; |
| 298 | 311 |
| 312 // Holds the currently available plugin groups. | |
| 313 PluginGroup::PluginMap plugin_groups_; | |
| 314 | |
| 315 int next_priority_; | |
| 316 | |
| 299 // Need synchronization for the above members since this object can be | 317 // Need synchronization for the above members since this object can be |
| 300 // accessed on multiple threads. | 318 // accessed on multiple threads. |
| 301 Lock lock_; | 319 Lock lock_; |
| 302 | 320 |
| 303 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 321 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
| 304 | 322 |
| 305 DISALLOW_COPY_AND_ASSIGN(PluginList); | 323 DISALLOW_COPY_AND_ASSIGN(PluginList); |
| 306 }; | 324 }; |
| 307 | 325 |
| 308 } // namespace NPAPI | 326 } // namespace NPAPI |
| 309 | 327 |
| 310 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 328 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
| OLD | NEW |