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/command_line.h" |
10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
11 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/browser/pref_service.h" | 14 #include "chrome/browser/pref_service.h" |
14 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/plugin_group.h" | 18 #include "chrome/common/plugin_group.h" |
17 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
18 #include "webkit/glue/plugins/plugin_list.h" | 20 #include "webkit/glue/plugins/plugin_list.h" |
19 #include "webkit/glue/plugins/webplugininfo.h" | 21 #include "webkit/glue/plugins/webplugininfo.h" |
20 | 22 |
21 namespace plugin_updater { | 23 namespace plugin_updater { |
22 | 24 |
23 // Convert to a List of Groups | 25 // Convert to a List of Groups |
24 static void GetPluginGroups( | 26 static void GetPluginGroups( |
25 std::vector<linked_ptr<PluginGroup> >* plugin_groups) { | 27 std::vector<linked_ptr<PluginGroup> >* plugin_groups) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 EnablePluginGroup(false, current_group_name); | 201 EnablePluginGroup(false, current_group_name); |
200 } | 202 } |
201 | 203 |
202 if (!enable_internal_pdf_ && !found_internal_pdf) { | 204 if (!enable_internal_pdf_ && !found_internal_pdf) { |
203 // The internal PDF plugin is disabled by default, and the user hasn't | 205 // The internal PDF plugin is disabled by default, and the user hasn't |
204 // overridden the default. | 206 // overridden the default. |
205 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); | 207 NPAPI::PluginList::Singleton()->DisablePlugin(pdf_path); |
206 } | 208 } |
207 } | 209 } |
208 | 210 |
| 211 void DisableOutdatedPluginGroups() { |
| 212 std::vector<linked_ptr<PluginGroup> > groups; |
| 213 GetPluginGroups(&groups); |
| 214 for (std::vector<linked_ptr<PluginGroup> >::iterator it = |
| 215 groups.begin(); |
| 216 it != groups.end(); |
| 217 ++it) { |
| 218 if ((*it)->IsVulnerable()) { |
| 219 (*it)->Enable(false); |
| 220 } |
| 221 } |
| 222 } |
| 223 |
209 void UpdatePreferences(Profile* profile) { | 224 void UpdatePreferences(Profile* profile) { |
210 ListValue* plugins_list = profile->GetPrefs()->GetMutableList( | 225 ListValue* plugins_list = profile->GetPrefs()->GetMutableList( |
211 prefs::kPluginsPluginsList); | 226 prefs::kPluginsPluginsList); |
212 plugins_list->Clear(); | 227 plugins_list->Clear(); |
213 | 228 |
214 FilePath internal_dir; | 229 FilePath internal_dir; |
215 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) | 230 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) |
216 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory, | 231 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory, |
217 internal_dir); | 232 internal_dir); |
218 | 233 |
219 // Add the plugin files. | 234 // Add the plugin files. |
220 std::vector<WebPluginInfo> plugins; | 235 std::vector<WebPluginInfo> plugins; |
221 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); | 236 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins); |
222 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); | 237 for (std::vector<WebPluginInfo>::const_iterator it = plugins.begin(); |
223 it != plugins.end(); | 238 it != plugins.end(); |
224 ++it) { | 239 ++it) { |
225 plugins_list->Append(CreatePluginFileSummary(*it)); | 240 plugins_list->Append(CreatePluginFileSummary(*it)); |
226 } | 241 } |
227 | 242 |
228 // Add the groups as well. | 243 // Add the groups as well. |
229 std::vector<linked_ptr<PluginGroup> > plugin_groups; | 244 std::vector<linked_ptr<PluginGroup> > plugin_groups; |
230 GetPluginGroups(&plugin_groups); | 245 GetPluginGroups(&plugin_groups); |
231 for (std::vector<linked_ptr<PluginGroup> >::iterator it = | 246 for (std::vector<linked_ptr<PluginGroup> >::iterator it = |
232 plugin_groups.begin(); | 247 plugin_groups.begin(); |
233 it != plugin_groups.end(); | 248 it != plugin_groups.end(); |
234 ++it) { | 249 ++it) { |
235 // Don't save preferences for vulnerable pugins. | 250 // Don't save preferences for vulnerable pugins. |
236 if (!(*it)->IsVulnerable()) { | 251 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 252 switches::kDisableOutdatedPlugins) || |
| 253 !(*it)->IsVulnerable()) { |
237 plugins_list->Append((*it)->GetSummary()); | 254 plugins_list->Append((*it)->GetSummary()); |
238 } | 255 } |
239 } | 256 } |
240 } | 257 } |
241 | 258 |
242 } // namespace plugin_updater | 259 } // namespace plugin_updater |
OLD | NEW |