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