| 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/extensions/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/prefs/pref_notifier.h" | 10 #include "chrome/browser/prefs/pref_notifier.h" |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 return launch_container; | 607 return launch_container; |
| 608 } | 608 } |
| 609 | 609 |
| 610 void ExtensionPrefs::SetLaunchType(const std::string& extension_id, | 610 void ExtensionPrefs::SetLaunchType(const std::string& extension_id, |
| 611 LaunchType launch_type) { | 611 LaunchType launch_type) { |
| 612 UpdateExtensionPref(extension_id, kPrefLaunchType, | 612 UpdateExtensionPref(extension_id, kPrefLaunchType, |
| 613 Value::CreateIntegerValue(static_cast<int>(launch_type))); | 613 Value::CreateIntegerValue(static_cast<int>(launch_type))); |
| 614 SavePrefsAndNotify(); | 614 SavePrefsAndNotify(); |
| 615 } | 615 } |
| 616 | 616 |
| 617 void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) { | 617 bool ExtensionPrefs::IsExtensionKilled(const std::string& id) { |
| 618 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); | 618 DictionaryValue* extension = GetExtensionPref(id); |
| 619 if (!dict || dict->empty()) | 619 if (!extension) |
| 620 return; | 620 return false; |
| 621 | 621 int state = 0; |
| 622 for (DictionaryValue::key_iterator i = dict->begin_keys(); | 622 return extension->GetInteger(kPrefState, &state) && |
| 623 i != dict->end_keys(); ++i) { | 623 state == static_cast<int>(Extension::KILLBIT); |
| 624 const std::string& key_name(*i); | |
| 625 if (!Extension::IdIsValid(key_name)) { | |
| 626 LOG(WARNING) << "Invalid external extension ID encountered: " << key_name; | |
| 627 continue; | |
| 628 } | |
| 629 | |
| 630 DictionaryValue* extension; | |
| 631 if (!dict->GetDictionary(key_name, &extension)) { | |
| 632 NOTREACHED(); | |
| 633 continue; | |
| 634 } | |
| 635 | |
| 636 // Check to see if the extension has been killed. | |
| 637 int state; | |
| 638 if (extension->GetInteger(kPrefState, &state) && | |
| 639 state == static_cast<int>(Extension::KILLBIT)) { | |
| 640 killed_ids->insert(StringToLowerASCII(key_name)); | |
| 641 } | |
| 642 } | |
| 643 } | 624 } |
| 644 | 625 |
| 645 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { | 626 std::vector<std::string> ExtensionPrefs::GetToolbarOrder() { |
| 646 std::vector<std::string> extension_ids; | 627 std::vector<std::string> extension_ids; |
| 647 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); | 628 const ListValue* toolbar_order = prefs_->GetList(kExtensionToolbar); |
| 648 if (toolbar_order) { | 629 if (toolbar_order) { |
| 649 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { | 630 for (size_t i = 0; i < toolbar_order->GetSize(); ++i) { |
| 650 std::string extension_id; | 631 std::string extension_id; |
| 651 if (toolbar_order->GetString(i, &extension_id)) | 632 if (toolbar_order->GetString(i, &extension_id)) |
| 652 extension_ids.push_back(extension_id); | 633 extension_ids.push_back(extension_id); |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { | 1075 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
| 1095 prefs->RegisterDictionaryPref(kExtensionsPref); | 1076 prefs->RegisterDictionaryPref(kExtensionsPref); |
| 1096 prefs->RegisterListPref(kExtensionToolbar); | 1077 prefs->RegisterListPref(kExtensionToolbar); |
| 1097 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); | 1078 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); |
| 1098 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); | 1079 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); |
| 1099 prefs->RegisterListPref(prefs::kExtensionInstallAllowList); | 1080 prefs->RegisterListPref(prefs::kExtensionInstallAllowList); |
| 1100 prefs->RegisterListPref(prefs::kExtensionInstallDenyList); | 1081 prefs->RegisterListPref(prefs::kExtensionInstallDenyList); |
| 1101 prefs->RegisterListPref(prefs::kExtensionInstallForceList); | 1082 prefs->RegisterListPref(prefs::kExtensionInstallForceList); |
| 1102 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */); | 1083 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */); |
| 1103 } | 1084 } |
| OLD | NEW |