| 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_GROUP_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ |
| 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 | 18 |
| 19 class DictionaryValue; | 19 class DictionaryValue; |
| 20 class FilePath; | 20 class FilePath; |
| 21 class Version; | 21 class Version; |
| 22 struct WebPluginInfo; | 22 struct WebPluginInfo; |
| 23 | 23 |
| 24 namespace NPAPI { | 24 namespace NPAPI { |
| 25 class PluginList; | 25 class PluginList; |
| 26 }; | 26 }; |
| 27 namespace plugin_test_internal { |
| 28 class TestablePluginList; |
| 29 } |
| 27 | 30 |
| 28 // Hard-coded version ranges for plugin groups. | 31 // Hard-coded version ranges for plugin groups. |
| 29 struct VersionRangeDefinition { | 32 struct VersionRangeDefinition { |
| 30 // Matcher for lowest version matched by this range (inclusive). May be empty | 33 // Matcher for lowest version matched by this range (inclusive). May be empty |
| 31 // to match everything iff |version_matcher_high| is also empty. | 34 // to match everything iff |version_matcher_high| is also empty. |
| 32 const char* version_matcher_low; | 35 const char* version_matcher_low; |
| 33 // Matcher for highest version matched by this range (exclusive). May be empty | 36 // Matcher for highest version matched by this range (exclusive). May be empty |
| 34 // to match anything higher than |version_matcher_low|. | 37 // to match anything higher than |version_matcher_low|. |
| 35 const char* version_matcher_high; | 38 const char* version_matcher_high; |
| 36 const char* min_version; // Minimum secure version. | 39 const char* min_version; // Minimum secure version. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // Retuns true if plugin has been added and false if it was already added. | 106 // Retuns true if plugin has been added and false if it was already added. |
| 104 WebPluginInfo* AddPlugin(const WebPluginInfo& plugin, int position); | 107 WebPluginInfo* AddPlugin(const WebPluginInfo& plugin, int position); |
| 105 | 108 |
| 106 // Returns a poitner to the plugin at the end of the |web_plugin_infos_| | 109 // Returns a poitner to the plugin at the end of the |web_plugin_infos_| |
| 107 // array. | 110 // array. |
| 108 std::list<WebPluginInfo>& GetPlugins(); | 111 std::list<WebPluginInfo>& GetPlugins(); |
| 109 | 112 |
| 110 // Returns the positions of the plugins in the group. | 113 // Returns the positions of the plugins in the group. |
| 111 std::vector<int>& GetPluginPositions(); | 114 std::vector<int>& GetPluginPositions(); |
| 112 | 115 |
| 116 bool IsEmpty(); |
| 117 |
| 113 // Enables/disables this group. This enables/disables all plugins in the | 118 // Enables/disables this group. This enables/disables all plugins in the |
| 114 // group. | 119 // group. |
| 115 void Enable(bool enable); | 120 void Enable(bool enable); |
| 116 | 121 |
| 117 // Refreshes the enabled flag based on the state of its plugins. | 122 // Refreshes the enabled flag based on the state of its plugins. |
| 118 void RefreshEnabledState(); | 123 void RefreshEnabledState(); |
| 119 | 124 |
| 120 // Returns whether the plugin group is enabled or not. | 125 // Returns whether the plugin group is enabled or not. |
| 121 bool Enabled() const { return enabled_; } | 126 bool Enabled() const { return enabled_; } |
| 122 | 127 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 145 bool IsVulnerable() const; | 150 bool IsVulnerable() const; |
| 146 | 151 |
| 147 // Disables all plugins in this group that are older than the | 152 // Disables all plugins in this group that are older than the |
| 148 // minimum version. | 153 // minimum version. |
| 149 void DisableOutdatedPlugins(); | 154 void DisableOutdatedPlugins(); |
| 150 | 155 |
| 151 private: | 156 private: |
| 152 typedef std::map<std::string, PluginGroup*> PluginMap; | 157 typedef std::map<std::string, PluginGroup*> PluginMap; |
| 153 | 158 |
| 154 friend class NPAPI::PluginList; | 159 friend class NPAPI::PluginList; |
| 160 friend class plugin_test_internal::TestablePluginList; |
| 155 friend class PluginGroupTest; | 161 friend class PluginGroupTest; |
| 156 friend class TableModelArrayControllerTest; | 162 friend class TableModelArrayControllerTest; |
| 157 friend class PluginExceptionsTableModelTest; | 163 friend class PluginExceptionsTableModelTest; |
| 158 | 164 |
| 159 // Generates the (short) identifier string for the given plugin. | 165 // Generates the (short) identifier string for the given plugin. |
| 160 static std::string GetIdentifier(const WebPluginInfo& wpi); | 166 static std::string GetIdentifier(const WebPluginInfo& wpi); |
| 161 | 167 |
| 162 // Generates the long identifier (based on the full file path) for the given | 168 // Generates the long identifier (based on the full file path) for the given |
| 163 // plugin, to be called when the short identifier is not unique. | 169 // plugin, to be called when the short identifier is not unique. |
| 164 static std::string GetLongIdentifier(const WebPluginInfo& wpi); | 170 static std::string GetLongIdentifier(const WebPluginInfo& wpi); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 191 Version* CreateVersionFromString(const string16& version_string); | 197 Version* CreateVersionFromString(const string16& version_string); |
| 192 | 198 |
| 193 // Set the description and version for this plugin group from the | 199 // Set the description and version for this plugin group from the |
| 194 // given plug-in. | 200 // given plug-in. |
| 195 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); | 201 void UpdateDescriptionAndVersion(const WebPluginInfo& plugin); |
| 196 | 202 |
| 197 // Updates the active plugin in the group. The active plugin is the first | 203 // Updates the active plugin in the group. The active plugin is the first |
| 198 // enabled one, or if all plugins are disabled, simply the first one. | 204 // enabled one, or if all plugins are disabled, simply the first one. |
| 199 void UpdateActivePlugin(const WebPluginInfo& plugin); | 205 void UpdateActivePlugin(const WebPluginInfo& plugin); |
| 200 | 206 |
| 207 // Used by tests to override the default PluginList singleton. |
| 208 NPAPI::PluginList* GetPluginList(); |
| 209 |
| 201 static std::set<string16>* policy_disabled_plugin_patterns_; | 210 static std::set<string16>* policy_disabled_plugin_patterns_; |
| 202 | 211 |
| 203 std::string identifier_; | 212 std::string identifier_; |
| 204 string16 group_name_; | 213 string16 group_name_; |
| 205 string16 name_matcher_; | 214 string16 name_matcher_; |
| 206 string16 description_; | 215 string16 description_; |
| 207 std::string update_url_; | 216 std::string update_url_; |
| 208 bool enabled_; | 217 bool enabled_; |
| 209 std::vector<VersionRange> version_ranges_; | 218 std::vector<VersionRange> version_ranges_; |
| 210 scoped_ptr<Version> version_; | 219 scoped_ptr<Version> version_; |
| 211 std::list<WebPluginInfo> web_plugin_infos_; | 220 std::list<WebPluginInfo> web_plugin_infos_; |
| 212 std::vector<int> web_plugin_positions_; | 221 std::vector<int> web_plugin_positions_; |
| 222 NPAPI::PluginList* plugin_list_; |
| 213 }; | 223 }; |
| 214 | 224 |
| 215 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ | 225 #endif // WEBKIT_GLUE_PLUGINS_PLUGIN_GROUP_H_ |
| OLD | NEW |