OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/plugins_ui.h" | 5 #include "chrome/browser/ui/webui/plugins_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 PluginService::GetInstance()->GetPluginGroups( | 335 PluginService::GetInstance()->GetPluginGroups( |
336 base::Bind(&PluginsDOMHandler::PluginsLoaded, | 336 base::Bind(&PluginsDOMHandler::PluginsLoaded, |
337 weak_ptr_factory_.GetWeakPtr(), plugin_finder)); | 337 weak_ptr_factory_.GetWeakPtr(), plugin_finder)); |
338 } | 338 } |
339 | 339 |
340 void PluginsDOMHandler::PluginsLoaded(PluginFinder* plugin_finder, | 340 void PluginsDOMHandler::PluginsLoaded(PluginFinder* plugin_finder, |
341 const std::vector<PluginGroup>& groups) { | 341 const std::vector<PluginGroup>& groups) { |
342 Profile* profile = Profile::FromWebUI(web_ui()); | 342 Profile* profile = Profile::FromWebUI(web_ui()); |
343 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); | 343 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(profile); |
344 | 344 |
345 HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | |
346 ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); | 345 ContentSettingsPattern wildcard = ContentSettingsPattern::Wildcard(); |
347 | 346 |
348 // Construct DictionaryValues to return to the UI | 347 // Construct DictionaryValues to return to the UI |
349 ListValue* plugin_groups_data = new ListValue(); | 348 ListValue* plugin_groups_data = new ListValue(); |
350 for (size_t i = 0; i < groups.size(); ++i) { | 349 for (size_t i = 0; i < groups.size(); ++i) { |
351 const PluginGroup& group = groups[i]; | 350 const PluginGroup& group = groups[i]; |
352 if (group.IsEmpty()) | 351 if (group.IsEmpty()) |
353 continue; | 352 continue; |
354 ListValue* plugin_files = new ListValue(); | 353 ListValue* plugin_files = new ListValue(); |
355 string16 group_name = group.GetGroupName(); | 354 string16 group_name = group.GetGroupName(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 enabled_mode = "enabledByPolicy"; | 440 enabled_mode = "enabledByPolicy"; |
442 } else if (all_plugins_disabled_by_policy) { | 441 } else if (all_plugins_disabled_by_policy) { |
443 enabled_mode = "disabledByPolicy"; | 442 enabled_mode = "disabledByPolicy"; |
444 } else if (group_enabled) { | 443 } else if (group_enabled) { |
445 enabled_mode = "enabledByUser"; | 444 enabled_mode = "enabledByUser"; |
446 } else { | 445 } else { |
447 enabled_mode = "disabledByUser"; | 446 enabled_mode = "disabledByUser"; |
448 } | 447 } |
449 group_data->SetString("enabledMode", enabled_mode); | 448 group_data->SetString("enabledMode", enabled_mode); |
450 | 449 |
451 // TODO(bauerb): We should have a method on HostContentSettingsMap for this. | |
452 bool always_allowed = false; | 450 bool always_allowed = false; |
453 ContentSettingsForOneType settings; | 451 if (group_enabled) { |
454 map->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS, | 452 const DictionaryValue* whitelist = profile->GetPrefs()->GetDictionary( |
455 group.identifier(), &settings); | 453 prefs::kContentSettingsPluginWhitelist); |
456 for (ContentSettingsForOneType::const_iterator it = settings.begin(); | 454 whitelist->GetBoolean(group.identifier(), &always_allowed); |
457 it != settings.end(); ++it) { | |
458 if (it->primary_pattern == wildcard && | |
459 it->secondary_pattern == wildcard && | |
460 it->setting == CONTENT_SETTING_ALLOW) { | |
461 always_allowed = true; | |
462 break; | |
463 } | |
464 } | 455 } |
465 group_data->SetBoolean("alwaysAllowed", always_allowed); | 456 group_data->SetBoolean("alwaysAllowed", always_allowed); |
466 | 457 |
467 plugin_groups_data->Append(group_data); | 458 plugin_groups_data->Append(group_data); |
468 } | 459 } |
469 DictionaryValue results; | 460 DictionaryValue results; |
470 results.Set("plugins", plugin_groups_data); | 461 results.Set("plugins", plugin_groups_data); |
471 web_ui()->CallJavascriptFunction("returnPluginsData", results); | 462 web_ui()->CallJavascriptFunction("returnPluginsData", results); |
472 } | 463 } |
473 | 464 |
(...skipping 24 matching lines...) Expand all Loading... |
498 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { | 489 void PluginsUI::RegisterUserPrefs(PrefService* prefs) { |
499 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, | 490 prefs->RegisterBooleanPref(prefs::kPluginsShowDetails, |
500 false, | 491 false, |
501 PrefService::UNSYNCABLE_PREF); | 492 PrefService::UNSYNCABLE_PREF); |
502 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, | 493 prefs->RegisterBooleanPref(prefs::kPluginsShowSetReaderDefaultInfobar, |
503 true, | 494 true, |
504 PrefService::UNSYNCABLE_PREF); | 495 PrefService::UNSYNCABLE_PREF); |
505 prefs->RegisterDictionaryPref(prefs::kContentSettingsPluginWhitelist, | 496 prefs->RegisterDictionaryPref(prefs::kContentSettingsPluginWhitelist, |
506 PrefService::SYNCABLE_PREF); | 497 PrefService::SYNCABLE_PREF); |
507 } | 498 } |
OLD | NEW |