| 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 <set> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 #include <set> | 11 #include <set> |
| 11 | 12 |
| 12 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 13 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 14 #include "base/lock.h" | 15 #include "base/lock.h" |
| 15 #include "third_party/npapi/bindings/nphostapi.h" | 16 #include "third_party/npapi/bindings/nphostapi.h" |
| 16 #include "webkit/glue/webplugininfo.h" | 17 #include "webkit/glue/webplugininfo.h" |
| 17 | 18 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 WebPluginInfo* info, | 108 WebPluginInfo* info, |
| 108 const PluginEntryPoints** entry_points); | 109 const PluginEntryPoints** entry_points); |
| 109 | 110 |
| 110 // Populate a WebPluginInfo from a PluginVersionInfo. | 111 // Populate a WebPluginInfo from a PluginVersionInfo. |
| 111 static bool CreateWebPluginInfo(const PluginVersionInfo& pvi, | 112 static bool CreateWebPluginInfo(const PluginVersionInfo& pvi, |
| 112 WebPluginInfo* info); | 113 WebPluginInfo* info); |
| 113 | 114 |
| 114 // Shutdown all plugins. Should be called at process teardown. | 115 // Shutdown all plugins. Should be called at process teardown. |
| 115 void Shutdown(); | 116 void Shutdown(); |
| 116 | 117 |
| 117 // Get all the plugins | 118 // Get all the plugins. |
| 118 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); | 119 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); |
| 119 | 120 |
| 121 // Get all the enabled plugins. |
| 122 void GetEnabledPlugins(bool refresh, std::vector<WebPluginInfo>* plugins); |
| 123 |
| 120 // Returns true if a plugin is found for the given url and mime type. | 124 // Returns true if a plugin is found for the given url and mime type. |
| 121 // The mime type which corresponds to the URL is optionally returned | 125 // The mime type which corresponds to the URL is optionally returned |
| 122 // back. | 126 // back. |
| 123 // The allow_wildcard parameter controls whether this function returns | 127 // The allow_wildcard parameter controls whether this function returns |
| 124 // plugins which support wildcard mime types (* as the mime type). | 128 // plugins which support wildcard mime types (* as the mime type). |
| 125 bool GetPluginInfo(const GURL& url, | 129 bool GetPluginInfo(const GURL& url, |
| 126 const std::string& mime_type, | 130 const std::string& mime_type, |
| 127 bool allow_wildcard, | 131 bool allow_wildcard, |
| 128 WebPluginInfo* info, | 132 WebPluginInfo* info, |
| 129 std::string* actual_mime_type); | 133 std::string* actual_mime_type); |
| 130 | 134 |
| 131 // Get plugin info by plugin path. Returns true if the plugin is found and | 135 // Get plugin info by plugin path. Returns true if the plugin is found and |
| 132 // WebPluginInfo has been filled in |info|. | 136 // WebPluginInfo has been filled in |info|. |
| 133 bool GetPluginInfoByPath(const FilePath& plugin_path, | 137 bool GetPluginInfoByPath(const FilePath& plugin_path, |
| 134 WebPluginInfo* info); | 138 WebPluginInfo* info); |
| 135 | 139 |
| 136 // Load a specific plugin with full path. | 140 // Load a specific plugin with full path. |
| 137 void LoadPlugin(const FilePath& filename, | 141 void LoadPlugin(const FilePath& filename, |
| 138 std::vector<WebPluginInfo>* plugins); | 142 std::vector<WebPluginInfo>* plugins); |
| 139 | 143 |
| 144 // Enable a specific plugin, specified by path. Returns |true| iff a plugin |
| 145 // currently in the plugin list was actually enabled as a result; regardless |
| 146 // of return value, if a plugin is found in the future with the given name, it |
| 147 // will be enabled. Note that plugins are enabled by default as far as |
| 148 // |PluginList| is concerned. |
| 149 bool EnablePlugin(const FilePath& filename); |
| 150 |
| 151 // Disable a specific plugin, specified by path. Returns |true| iff a plugin |
| 152 // currently in the plugin list was actually disabled as a result; regardless |
| 153 // of return value, if a plugin is found in the future with the given name, it |
| 154 // will be disabled. |
| 155 bool DisablePlugin(const FilePath& filename); |
| 156 |
| 140 private: | 157 private: |
| 141 // Constructors are private for singletons | 158 // Constructors are private for singletons |
| 142 PluginList(); | 159 PluginList(); |
| 143 | 160 |
| 144 // Load all plugins from the default plugins directory | 161 // Load all plugins from the default plugins directory |
| 145 void LoadPlugins(bool refresh); | 162 void LoadPlugins(bool refresh); |
| 146 | 163 |
| 147 // Load all plugins from a specific directory. | 164 // Load all plugins from a specific directory. |
| 148 // |plugins| is updated with loaded plugin information. | 165 // |plugins| is updated with loaded plugin information. |
| 149 // |visited_plugins| is updated with paths to all plugins that were considered | 166 // |visited_plugins| is updated with paths to all plugins that were considered |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 232 |
| 216 // Extra plugin paths that we want to search when loading. | 233 // Extra plugin paths that we want to search when loading. |
| 217 std::vector<FilePath> extra_plugin_paths_; | 234 std::vector<FilePath> extra_plugin_paths_; |
| 218 | 235 |
| 219 // Extra plugin directories that we want to search when loading. | 236 // Extra plugin directories that we want to search when loading. |
| 220 std::vector<FilePath> extra_plugin_dirs_; | 237 std::vector<FilePath> extra_plugin_dirs_; |
| 221 | 238 |
| 222 // Holds information about internal plugins. | 239 // Holds information about internal plugins. |
| 223 std::vector<PluginVersionInfo> internal_plugins_; | 240 std::vector<PluginVersionInfo> internal_plugins_; |
| 224 | 241 |
| 242 // Path names of plugins to disable (the default is to enable them all). |
| 243 std::set<FilePath> disabled_plugins_; |
| 244 |
| 225 // Need synchronization for the above members since this object can be | 245 // Need synchronization for the above members since this object can be |
| 226 // accessed on multiple threads. | 246 // accessed on multiple threads. |
| 227 Lock lock_; | 247 Lock lock_; |
| 228 | 248 |
| 229 friend struct base::DefaultLazyInstanceTraits<PluginList>; | 249 friend struct base::DefaultLazyInstanceTraits<PluginList>; |
| 230 | 250 |
| 231 DISALLOW_COPY_AND_ASSIGN(PluginList); | 251 DISALLOW_COPY_AND_ASSIGN(PluginList); |
| 232 }; | 252 }; |
| 233 | 253 |
| 234 } // namespace NPAPI | 254 } // namespace NPAPI |
| 235 | 255 |
| 236 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ | 256 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_LIST_H_ |
| OLD | NEW |