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 #include "chrome/browser/plugin_updater.h" | 5 #include "chrome/browser/plugin_updater.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "base/string_util.h" | |
13 #include "base/values.h" | 12 #include "base/values.h" |
14 #include "base/version.h" | |
15 #include "base/utf_string_conversions.h" | |
16 #include "chrome/browser/pref_service.h" | 13 #include "chrome/browser/pref_service.h" |
| 14 #include "chrome/browser/profile.h" |
17 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/browser/profile.h" | 16 #include "chrome/common/plugin_group.h" |
19 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
20 #include "webkit/glue/plugins/plugin_list.h" | 18 #include "webkit/glue/plugins/plugin_list.h" |
21 #include "webkit/glue/plugins/webplugininfo.h" | 19 #include "webkit/glue/plugins/webplugininfo.h" |
22 | 20 |
23 /*private*/ | 21 namespace plugin_updater { |
24 PluginGroup::PluginGroup(const string16& group_name, | |
25 const string16& name_matcher, | |
26 const std::string& version_range_low, | |
27 const std::string& version_range_high, | |
28 const std::string& min_version, | |
29 const std::string& update_url) { | |
30 group_name_ = group_name; | |
31 name_matcher_ = name_matcher; | |
32 version_range_low_str_ = version_range_low; | |
33 if (!version_range_low.empty()) { | |
34 version_range_low_.reset( | |
35 Version::GetVersionFromString(version_range_low)); | |
36 } | |
37 version_range_high_str_ = version_range_high; | |
38 if (!version_range_high.empty()) { | |
39 version_range_high_.reset( | |
40 Version::GetVersionFromString(version_range_high)); | |
41 } | |
42 min_version_str_ = min_version; | |
43 if (!min_version.empty()) { | |
44 min_version_.reset(Version::GetVersionFromString(min_version)); | |
45 } | |
46 update_url_ = update_url; | |
47 enabled_ = false; | |
48 max_version_.reset(Version::GetVersionFromString("0")); | |
49 } | |
50 | |
51 PluginGroup* PluginGroup::FromPluginGroupDefinition( | |
52 const PluginGroupDefinition& definition) { | |
53 return new PluginGroup(ASCIIToUTF16(definition.name), | |
54 ASCIIToUTF16(definition.name_matcher), | |
55 definition.version_matcher_low, | |
56 definition.version_matcher_high, | |
57 definition.min_version, | |
58 definition.update_url); | |
59 } | |
60 | |
61 PluginGroup* PluginGroup::FromWebPluginInfo(const WebPluginInfo& wpi) { | |
62 // Create a matcher from the name of this plugin. | |
63 return new PluginGroup(wpi.name, wpi.name, | |
64 "", "", "", ""); | |
65 } | |
66 | |
67 PluginGroup* PluginGroup::Copy() { | |
68 return new PluginGroup(group_name_, name_matcher_, version_range_low_str_, | |
69 version_range_high_str_, min_version_str_, | |
70 update_url_); | |
71 } | |
72 | |
73 const string16 PluginGroup::GetGroupName() const { | |
74 return group_name_; | |
75 } | |
76 | |
77 bool PluginGroup::Match(const WebPluginInfo& plugin) const { | |
78 if (name_matcher_.empty()) { | |
79 return false; | |
80 } | |
81 | |
82 // Look for the name matcher anywhere in the plugin name. | |
83 if (plugin.name.find(name_matcher_) == string16::npos) { | |
84 return false; | |
85 } | |
86 | |
87 if (version_range_low_.get() == NULL || | |
88 version_range_high_.get() == NULL) { | |
89 return true; | |
90 } | |
91 | |
92 // There's a version range, we must be in it. | |
93 scoped_ptr<Version> plugin_version( | |
94 Version::GetVersionFromString(UTF16ToWide(plugin.version))); | |
95 if (plugin_version.get() == NULL) { | |
96 // No version could be extracted, assume we don't match the range. | |
97 return false; | |
98 } | |
99 | |
100 // We match if we are in the range: [low, high) | |
101 return (version_range_low_->CompareTo(*plugin_version) <= 0 && | |
102 version_range_high_->CompareTo(*plugin_version) > 0); | |
103 } | |
104 | |
105 void PluginGroup::AddPlugin(const WebPluginInfo& plugin, int position) { | |
106 web_plugin_infos_.push_back(plugin); | |
107 // The position of this plugin relative to the global list of plugins. | |
108 web_plugin_positions_.push_back(position); | |
109 description_ = plugin.desc; | |
110 | |
111 // A group is enabled if any of the files are enabled. | |
112 if (plugin.enabled) { | |
113 enabled_ = true; | |
114 } | |
115 | |
116 // update max_version_. Remove spaces and ')' from the version string, | |
117 // Replace any instances of 'r', ',' or '(' with a dot. | |
118 std::wstring version = UTF16ToWide(plugin.version); | |
119 RemoveChars(version, L") ", &version); | |
120 std::replace(version.begin(), version.end(), 'r', '.'); | |
121 std::replace(version.begin(), version.end(), ',', '.'); | |
122 std::replace(version.begin(), version.end(), '(', '.'); | |
123 | |
124 scoped_ptr<Version> plugin_version( | |
125 Version::GetVersionFromString(version)); | |
126 if (plugin_version.get() != NULL) { | |
127 if (plugin_version->CompareTo(*(max_version_)) > 0) { | |
128 max_version_.reset(plugin_version.release()); | |
129 } | |
130 } | |
131 } | |
132 | |
133 DictionaryValue* PluginGroup::GetSummary() const { | |
134 DictionaryValue* result = new DictionaryValue(); | |
135 result->SetStringFromUTF16(L"name", group_name_); | |
136 result->SetBoolean(L"enabled", enabled_); | |
137 return result; | |
138 } | |
139 | |
140 DictionaryValue* PluginGroup::GetData() const { | |
141 DictionaryValue* result = new DictionaryValue(); | |
142 result->SetStringFromUTF16(L"name", group_name_); | |
143 result->SetStringFromUTF16(L"description", description_); | |
144 result->SetString(L"version", max_version_->GetString()); | |
145 result->SetString(L"update_url", update_url_); | |
146 result->SetBoolean(L"critical", IsVulnerable()); | |
147 result->SetBoolean(L"enabled", enabled_); | |
148 | |
149 ListValue* plugin_files = new ListValue(); | |
150 for (size_t i = 0; i < web_plugin_infos_.size(); ++i) { | |
151 const WebPluginInfo& web_plugin = web_plugin_infos_[i]; | |
152 int priority = web_plugin_positions_[i]; | |
153 DictionaryValue* plugin_file = new DictionaryValue(); | |
154 plugin_file->SetStringFromUTF16(L"name", web_plugin.name); | |
155 plugin_file->SetStringFromUTF16(L"description", web_plugin.desc); | |
156 plugin_file->SetString(L"path", web_plugin.path.value()); | |
157 plugin_file->SetStringFromUTF16(L"version", web_plugin.version); | |
158 plugin_file->SetBoolean(L"enabled", web_plugin.enabled); | |
159 plugin_file->SetInteger(L"priority", priority); | |
160 | |
161 ListValue* mime_types = new ListValue(); | |
162 for (std::vector<WebPluginMimeType>::const_iterator type_it = | |
163 web_plugin.mime_types.begin(); | |
164 type_it != web_plugin.mime_types.end(); | |
165 ++type_it) { | |
166 DictionaryValue* mime_type = new DictionaryValue(); | |
167 mime_type->SetString(L"mimeType", type_it->mime_type); | |
168 mime_type->SetStringFromUTF16(L"description", type_it->description); | |
169 | |
170 ListValue* file_extensions = new ListValue(); | |
171 for (std::vector<std::string>::const_iterator ext_it = | |
172 type_it->file_extensions.begin(); | |
173 ext_it != type_it->file_extensions.end(); | |
174 ++ext_it) { | |
175 file_extensions->Append(new StringValue(*ext_it)); | |
176 } | |
177 mime_type->Set(L"fileExtensions", file_extensions); | |
178 | |
179 mime_types->Append(mime_type); | |
180 } | |
181 plugin_file->Set(L"mimeTypes", mime_types); | |
182 | |
183 plugin_files->Append(plugin_file); | |
184 } | |
185 result->Set(L"plugin_files", plugin_files); | |
186 | |
187 return result; | |
188 } | |
189 | |
190 // Returns true if the latest version of this plugin group is vulnerable. | |
191 bool PluginGroup::IsVulnerable() const { | |
192 if (min_version_.get() == NULL || max_version_->GetString() == "0") { | |
193 return false; | |
194 } | |
195 return max_version_->CompareTo(*min_version_) < 0; | |
196 } | |
197 | |
198 void PluginGroup::Enable(bool enable) { | |
199 for (std::vector<WebPluginInfo>::const_iterator it = | |
200 web_plugin_infos_.begin(); | |
201 it != web_plugin_infos_.end(); ++it) { | |
202 if (enable) { | |
203 NPAPI::PluginList::Singleton()->EnablePlugin( | |
204 FilePath(it->path)); | |
205 } else { | |
206 NPAPI::PluginList::Singleton()->DisablePlugin( | |
207 FilePath(it->path)); | |
208 } | |
209 } | |
210 } | |
211 | |
212 #if defined(OS_MACOSX) | |
213 // Plugin Groups for Mac. | |
214 // Plugins are listed here as soon as vulnerabilities and solutions | |
215 // (new versions) are published. | |
216 // TODO(panayiotis): Track Java as soon as it's supported on Chrome Mac. | |
217 // TODO(panayiotis): Get the Real Player version on Mac, somehow. | |
218 static const PluginGroupDefinition kGroupDefinitions[] = { | |
219 { "Quicktime", "QuickTime Plug-in", "", "", "7.6.6", | |
220 "http://www.apple.com/quicktime/download/" }, | |
221 { "Flash", "Shockwave Flash", "", "", "10.0.45", | |
222 "http://get.adobe.com/flashplayer/" }, | |
223 { "Silverlight 3", "Silverlight", "0", "4", "3.0.50106.0", | |
224 "http://go.microsoft.com/fwlink/?LinkID=185927" }, | |
225 { "Silverlight 4", "Silverlight", "4", "5", "", | |
226 "http://go.microsoft.com/fwlink/?LinkID=185927" }, | |
227 { "Flip4Mac", "Flip4Mac", "", "", "2.2.1", | |
228 "http://www.telestream.net/flip4mac-wmv/overview.htm" }, | |
229 { "Shockwave", "Shockwave for Director", "", "", "11.5.7.609", | |
230 "http://www.adobe.com/shockwave/download/" } | |
231 }; | |
232 | |
233 #elif defined(OS_WIN) | |
234 // TODO(panayiotis): We should group "RealJukebox NS Plugin" with the rest of | |
235 // the RealPlayer files. | |
236 static const PluginGroupDefinition kGroupDefinitions[] = { | |
237 { "Quicktime", "QuickTime Plug-in", "", "", "7.6.6", | |
238 "http://www.apple.com/quicktime/download/" }, | |
239 { "Java 6", "Java", "", "6", "6.0.200", | |
240 "http://www.java.com/" }, | |
241 { "Adobe Reader 9", "Adobe Acrobat", "9", "10", "9.3.2", | |
242 "http://get.adobe.com/reader/" }, | |
243 { "Adobe Reader 8", "Adobe Acrobat", "0", "9", "8.2.2", | |
244 "http://get.adobe.com/reader/" }, | |
245 { "Flash", "Shockwave Flash", "", "", "10.0.45", | |
246 "http://get.adobe.com/flashplayer/" }, | |
247 { "Silverlight 3", "Silverlight", "0", "4", "3.0.50106.0", | |
248 "http://go.microsoft.com/fwlink/?LinkID=185927" }, | |
249 { "Silverlight 4", "Silverlight", "4", "5", "", | |
250 "http://go.microsoft.com/fwlink/?LinkID=185927" }, | |
251 { "Shockwave", "Shockwave for Director", "", "", "11.5.7.609", | |
252 "http://www.adobe.com/shockwave/download/" }, | |
253 { "DivX Player", "DivX Web Player", "", "", "1.4.3.4", | |
254 "http://download.divx.com/divx/autoupdate/player/DivXWebPlayerInstaller.exe"
}, | |
255 // These are here for grouping, no vulnerabilies known. | |
256 { "Windows Media Player", "Windows Media Player", "", "", "", "" }, | |
257 { "Microsoft Office", "Microsoft Office", "", "", "", "" }, | |
258 // TODO(panayiotis): The vulnerable versions are | |
259 // (v >= 6.0.12.1040 && v <= 6.0.12.1663) | |
260 // || v == 6.0.12.1698 || v == 6.0.12.1741 | |
261 { "RealPlayer", "RealPlayer", "", "", "", | |
262 "http://www.adobe.com/shockwave/download/" }, | |
263 }; | |
264 | |
265 #else | |
266 static const PluginGroupDefinition kGroupDefinitions[] = {}; | |
267 #endif | |
268 | |
269 /*static*/ | |
270 const PluginGroupDefinition* PluginUpdater::GetPluginGroupDefinitions() { | |
271 return kGroupDefinitions; | |
272 } | |
273 | |
274 /*static*/ | |
275 const size_t PluginUpdater::GetPluginGroupDefinitionsSize() { | |
276 // TODO(viettrungluu): |arraysize()| doesn't work with zero-size arrays. | |
277 return ARRAYSIZE_UNSAFE(kGroupDefinitions); | |
278 } | |
279 | |
280 // static | |
281 PluginUpdater* PluginUpdater::GetInstance() { | |
282 return Singleton<PluginUpdater>::get(); | |
283 } | |
284 | |
285 PluginUpdater::PluginUpdater() { | |
286 const PluginGroupDefinition* definitions = GetPluginGroupDefinitions(); | |
287 for (size_t i = 0; i < GetPluginGroupDefinitionsSize(); ++i) { | |
288 PluginGroup* definition_group = PluginGroup::FromPluginGroupDefinition( | |
289 definitions[i]); | |
290 plugin_group_definitions_.push_back(linked_ptr<PluginGroup>( | |
291 definition_group)); | |
292 } | |
293 } | |
294 | |
295 PluginUpdater::~PluginUpdater() { | |
296 } | |
297 | 22 |
298 // Convert to a List of Groups | 23 // Convert to a List of Groups |
299 void PluginUpdater::GetPluginGroups( | 24 static void GetPluginGroups( |
300 std::vector<linked_ptr<PluginGroup> >* plugin_groups) { | 25 std::vector<linked_ptr<PluginGroup> >* plugin_groups) { |
301 // Read all plugins and convert them to plugin groups | 26 // Read all plugins and convert them to plugin groups |
302 std::vector<WebPluginInfo> web_plugins; | 27 std::vector<WebPluginInfo> web_plugins; |
303 NPAPI::PluginList::Singleton()->GetPlugins(false, &web_plugins); | 28 NPAPI::PluginList::Singleton()->GetPlugins(false, &web_plugins); |
304 | 29 |
305 // We first search for an existing group that matches our name, | 30 // We first search for an existing group that matches our name, |
306 // and only create a new group if we can't find any. | 31 // and only create a new group if we can't find any. |
307 for (size_t i = 0; i < web_plugins.size(); ++i) { | 32 for (size_t i = 0; i < web_plugins.size(); ++i) { |
308 const WebPluginInfo& web_plugin = web_plugins[i]; | 33 const WebPluginInfo& web_plugin = web_plugins[i]; |
309 bool found = false; | 34 PluginGroup* group = PluginGroup::FindGroupMatchingPlugin( |
310 for (std::vector<linked_ptr<PluginGroup> >::iterator existing_it = | 35 *plugin_groups, web_plugin); |
311 plugin_groups->begin(); | 36 if (!group) { |
312 existing_it != plugin_groups->end(); | 37 group = PluginGroup::FindHardcodedPluginGroup(web_plugin); |
313 ++existing_it) { | 38 plugin_groups->push_back(linked_ptr<PluginGroup>(group)); |
314 if ((*existing_it)->Match(web_plugin)) { | |
315 (*existing_it)->AddPlugin(web_plugin, i); | |
316 found = true; | |
317 break; | |
318 } | |
319 } | 39 } |
320 | 40 group->AddPlugin(web_plugin, i); |
321 if (!found) { | |
322 // See if this plugin matches any of the hardcoded groups. | |
323 for (std::vector<linked_ptr<PluginGroup> >::iterator defs_it = | |
324 plugin_group_definitions_.begin(); | |
325 defs_it != plugin_group_definitions_.end(); | |
326 ++defs_it) { | |
327 if ((*defs_it)->Match(web_plugin)) { | |
328 // Make a copy, otherwise we'd be modifying plugin_group_defs_ every | |
329 // time this method is called. | |
330 PluginGroup* copy = (*defs_it)->Copy(); | |
331 copy->AddPlugin(web_plugin, i); | |
332 plugin_groups->push_back(linked_ptr<PluginGroup>(copy)); | |
333 found = true; | |
334 break; | |
335 } | |
336 } | |
337 } | |
338 | |
339 // Not found in our hardcoded list, create a new one. | |
340 if (!found) { | |
341 PluginGroup* plugin_group = PluginGroup::FromWebPluginInfo(web_plugin); | |
342 plugin_group->AddPlugin(web_plugin, i); | |
343 plugin_groups->push_back(linked_ptr<PluginGroup>(plugin_group)); | |
344 } | |
345 } | 41 } |
346 } | 42 } |
347 | 43 |
348 ListValue* PluginUpdater::GetPluginGroupsData() { | 44 static DictionaryValue* CreatePluginFileSummary( |
| 45 const WebPluginInfo& plugin) { |
| 46 DictionaryValue* data = new DictionaryValue(); |
| 47 data->SetString(L"path", plugin.path.value()); |
| 48 data->SetStringFromUTF16(L"name", plugin.name); |
| 49 data->SetStringFromUTF16(L"version", plugin.version); |
| 50 data->SetBoolean(L"enabled", plugin.enabled); |
| 51 return data; |
| 52 } |
| 53 |
| 54 ListValue* GetPluginGroupsData() { |
349 std::vector<linked_ptr<PluginGroup> > plugin_groups; | 55 std::vector<linked_ptr<PluginGroup> > plugin_groups; |
350 GetPluginGroups(&plugin_groups); | 56 GetPluginGroups(&plugin_groups); |
351 | 57 |
352 // Construct DictionaryValues to return to the UI | |
353 ListValue* plugin_groups_data = new ListValue(); | |
354 for (std::vector<linked_ptr<PluginGroup> >::iterator it = | |
355 plugin_groups.begin(); | |
356 it != plugin_groups.end(); | |
357 ++it) { | |
358 plugin_groups_data->Append((*it)->GetData()); | |
359 } | |
360 return plugin_groups_data; | |
361 } | |
362 | |
363 ListValue* PluginUpdater::GetPluginGroupsSummary() { | |
364 std::vector<linked_ptr<PluginGroup> > plugin_groups; | |
365 GetPluginGroups(&plugin_groups); | |
366 | |
367 // Construct DictionaryValues to return to the UI | 58 // Construct DictionaryValues to return to the UI |
368 ListValue* plugin_groups_data = new ListValue(); | 59 ListValue* plugin_groups_data = new ListValue(); |
369 for (std::vector<linked_ptr<PluginGroup> >::iterator it = | 60 for (std::vector<linked_ptr<PluginGroup> >::iterator it = |
370 plugin_groups.begin(); | 61 plugin_groups.begin(); |
371 it != plugin_groups.end(); | 62 it != plugin_groups.end(); |
372 ++it) { | 63 ++it) { |
373 plugin_groups_data->Append((*it)->GetSummary()); | 64 plugin_groups_data->Append((*it)->GetDataForUI()); |
374 } | 65 } |
375 return plugin_groups_data; | 66 return plugin_groups_data; |
376 } | 67 } |
377 | 68 |
378 void PluginUpdater::EnablePluginGroup(bool enable, | 69 void EnablePluginGroup(bool enable, const string16& group_name) { |
379 const string16& group_name) { | |
380 std::vector<linked_ptr<PluginGroup> > plugin_groups; | 70 std::vector<linked_ptr<PluginGroup> > plugin_groups; |
381 GetPluginGroups(&plugin_groups); | 71 GetPluginGroups(&plugin_groups); |
382 | 72 |
383 for (std::vector<linked_ptr<PluginGroup> >::iterator it = | 73 for (std::vector<linked_ptr<PluginGroup> >::iterator it = |
384 plugin_groups.begin(); | 74 plugin_groups.begin(); |
385 it != plugin_groups.end(); | 75 it != plugin_groups.end(); |
386 ++it) { | 76 ++it) { |
387 if ((*it)->GetGroupName() == group_name) { | 77 if ((*it)->GetGroupName() == group_name) { |
388 (*it)->Enable(enable); | 78 (*it)->Enable(enable); |
389 } | 79 } |
390 } | 80 } |
391 } | 81 } |
392 | 82 |
393 void PluginUpdater::EnablePluginFile(bool enable, | 83 void EnablePluginFile(bool enable, const FilePath::StringType& file_path) { |
394 const FilePath::StringType& file_path) { | |
395 if (enable) | 84 if (enable) |
396 NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(file_path)); | 85 NPAPI::PluginList::Singleton()->EnablePlugin(FilePath(file_path)); |
397 else | 86 else |
398 NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(file_path)); | 87 NPAPI::PluginList::Singleton()->DisablePlugin(FilePath(file_path)); |
399 } | 88 } |
400 | 89 |
401 // static | |
402 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
403 bool PluginUpdater::enable_internal_pdf_ = true; | 91 static bool enable_internal_pdf_ = true; |
404 #else | 92 #else |
405 bool PluginUpdater::enable_internal_pdf_ = false; | 93 static bool enable_internal_pdf_ = false; |
406 #endif | 94 #endif |
407 | 95 |
408 void PluginUpdater::DisablePluginGroupsFromPrefs(Profile* profile) { | 96 void DisablePluginGroupsFromPrefs(Profile* profile) { |
409 bool update_internal_dir = false; | 97 bool update_internal_dir = false; |
410 FilePath last_internal_dir = | 98 FilePath last_internal_dir = |
411 profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory); | 99 profile->GetPrefs()->GetFilePath(prefs::kPluginsLastInternalDirectory); |
412 FilePath cur_internal_dir; | 100 FilePath cur_internal_dir; |
413 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir) && | 101 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &cur_internal_dir) && |
414 cur_internal_dir != last_internal_dir) { | 102 cur_internal_dir != last_internal_dir) { |
415 update_internal_dir = true; | 103 update_internal_dir = true; |
416 profile->GetPrefs()->SetFilePath( | 104 profile->GetPrefs()->SetFilePath( |
417 prefs::kPluginsLastInternalDirectory, cur_internal_dir); | 105 prefs::kPluginsLastInternalDirectory, cur_internal_dir); |
418 } | 106 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 166 } |
479 } | 167 } |
480 | 168 |
481 if (!enable_internal_pdf_ && !found_internal_pdf) { | 169 if (!enable_internal_pdf_ && !found_internal_pdf) { |
482 // The internal PDF plugin is disabled by default, and the user hasn't | 170 // The internal PDF plugin is disabled by default, and the user hasn't |
483 // overridden the default. | 171 // overridden the default. |
484 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); | 172 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); |
485 } | 173 } |
486 } | 174 } |
487 | 175 |
488 DictionaryValue* PluginUpdater::CreatePluginFileSummary( | 176 void UpdatePreferences(Profile* profile) { |
489 const WebPluginInfo& plugin) { | |
490 DictionaryValue* data = new DictionaryValue(); | |
491 data->SetString(L"path", plugin.path.value()); | |
492 data->SetStringFromUTF16(L"name", plugin.name); | |
493 data->SetStringFromUTF16(L"version", plugin.version); | |
494 data->SetBoolean(L"enabled", plugin.enabled); | |
495 return data; | |
496 } | |
497 | |
498 void PluginUpdater::UpdatePreferences(Profile* profile) { | |
499 ListValue* plugins_list = profile->GetPrefs()->GetMutableList( | 177 ListValue* plugins_list = profile->GetPrefs()->GetMutableList( |
500 prefs::kPluginsPluginsList); | 178 prefs::kPluginsPluginsList); |
501 plugins_list->Clear(); | 179 plugins_list->Clear(); |
502 | 180 |
503 FilePath internal_dir; | 181 FilePath internal_dir; |
504 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) | 182 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) |
505 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory, | 183 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory, |
506 internal_dir); | 184 internal_dir); |
507 | 185 |
508 // Add the plugin files. | 186 // Add the plugin files. |
509 std::vector<WebPluginInfo> plugins; | 187 std::vector<WebPluginInfo> plugins; |
510 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); | 188 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); |
511 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); | 189 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); |
512 it != plugins.end(); | 190 it != plugins.end(); |
513 ++it) { | 191 ++it) { |
514 plugins_list->Append(CreatePluginFileSummary(*it)); | 192 plugins_list->Append(CreatePluginFileSummary(*it)); |
515 } | 193 } |
516 | 194 |
517 // Add the groups as well. | 195 // Add the groups as well. |
518 ListValue* plugin_groups = GetPluginGroupsSummary(); | 196 std::vector<linked_ptr<PluginGroup> > plugin_groups; |
519 for (ListValue::const_iterator it = plugin_groups->begin(); | 197 GetPluginGroups(&plugin_groups); |
520 it != plugin_groups->end(); | 198 for (std::vector<linked_ptr<PluginGroup> >::iterator it = |
| 199 plugin_groups.begin(); |
| 200 it != plugin_groups.end(); |
521 ++it) { | 201 ++it) { |
522 plugins_list->Append(*it); | 202 // Don't save preferences for vulnerable pugins. |
| 203 if (!(*it)->IsVulnerable()) { |
| 204 plugins_list->Append((*it)->GetSummary()); |
| 205 } |
523 } | 206 } |
524 } | 207 } |
| 208 |
| 209 } // namespace plugin_updater |
OLD | NEW |