OLD | NEW |
1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_PLUGIN_UPDATER_H_ | 5 #ifndef CHROME_BROWSER_PLUGIN_UPDATER_H_ |
6 #define CHROME_BROWSER_PLUGIN_UPDATER_H_ | 6 #define CHROME_BROWSER_PLUGIN_UPDATER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
| 9 |
9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/file_path.h" |
10 #include "base/linked_ptr.h" | 12 #include "base/linked_ptr.h" |
11 #include "base/scoped_ptr.h" | |
12 #include "base/singleton.h" | 13 #include "base/singleton.h" |
13 #include "base/string16.h" | |
14 #include "base/values.h" | |
15 #include "googleurl/src/gurl.h" | |
16 #include "webkit/glue/plugins/webplugininfo.h" | |
17 | 14 |
18 class Version; | 15 class ListValue; |
19 class Profile; | 16 class Profile; |
20 | 17 |
21 // Hard-coded definitions of plugin groups. | 18 namespace plugin_updater { |
22 typedef struct { | |
23 const char* const name; // Name of this group. | |
24 const char* const name_matcher; // Substring matcher for the plugin name. | |
25 const char* const version_matcher_low; // Matchers for the plugin version. | |
26 const char* const version_matcher_high; | |
27 const char* const min_version; // Minimum secure version. | |
28 const char* const update_url; // Location of latest secure version. | |
29 } PluginGroupDefinition; | |
30 | 19 |
| 20 // Get a list of all the Plugin groups. |
| 21 ListValue* GetPluginGroupsData(); |
31 | 22 |
32 // A PluginGroup contains at least one WebPluginInfo. | 23 // Enable or disable a plugin group. |
33 // In addition, it knows if the plugin is critically vulnerable. | 24 void EnablePluginGroup(bool enable, const string16& group_name); |
34 class PluginGroup { | |
35 public: | |
36 // Creates a PluginGroup from a PluginGroupDefinition. | |
37 static PluginGroup* FromPluginGroupDefinition( | |
38 const PluginGroupDefinition& definition); | |
39 | 25 |
40 // Creates a PluginGroup from a WebPluginInfo -- when no hard-coded | 26 // Enable or disable a specific plugin file. |
41 // definition is found. | 27 void EnablePluginFile(bool enable, const FilePath::StringType& file_path); |
42 static PluginGroup* FromWebPluginInfo(const WebPluginInfo& wpi); | |
43 | 28 |
44 // Creates a copy of this plugin group. | 29 // Disable all plugin groups as defined by the user's preference file. |
45 PluginGroup* Copy(); | 30 void DisablePluginGroupsFromPrefs(Profile* profile); |
46 | 31 |
47 // Returns true if the given plugin matches this group. | 32 // Write the enable/disable status to the user's preference file. |
48 bool Match(const WebPluginInfo& plugin) const; | 33 void UpdatePreferences(Profile* profile); |
49 | 34 |
50 // Adds the given plugin to this group. Provide the position of the | 35 } // namespace plugin_updater |
51 // plugin as given by PluginList so we can display its priority. | |
52 void AddPlugin(const WebPluginInfo& plugin, int position); | |
53 | |
54 // Enables/disables this group. This enables/disables all plugins in the | |
55 // group. | |
56 void Enable(bool enable); | |
57 | |
58 // Returns this group's name | |
59 const string16 GetGroupName() const; | |
60 | |
61 // Returns a DictionaryValue with data to display in the UI. | |
62 DictionaryValue* GetData() const; | |
63 | |
64 // Returns a DictionaryValue with data to save in the preferences. | |
65 DictionaryValue* GetSummary() const; | |
66 | |
67 // Returns true if the latest plugin in this group has known | |
68 // security problems. | |
69 bool IsVulnerable() const; | |
70 | |
71 private: | |
72 PluginGroup(const string16& group_name, | |
73 const string16& name_matcher, | |
74 const std::string& version_range_low, | |
75 const std::string& version_range_high, | |
76 const std::string& min_version, | |
77 const std::string& update_url); | |
78 | |
79 string16 group_name_; | |
80 string16 name_matcher_; | |
81 std::string version_range_low_str_; | |
82 std::string version_range_high_str_; | |
83 scoped_ptr<Version> version_range_low_; | |
84 scoped_ptr<Version> version_range_high_; | |
85 string16 description_; | |
86 std::string update_url_; | |
87 bool enabled_; | |
88 std::string min_version_str_; | |
89 scoped_ptr<Version> min_version_; | |
90 scoped_ptr<Version> max_version_; | |
91 std::vector<WebPluginInfo> web_plugin_infos_; | |
92 std::vector<int> web_plugin_positions_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(PluginGroup); | |
95 }; | |
96 | |
97 class PluginUpdater { | |
98 public: | |
99 // Returns the PluginUpdater singleton. | |
100 static PluginUpdater* GetInstance(); | |
101 | |
102 static const PluginGroupDefinition* GetPluginGroupDefinitions(); | |
103 static const size_t GetPluginGroupDefinitionsSize(); | |
104 | |
105 // Get a list of all the Plugin groups. | |
106 ListValue* GetPluginGroupsData(); | |
107 | |
108 // Get a list of all the Plugin groups. | |
109 ListValue* GetPluginGroupsSummary(); | |
110 | |
111 // Enable or disable a plugin group. | |
112 void EnablePluginGroup(bool enable, const string16& group_name); | |
113 | |
114 // Enable or disable a specific plugin file. | |
115 void EnablePluginFile(bool enable, const FilePath::StringType& file_path); | |
116 | |
117 // Disable all plugin groups as defined by the user's preference file. | |
118 void DisablePluginGroupsFromPrefs(Profile* profile); | |
119 | |
120 // Write the enable/disable status to the user's preference file. | |
121 void UpdatePreferences(Profile* profile); | |
122 | |
123 private: | |
124 friend struct DefaultSingletonTraits<PluginUpdater>; | |
125 | |
126 PluginUpdater(); | |
127 ~PluginUpdater(); | |
128 | |
129 void GetPluginGroups(std::vector<linked_ptr<PluginGroup> >* plugin_groups); | |
130 | |
131 DictionaryValue* CreatePluginFileSummary(const WebPluginInfo& plugin); | |
132 | |
133 std::vector<linked_ptr<PluginGroup> > plugin_group_definitions_; | |
134 | |
135 // Set to true iff the internal pdf plugin is enabled by default. | |
136 static bool enable_internal_pdf_; | |
137 | |
138 DISALLOW_COPY_AND_ASSIGN(PluginUpdater); | |
139 }; | |
140 | 36 |
141 #endif // CHROME_BROWSER_PLUGIN_UPDATER_H_ | 37 #endif // CHROME_BROWSER_PLUGIN_UPDATER_H_ |
OLD | NEW |