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" |
11 #include "chrome/common/in_memory_pref_store.h" | |
11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
12 | 13 |
13 using base::Time; | 14 using base::Time; |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // Additional preferences keys | 18 // Additional preferences keys |
18 | 19 |
19 // Where an extension was installed from. (see Extension::Location) | 20 // Where an extension was installed from. (see Extension::Location) |
20 const char kPrefLocation[] = "location"; | 21 const char kPrefLocation[] = "location"; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 // A preference set by the the NTP to persist the desired launch container type | 72 // A preference set by the the NTP to persist the desired launch container type |
72 // used for apps. | 73 // used for apps. |
73 const char kPrefLaunchType[] = "launchType"; | 74 const char kPrefLaunchType[] = "launchType"; |
74 | 75 |
75 // A preference determining the order of which the apps appear on the NTP. | 76 // A preference determining the order of which the apps appear on the NTP. |
76 const char kPrefAppLaunchIndex[] = "app_launcher_index"; | 77 const char kPrefAppLaunchIndex[] = "app_launcher_index"; |
77 | 78 |
78 // "A preference for storing extra data sent in update checks for an extension. | 79 // "A preference for storing extra data sent in update checks for an extension. |
79 const char kUpdateUrlData[] = "update_url_data"; | 80 const char kUpdateUrlData[] = "update_url_data"; |
80 | 81 |
82 // A preference that indicates when an extension was installed. | |
83 const char kPrefInstallTime[] = "install_time"; | |
84 | |
85 // A preference that indicates the last effective preference values of an | |
86 // extension. | |
Mattias Nissler (ping if slow)
2010/11/18 16:30:33
Maybe add "The value is a dictionary mapping prefe
battre (please use the other)
2010/11/18 16:47:33
Done.
| |
87 const char kPrefPreferences[] = "preferences"; | |
88 | |
81 } // namespace | 89 } // namespace |
82 | 90 |
83 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
84 | 92 |
85 namespace { | 93 namespace { |
86 | 94 |
87 // TODO(asargent) - This is cleanup code for a key that was introduced into | 95 // TODO(asargent) - This is cleanup code for a key that was introduced into |
88 // the extensions.settings sub-dictionary which wasn't a valid extension | 96 // the extensions.settings sub-dictionary which wasn't a valid extension |
89 // id. We can remove this in a couple of months. (See http://crbug.com/40017 | 97 // id. We can remove this in a couple of months. (See http://crbug.com/40017 |
90 // and http://crbug.com/39745 for more details). | 98 // and http://crbug.com/39745 for more details). |
(...skipping 21 matching lines...) Expand all Loading... | |
112 } // namespace | 120 } // namespace |
113 | 121 |
114 ExtensionPrefs::ExtensionPrefs(PrefService* prefs, const FilePath& root_dir) | 122 ExtensionPrefs::ExtensionPrefs(PrefService* prefs, const FilePath& root_dir) |
115 : prefs_(prefs), | 123 : prefs_(prefs), |
116 install_directory_(root_dir) { | 124 install_directory_(root_dir) { |
117 // TODO(asargent) - Remove this in a couple of months. (See comment above | 125 // TODO(asargent) - Remove this in a couple of months. (See comment above |
118 // CleanupBadExtensionKeys). | 126 // CleanupBadExtensionKeys). |
119 CleanupBadExtensionKeys(prefs); | 127 CleanupBadExtensionKeys(prefs); |
120 | 128 |
121 MakePathsRelative(); | 129 MakePathsRelative(); |
130 | |
131 InstallPersistedExtensionControlledPrefs(); | |
122 } | 132 } |
123 | 133 |
124 ExtensionPrefs::~ExtensionPrefs() {} | 134 ExtensionPrefs::~ExtensionPrefs() {} |
125 | 135 |
126 // static | 136 // static |
127 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings"; | 137 const char ExtensionPrefs::kExtensionsPref[] = "extensions.settings"; |
128 | 138 |
129 static FilePath::StringType MakePathRelative(const FilePath& parent, | 139 static FilePath::StringType MakePathRelative(const FilePath& parent, |
130 const FilePath& child, | 140 const FilePath& child, |
131 bool *dirty) { | 141 bool *dirty) { |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 iter != extension_ids.end(); ++iter) { | 527 iter != extension_ids.end(); ++iter) { |
518 toolbar_order->Append(new StringValue(*iter)); | 528 toolbar_order->Append(new StringValue(*iter)); |
519 } | 529 } |
520 SavePrefsAndNotify(); | 530 SavePrefsAndNotify(); |
521 } | 531 } |
522 | 532 |
523 void ExtensionPrefs::OnExtensionInstalled( | 533 void ExtensionPrefs::OnExtensionInstalled( |
524 const Extension* extension, Extension::State initial_state, | 534 const Extension* extension, Extension::State initial_state, |
525 bool initial_incognito_enabled) { | 535 bool initial_incognito_enabled) { |
526 const std::string& id = extension->id(); | 536 const std::string& id = extension->id(); |
537 const base::Time installTime = GetCurrentTime(); | |
527 UpdateExtensionPref(id, kPrefState, | 538 UpdateExtensionPref(id, kPrefState, |
528 Value::CreateIntegerValue(initial_state)); | 539 Value::CreateIntegerValue(initial_state)); |
529 UpdateExtensionPref(id, kPrefIncognitoEnabled, | 540 UpdateExtensionPref(id, kPrefIncognitoEnabled, |
530 Value::CreateBooleanValue(initial_incognito_enabled)); | 541 Value::CreateBooleanValue(initial_incognito_enabled)); |
531 UpdateExtensionPref(id, kPrefLocation, | 542 UpdateExtensionPref(id, kPrefLocation, |
532 Value::CreateIntegerValue(extension->location())); | 543 Value::CreateIntegerValue(extension->location())); |
544 UpdateExtensionPref(id, kPrefInstallTime, | |
545 Value::CreateStringValue( | |
546 base::Int64ToString(installTime.ToInternalValue()))); | |
547 UpdateExtensionPref(id, kPrefPreferences, new DictionaryValue()); | |
548 | |
533 FilePath::StringType path = MakePathRelative(install_directory_, | 549 FilePath::StringType path = MakePathRelative(install_directory_, |
534 extension->path(), NULL); | 550 extension->path(), NULL); |
535 UpdateExtensionPref(id, kPrefPath, Value::CreateStringValue(path)); | 551 UpdateExtensionPref(id, kPrefPath, Value::CreateStringValue(path)); |
536 // We store prefs about LOAD extensions, but don't cache their manifest | 552 // We store prefs about LOAD extensions, but don't cache their manifest |
537 // since it may change on disk. | 553 // since it may change on disk. |
538 if (extension->location() != Extension::LOAD) { | 554 if (extension->location() != Extension::LOAD) { |
539 UpdateExtensionPref(id, kPrefManifest, | 555 UpdateExtensionPref(id, kPrefManifest, |
540 extension->manifest_value()->DeepCopy()); | 556 extension->manifest_value()->DeepCopy()); |
541 } | 557 } |
542 UpdateExtensionPref(id, kPrefAppLaunchIndex, | 558 UpdateExtensionPref(id, kPrefAppLaunchIndex, |
543 Value::CreateIntegerValue(GetNextAppLaunchIndex())); | 559 Value::CreateIntegerValue(GetNextAppLaunchIndex())); |
544 SavePrefsAndNotify(); | 560 SavePrefsAndNotify(); |
545 } | 561 } |
546 | 562 |
547 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, | 563 void ExtensionPrefs::OnExtensionUninstalled(const std::string& extension_id, |
548 const Extension::Location& location, | 564 const Extension::Location& location, |
549 bool external_uninstall) { | 565 bool external_uninstall) { |
550 // For external extensions, we save a preference reminding ourself not to try | 566 // For external extensions, we save a preference reminding ourself not to try |
551 // and install the extension anymore (except when |external_uninstall| is | 567 // and install the extension anymore (except when |external_uninstall| is |
552 // true, which signifies that the registry key was deleted or the pref file | 568 // true, which signifies that the registry key was deleted or the pref file |
553 // no longer lists the extension). | 569 // no longer lists the extension). |
570 | |
571 std::vector<std::string> prefKeys; | |
572 GetExtensionControlledPrefKeys(extension_id, &prefKeys); | |
573 | |
554 if (!external_uninstall && Extension::IsExternalLocation(location)) { | 574 if (!external_uninstall && Extension::IsExternalLocation(location)) { |
555 UpdateExtensionPref(extension_id, kPrefState, | 575 UpdateExtensionPref(extension_id, kPrefState, |
556 Value::CreateIntegerValue(Extension::KILLBIT)); | 576 Value::CreateIntegerValue(Extension::KILLBIT)); |
557 SavePrefsAndNotify(); | 577 SavePrefsAndNotify(); |
558 } else { | 578 } else { |
559 DeleteExtensionPrefs(extension_id); | 579 DeleteExtensionPrefs(extension_id); |
560 } | 580 } |
581 | |
582 for (std::vector<std::string>::iterator i = prefKeys.begin(); | |
583 i != prefKeys.end(); ++i) { | |
584 UpdateWinningPref(*i); | |
585 } | |
561 } | 586 } |
562 | 587 |
563 Extension::State ExtensionPrefs::GetExtensionState( | 588 Extension::State ExtensionPrefs::GetExtensionState( |
564 const std::string& extension_id) { | 589 const std::string& extension_id) const { |
565 DictionaryValue* extension = GetExtensionPref(extension_id); | 590 DictionaryValue* extension = GetExtensionPref(extension_id); |
566 | 591 |
567 // If the extension doesn't have a pref, it's a --load-extension. | 592 // If the extension doesn't have a pref, it's a --load-extension. |
568 if (!extension) | 593 if (!extension) |
569 return Extension::ENABLED; | 594 return Extension::ENABLED; |
570 | 595 |
571 int state = -1; | 596 int state = -1; |
572 if (!extension->GetInteger(kPrefState, &state) || | 597 if (!extension->GetInteger(kPrefState, &state) || |
573 state < 0 || state >= Extension::NUM_STATES) { | 598 state < 0 || state >= Extension::NUM_STATES) { |
574 LOG(ERROR) << "Bad or missing pref 'state' for extension '" | 599 LOG(ERROR) << "Bad or missing pref 'state' for extension '" |
575 << extension_id << "'"; | 600 << extension_id << "'"; |
576 return Extension::ENABLED; | 601 return Extension::ENABLED; |
577 } | 602 } |
578 return static_cast<Extension::State>(state); | 603 return static_cast<Extension::State>(state); |
579 } | 604 } |
580 | 605 |
581 void ExtensionPrefs::SetExtensionState(const Extension* extension, | 606 void ExtensionPrefs::SetExtensionState(const Extension* extension, |
582 Extension::State state) { | 607 Extension::State state) { |
583 UpdateExtensionPref(extension->id(), kPrefState, | 608 UpdateExtensionPref(extension->id(), kPrefState, |
584 Value::CreateIntegerValue(state)); | 609 Value::CreateIntegerValue(state)); |
610 | |
611 std::vector<std::string> prefKeys; | |
612 GetExtensionControlledPrefKeys(extension->id(), &prefKeys); | |
613 for (std::vector<std::string>::iterator i = prefKeys.begin(); | |
614 i != prefKeys.end(); ++i) { | |
615 UpdateWinningPref(*i); | |
616 } | |
617 | |
585 SavePrefsAndNotify(); | 618 SavePrefsAndNotify(); |
586 } | 619 } |
587 | 620 |
588 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { | 621 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { |
589 DictionaryValue* extension = GetExtensionPref(extension_id); | 622 DictionaryValue* extension = GetExtensionPref(extension_id); |
590 if (!extension) | 623 if (!extension) |
591 return std::string(); | 624 return std::string(); |
592 | 625 |
593 std::string version; | 626 std::string version; |
594 if (!extension->GetString(kPrefVersion, &version)) { | 627 if (!extension->GetString(kPrefVersion, &version)) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 DictionaryValue* ExtensionPrefs::GetExtensionPref( | 687 DictionaryValue* ExtensionPrefs::GetExtensionPref( |
655 const std::string& extension_id) const { | 688 const std::string& extension_id) const { |
656 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); | 689 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); |
657 if (!dict) | 690 if (!dict) |
658 return NULL; | 691 return NULL; |
659 DictionaryValue* extension = NULL; | 692 DictionaryValue* extension = NULL; |
660 dict->GetDictionary(extension_id, &extension); | 693 dict->GetDictionary(extension_id, &extension); |
661 return extension; | 694 return extension; |
662 } | 695 } |
663 | 696 |
697 DictionaryValue* ExtensionPrefs::GetExtensionControlledPrefs( | |
698 const std::string& extension_id) const { | |
699 DictionaryValue* extension = GetExtensionPref(extension_id); | |
700 if (!extension) | |
701 return NULL; | |
702 DictionaryValue* preferences = NULL; | |
703 extension->GetDictionary(kPrefPreferences, &preferences); | |
704 return preferences; | |
705 } | |
706 | |
664 // Helper function for GetInstalledExtensionsInfo. | 707 // Helper function for GetInstalledExtensionsInfo. |
665 static ExtensionInfo* GetInstalledExtensionInfoImpl( | 708 static ExtensionInfo* GetInstalledExtensionInfoImpl( |
666 DictionaryValue* extension_data, | 709 DictionaryValue* extension_data, |
667 DictionaryValue::key_iterator extension_id) { | 710 DictionaryValue::key_iterator extension_id) { |
668 DictionaryValue* ext; | 711 DictionaryValue* ext; |
669 if (!extension_data->GetDictionaryWithoutPathExpansion(*extension_id, &ext)) { | 712 if (!extension_data->GetDictionaryWithoutPathExpansion(*extension_id, &ext)) { |
670 LOG(WARNING) << "Invalid pref for extension " << *extension_id; | 713 LOG(WARNING) << "Invalid pref for extension " << *extension_id; |
671 NOTREACHED(); | 714 NOTREACHED(); |
672 return NULL; | 715 return NULL; |
673 } | 716 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 std::string ExtensionPrefs::GetUpdateUrlData(const std::string& extension_id) { | 956 std::string ExtensionPrefs::GetUpdateUrlData(const std::string& extension_id) { |
914 DictionaryValue* dictionary = GetExtensionPref(extension_id); | 957 DictionaryValue* dictionary = GetExtensionPref(extension_id); |
915 if (!dictionary) | 958 if (!dictionary) |
916 return std::string(); | 959 return std::string(); |
917 | 960 |
918 std::string data; | 961 std::string data; |
919 dictionary->GetString(kUpdateUrlData, &data); | 962 dictionary->GetString(kUpdateUrlData, &data); |
920 return data; | 963 return data; |
921 } | 964 } |
922 | 965 |
966 base::Time ExtensionPrefs::GetCurrentTime() const { | |
967 return base::Time::Now(); | |
968 } | |
969 | |
970 base::Time ExtensionPrefs::GetInstallTime(const DictionaryValue* extension) | |
971 const { | |
972 DCHECK(extension); | |
973 std::string install_time_str("0"); | |
974 extension->GetString(kPrefInstallTime, &install_time_str); | |
975 int64 install_time_i64 = 0; | |
976 base::StringToInt64(install_time_str, &install_time_i64); | |
977 LOG_IF(ERROR, install_time_i64 == 0) | |
978 << "Error parsing installation time of an extension"; | |
979 return base::Time::FromInternalValue(install_time_i64); | |
980 } | |
981 | |
982 void ExtensionPrefs::InstallPersistedExtensionControlledPrefs() { | |
983 // When this is called, the PrefService is initialized and provides access | |
984 // to the user preferences stored in a JSON file. We take the persisted | |
985 // preferences of all extensions, calculate the effective preferences | |
986 // (considering that one extension overrides preferences of other extensions) | |
987 // and store the effective preferences in the PrefService. | |
988 | |
989 const DictionaryValue* extensions = | |
990 pref_service()->GetDictionary(kExtensionsPref); | |
991 | |
992 // Collect extensions, sorted by time (latest installed appears last). | |
993 std::vector<DictionaryValue*> sorted_extensions; | |
994 for (DictionaryValue::key_iterator ext_id = extensions->begin_keys(); | |
995 ext_id != extensions->end_keys(); ++ext_id) { | |
996 if (GetExtensionState(*ext_id) != Extension::ENABLED) | |
997 continue; | |
998 | |
999 DictionaryValue* extension = GetExtensionPref(*ext_id); | |
1000 CHECK(extension != NULL); | |
1001 | |
1002 if (GetInstallTime(extension) == base::Time::FromInternalValue(0)) { | |
1003 // Fix old entry that did not get an installation time entry when | |
1004 // it was installed. | |
1005 const base::Time installTime = GetCurrentTime(); | |
1006 extension->Set(kPrefInstallTime, | |
1007 Value::CreateStringValue( | |
1008 base::Int64ToString(installTime.ToInternalValue()))); | |
1009 SavePrefsAndNotify(); | |
1010 } | |
1011 DictionaryValue* dummy_prefs; | |
1012 if (!extension->GetDictionary(kPrefPreferences, &dummy_prefs)) { | |
1013 extension->Set(kPrefPreferences, new DictionaryValue()); | |
1014 } | |
1015 | |
1016 // Currently we sort only by time, no tie-breaker. | |
1017 std::vector<DictionaryValue*>::iterator insert_pos = | |
1018 sorted_extensions.begin(); | |
1019 while (insert_pos != sorted_extensions.end() && | |
1020 GetInstallTime(extension) > GetInstallTime(*insert_pos)) { | |
1021 ++insert_pos; | |
1022 } | |
1023 sorted_extensions.insert(insert_pos, extension); | |
1024 } | |
1025 | |
1026 // Collect all effective preferences (later ones override newer ones). | |
1027 scoped_ptr<DictionaryValue> merged_non_expanded(new DictionaryValue); | |
1028 for (std::vector<DictionaryValue*>::iterator i = sorted_extensions.begin(); | |
1029 i != sorted_extensions.end(); ++i) { | |
1030 DictionaryValue* preferences; | |
1031 if ((*i)->GetDictionary(kPrefPreferences, &preferences)) | |
1032 merged_non_expanded->MergeDictionary(preferences); | |
1033 } | |
1034 | |
1035 // Expand all keys. | |
1036 scoped_ptr<InMemoryPrefStore> extension_prefs(new InMemoryPrefStore); | |
1037 for (DictionaryValue::key_iterator prefkey = | |
1038 merged_non_expanded->begin_keys(); | |
1039 prefkey != merged_non_expanded->end_keys(); | |
1040 ++prefkey) { | |
1041 Value* value; | |
1042 CHECK(merged_non_expanded->GetWithoutPathExpansion(*prefkey, &value)); | |
1043 extension_prefs->prefs()->Set(*prefkey, value->DeepCopy()); | |
1044 } | |
1045 | |
1046 // Store result in pref service. | |
1047 pref_service()->pref_value_store()->ReplaceExtensionPrefStore( | |
1048 extension_prefs.release()); | |
1049 } | |
1050 | |
1051 namespace subtle { | |
1052 static bool equalValues(const Value* a, const Value* b) { | |
1053 if ((a == NULL) && (b == NULL)) return true; | |
1054 if ((a == NULL) ^ (b == NULL)) return false; | |
1055 return a->Equals(b); | |
1056 } | |
1057 } | |
1058 | |
1059 const Value* ExtensionPrefs::WinningExtensionControlledPrefValue( | |
1060 const std::string& key) const { | |
1061 Value *winner = NULL; | |
1062 int64 winners_install_time = 0; | |
1063 | |
1064 const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); | |
1065 for (DictionaryValue::key_iterator ext_iter = extensions->begin_keys(); | |
1066 ext_iter != extensions->end_keys(); ++ext_iter) { | |
1067 if (GetExtensionState(*ext_iter) != Extension::ENABLED) | |
1068 continue; | |
1069 | |
1070 DictionaryValue* extension = GetExtensionPref(*ext_iter); | |
1071 CHECK(extension); | |
1072 | |
1073 std::string extension_install_time_s = "0"; | |
1074 extension->GetString(kPrefInstallTime, &extension_install_time_s); | |
1075 int64 extension_install_time = 0; | |
1076 base::StringToInt64(extension_install_time_s, &extension_install_time); | |
1077 | |
1078 // We do not need to consider extensions that were installed before the | |
1079 // most recent extension found that provides the requested preference. | |
1080 if (extension_install_time < winners_install_time) { | |
1081 continue; | |
1082 } | |
1083 | |
1084 DictionaryValue* preferences = GetExtensionControlledPrefs(*ext_iter); | |
1085 CHECK(preferences); | |
1086 | |
1087 Value *value = NULL; | |
1088 if (preferences->GetWithoutPathExpansion(key, &value)) { | |
1089 // This extension is more recent than the last one providing this pref. | |
1090 winner = value; | |
1091 winners_install_time = extension_install_time; | |
1092 } | |
1093 } | |
1094 return winner; | |
1095 } | |
1096 | |
1097 void ExtensionPrefs::UpdateWinningPref(const std::string& pref_key) { | |
1098 PrefStore* extensionPrefStore = | |
1099 pref_service()->pref_value_store()->GetExtensionPrefStore(); | |
1100 const Value* winningPrefValue = WinningExtensionControlledPrefValue(pref_key); | |
1101 Value* oldValue = NULL; | |
1102 extensionPrefStore->prefs()->Get(pref_key, &oldValue); | |
1103 bool changed = !subtle::equalValues(winningPrefValue, oldValue); | |
1104 | |
1105 if (winningPrefValue) { | |
1106 extensionPrefStore->prefs()->Set(pref_key, winningPrefValue->DeepCopy()); | |
1107 } else { | |
1108 extensionPrefStore->prefs()->Remove(pref_key, NULL); | |
1109 } | |
1110 | |
1111 if (changed) | |
1112 pref_service()->pref_notifier()->OnPreferenceSet( | |
1113 pref_key.c_str(), PrefNotifier::EXTENSION_STORE); | |
1114 } | |
1115 | |
1116 void ExtensionPrefs::SetExtensionControlledPref(const std::string& extension_id, | |
1117 const std::string& pref_key, | |
1118 Value* value) { | |
1119 DictionaryValue* extensionPreferences = | |
1120 GetExtensionControlledPrefs(extension_id); | |
1121 | |
1122 Value* oldValue = NULL; | |
1123 extensionPreferences->GetWithoutPathExpansion(pref_key, &oldValue); | |
1124 bool modified = subtle::equalValues(oldValue, value); | |
1125 | |
1126 if (value == NULL) | |
1127 extensionPreferences->RemoveWithoutPathExpansion(pref_key, NULL); | |
1128 else | |
1129 extensionPreferences->SetWithoutPathExpansion(pref_key, value); | |
1130 | |
1131 if (modified) | |
1132 pref_service()->ScheduleSavePersistentPrefs(); | |
1133 | |
1134 UpdateWinningPref(pref_key); | |
1135 } | |
1136 | |
1137 void ExtensionPrefs::GetExtensionControlledPrefKeys( | |
1138 const std::string& extension_id, std::vector<std::string> *out) const { | |
1139 DCHECK(out != NULL); | |
1140 DictionaryValue* extPrefs = GetExtensionControlledPrefs(extension_id); | |
1141 if (extPrefs) { | |
1142 for (DictionaryValue::key_iterator i = extPrefs->begin_keys(); | |
1143 i != extPrefs->end_keys(); ++i) { | |
1144 out->push_back(*i); | |
1145 } | |
1146 } | |
1147 } | |
1148 | |
923 // static | 1149 // static |
924 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { | 1150 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { |
925 prefs->RegisterDictionaryPref(kExtensionsPref); | 1151 prefs->RegisterDictionaryPref(kExtensionsPref); |
926 prefs->RegisterListPref(kExtensionToolbar); | 1152 prefs->RegisterListPref(kExtensionToolbar); |
927 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); | 1153 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); |
928 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); | 1154 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); |
929 prefs->RegisterListPref(prefs::kExtensionInstallAllowList); | 1155 prefs->RegisterListPref(prefs::kExtensionInstallAllowList); |
930 prefs->RegisterListPref(prefs::kExtensionInstallDenyList); | 1156 prefs->RegisterListPref(prefs::kExtensionInstallDenyList); |
931 prefs->RegisterListPref(prefs::kExtensionInstallForceList); | 1157 prefs->RegisterListPref(prefs::kExtensionInstallForceList); |
932 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */); | 1158 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */); |
933 } | 1159 } |
OLD | NEW |