OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 // Get plugin info by plugin path (including disabled plugins). Returns true | 144 // Get plugin info by plugin path (including disabled plugins). Returns true |
145 // if the plugin is found and WebPluginInfo has been filled in |info|. | 145 // if the plugin is found and WebPluginInfo has been filled in |info|. |
146 bool GetPluginInfoByPath(const FilePath& plugin_path, | 146 bool GetPluginInfoByPath(const FilePath& plugin_path, |
147 webkit::WebPluginInfo* info); | 147 webkit::WebPluginInfo* info); |
148 | 148 |
149 // Populates the given vector with all available plugin groups. | 149 // Populates the given vector with all available plugin groups. |
150 void GetPluginGroups(bool load_if_necessary, | 150 void GetPluginGroups(bool load_if_necessary, |
151 std::vector<PluginGroup>* plugin_groups); | 151 std::vector<PluginGroup>* plugin_groups); |
152 | 152 |
153 // Returns the PluginGroup corresponding to the given WebPluginInfo. If no | 153 // Returns a copy of the PluginGroup corresponding to the given WebPluginInfo. |
154 // such group exists, it is created and added to the cache. | 154 // If no such group exists, it is created and added to the cache. |
155 // Beware: when calling this from the Browser process, the group that the | 155 // The caller takes ownership of the returned PluginGroup. |
156 // returned pointer points to might disappear suddenly. This happens when | 156 PluginGroup* GetPluginGroup(const webkit::WebPluginInfo& web_plugin_info); |
157 // |RefreshPlugins()| is called and then |LoadPlugins()| is triggered by a | |
158 // call to |GetPlugins()|, |GetEnabledPlugins()|, |GetPluginInfoArray()|, | |
159 // |GetPluginInfoByPath()|, or |GetPluginGroups(true, _)|. It is the caller's | |
160 // responsibility to make sure this doesn't happen. | |
161 const PluginGroup* GetPluginGroup( | |
162 const webkit::WebPluginInfo& web_plugin_info); | |
163 | 157 |
164 // Returns the name of the PluginGroup with the given identifier. | 158 // Returns the name of the PluginGroup with the given identifier. |
165 // If no such group exists, an empty string is returned. | 159 // If no such group exists, an empty string is returned. |
166 string16 GetPluginGroupName(const std::string& identifier); | 160 string16 GetPluginGroupName(const std::string& identifier); |
167 | 161 |
168 // Returns the identifier string of the PluginGroup corresponding to the given | 162 // Returns the identifier string of the PluginGroup corresponding to the given |
169 // WebPluginInfo. If no such group exists, it is created and added to the | 163 // WebPluginInfo. If no such group exists, it is created and added to the |
170 // cache. | 164 // cache. |
171 std::string GetPluginGroupIdentifier( | 165 std::string GetPluginGroupIdentifier( |
172 const webkit::WebPluginInfo& web_plugin_info); | 166 const webkit::WebPluginInfo& web_plugin_info); |
173 | 167 |
174 // Load a specific plugin with full path. | 168 // Load a specific plugin with full path. |
175 void LoadPlugin(const FilePath& filename, | 169 void LoadPlugin(const FilePath& filename, |
176 ScopedVector<PluginGroup>* plugin_groups); | 170 ScopedVector<PluginGroup>* plugin_groups); |
177 | 171 |
178 // Enable a specific plugin, specified by path. Returns |true| iff a plugin | |
179 // currently in the plugin list was actually enabled as a result; regardless | |
180 // of return value, if a plugin is found in the future with the given name, it | |
181 // will be enabled. | |
182 bool EnablePlugin(const FilePath& filename); | |
183 | |
184 // Disable a specific plugin, specified by path. Returns |true| iff a plugin | |
185 // currently in the plugin list was actually disabled as a result; regardless | |
186 // of return value, if a plugin is found in the future with the given name, it | |
187 // will be disabled. | |
188 bool DisablePlugin(const FilePath& filename); | |
189 | |
190 // Enable/disable a plugin group, specified by group_name. Returns |true| iff | |
191 // a plugin currently in the plugin list was actually enabled/disabled as a | |
192 // result; regardless of return value, if a plugin is found in the future with | |
193 // the given name, it will be enabled/disabled. | |
194 bool EnableGroup(bool enable, const string16& name); | |
195 | |
196 virtual ~PluginList(); | 172 virtual ~PluginList(); |
197 | 173 |
198 protected: | 174 protected: |
199 // This constructor is used in unit tests to override the platform-dependent | 175 // This constructor is used in unit tests to override the platform-dependent |
200 // real-world plugin group definitions with custom ones. | 176 // real-world plugin group definitions with custom ones. |
201 PluginList(const PluginGroupDefinition* definitions, size_t num_definitions); | 177 PluginList(const PluginGroupDefinition* definitions, size_t num_definitions); |
202 | 178 |
203 // Adds the given WebPluginInfo to its corresponding group, creating it if | 179 // Adds the given WebPluginInfo to its corresponding group, creating it if |
204 // necessary, and returns the group. | 180 // necessary, and returns the group. |
205 // Callers need to protect calls to this method by a lock themselves. | 181 // Callers need to protect calls to this method by a lock themselves. |
(...skipping 27 matching lines...) Expand all Loading... |
233 void LoadPluginsFromDir(const FilePath& path, | 209 void LoadPluginsFromDir(const FilePath& path, |
234 ScopedVector<PluginGroup>* plugin_groups, | 210 ScopedVector<PluginGroup>* plugin_groups, |
235 std::set<FilePath>* visited_plugins); | 211 std::set<FilePath>* visited_plugins); |
236 | 212 |
237 // Returns true if we should load the given plugin, or false otherwise. | 213 // Returns true if we should load the given plugin, or false otherwise. |
238 // plugins is the list of plugins we have crawled in the current plugin | 214 // plugins is the list of plugins we have crawled in the current plugin |
239 // loading run. | 215 // loading run. |
240 bool ShouldLoadPlugin(const webkit::WebPluginInfo& info, | 216 bool ShouldLoadPlugin(const webkit::WebPluginInfo& info, |
241 ScopedVector<PluginGroup>* plugins); | 217 ScopedVector<PluginGroup>* plugins); |
242 | 218 |
243 // Return whether a plug-in group with the given name should be disabled, | |
244 // either because it already is on the list of disabled groups, or because it | |
245 // is blacklisted by a policy. In the latter case, add the plugin group to the | |
246 // list of disabled groups as well. | |
247 bool ShouldDisableGroup(const string16& group_name); | |
248 | |
249 // Returns true if the plugin supports |mime_type|. |mime_type| should be all | 219 // Returns true if the plugin supports |mime_type|. |mime_type| should be all |
250 // lower case. | 220 // lower case. |
251 bool SupportsType(const webkit::WebPluginInfo& plugin, | 221 bool SupportsType(const webkit::WebPluginInfo& plugin, |
252 const std::string& mime_type, | 222 const std::string& mime_type, |
253 bool allow_wildcard); | 223 bool allow_wildcard); |
254 | 224 |
255 // Returns true if the given plugin supports a given file extension. | 225 // Returns true if the given plugin supports a given file extension. |
256 // |extension| should be all lower case. If |mime_type| is not NULL, it will | 226 // |extension| should be all lower case. If |mime_type| is not NULL, it will |
257 // be set to the MIME type if found. The MIME type which corresponds to the | 227 // be set to the MIME type if found. The MIME type which corresponds to the |
258 // extension is optionally returned back. | 228 // extension is optionally returned back. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // Holds information about internal plugins. | 271 // Holds information about internal plugins. |
302 std::vector<InternalPlugin> internal_plugins_; | 272 std::vector<InternalPlugin> internal_plugins_; |
303 | 273 |
304 // Hardcoded plugin group definitions. | 274 // Hardcoded plugin group definitions. |
305 const PluginGroupDefinition* const group_definitions_; | 275 const PluginGroupDefinition* const group_definitions_; |
306 const size_t num_group_definitions_; | 276 const size_t num_group_definitions_; |
307 | 277 |
308 // Holds the currently available plugin groups. | 278 // Holds the currently available plugin groups. |
309 ScopedVector<PluginGroup> plugin_groups_; | 279 ScopedVector<PluginGroup> plugin_groups_; |
310 | 280 |
311 // The set of plugins that have been scheduled for disabling once they get | |
312 // loaded. This list is used in LoadPlugins and pruned after it. Contains | |
313 // plugins that were either disabled by the user (prefs are loaded before | |
314 // plugins) or disabled by a policy. | |
315 std::set<FilePath> plugins_to_disable_; | |
316 // Equivalent to the |plugins_to_disable_| this is the set of groups | |
317 // scheduled for disabling once they appear. This list is never completely | |
318 // pruned but all groups that do get created are removed from it. New groups | |
319 // might get added if they should be pruned because of plugins getting removed | |
320 // for example. | |
321 std::set<string16> groups_to_disable_; | |
322 | |
323 // Need synchronization for the above members since this object can be | 281 // Need synchronization for the above members since this object can be |
324 // accessed on multiple threads. | 282 // accessed on multiple threads. |
325 base::Lock lock_; | 283 base::Lock lock_; |
326 | 284 |
327 // Set to true if the default plugin is enabled. | 285 // Set to true if the default plugin is enabled. |
328 bool default_plugin_enabled_; | 286 bool default_plugin_enabled_; |
329 | 287 |
330 DISALLOW_COPY_AND_ASSIGN(PluginList); | 288 DISALLOW_COPY_AND_ASSIGN(PluginList); |
331 }; | 289 }; |
332 | 290 |
333 } // namespace npapi | 291 } // namespace npapi |
334 } // namespace webkit | 292 } // namespace webkit |
335 | 293 |
336 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ | 294 #endif // WEBKIT_PLUGINS_NPAPI_PLUGIN_LIST_H_ |
OLD | NEW |