Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_pref_store.h" | 10 #include "chrome/browser/extensions/extension_pref_store.h" |
| 11 #include "chrome/browser/prefs/pref_notifier.h" | 11 #include "chrome/browser/prefs/pref_notifier.h" |
| 12 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 12 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 15 #include "chrome/common/extensions/manifest_value.h" | |
| 15 #include "chrome/common/extensions/url_pattern.h" | 16 #include "chrome/common/extensions/url_pattern.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 19 | 20 |
| 20 using base::Time; | 21 using base::Time; |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 // The number of apps per page. This isn't a hard limit, but new apps installed | 25 // The number of apps per page. This isn't a hard limit, but new apps installed |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1093 extension_dict->Set(kPrefContentSettings, new ListValue()); | 1094 extension_dict->Set(kPrefContentSettings, new ListValue()); |
| 1094 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); | 1095 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); |
| 1095 | 1096 |
| 1096 FilePath::StringType path = MakePathRelative(install_directory_, | 1097 FilePath::StringType path = MakePathRelative(install_directory_, |
| 1097 extension->path()); | 1098 extension->path()); |
| 1098 extension_dict->Set(kPrefPath, Value::CreateStringValue(path)); | 1099 extension_dict->Set(kPrefPath, Value::CreateStringValue(path)); |
| 1099 // We store prefs about LOAD extensions, but don't cache their manifest | 1100 // We store prefs about LOAD extensions, but don't cache their manifest |
| 1100 // since it may change on disk. | 1101 // since it may change on disk. |
| 1101 if (extension->location() != Extension::LOAD) { | 1102 if (extension->location() != Extension::LOAD) { |
| 1102 extension_dict->Set(kPrefManifest, | 1103 extension_dict->Set(kPrefManifest, |
| 1103 extension->manifest_value()->DeepCopy()); | 1104 extension->manifest_value()->value()->DeepCopy()); |
|
Aaron Boodman
2011/11/23 01:45:25
Yeah, calling this thing just "manifest" would mak
jstritar
2011/11/28 23:09:56
Yeah, much better. Done.
| |
| 1104 } | 1105 } |
| 1105 | 1106 |
| 1106 if (extension->is_app()) { | 1107 if (extension->is_app()) { |
| 1107 if (page_index == -1) | 1108 if (page_index == -1) |
| 1108 page_index = GetNaturalAppPageIndex(); | 1109 page_index = GetNaturalAppPageIndex(); |
| 1109 extension_dict->Set(kPrefPageIndex, | 1110 extension_dict->Set(kPrefPageIndex, |
| 1110 Value::CreateIntegerValue(page_index)); | 1111 Value::CreateIntegerValue(page_index)); |
| 1111 extension_dict->Set(kPrefAppLaunchIndex, | 1112 extension_dict->Set(kPrefAppLaunchIndex, |
| 1112 Value::CreateIntegerValue(GetNextAppLaunchIndex(page_index))); | 1113 Value::CreateIntegerValue(GetNextAppLaunchIndex(page_index))); |
| 1113 } | 1114 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1183 } | 1184 } |
| 1184 | 1185 |
| 1185 void ExtensionPrefs::UpdateManifest(const Extension* extension) { | 1186 void ExtensionPrefs::UpdateManifest(const Extension* extension) { |
| 1186 if (extension->location() != Extension::LOAD) { | 1187 if (extension->location() != Extension::LOAD) { |
| 1187 const DictionaryValue* extension_dict = GetExtensionPref(extension->id()); | 1188 const DictionaryValue* extension_dict = GetExtensionPref(extension->id()); |
| 1188 if (!extension_dict) | 1189 if (!extension_dict) |
| 1189 return; | 1190 return; |
| 1190 DictionaryValue* old_manifest = NULL; | 1191 DictionaryValue* old_manifest = NULL; |
| 1191 bool update_required = | 1192 bool update_required = |
| 1192 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || | 1193 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || |
| 1193 !extension->manifest_value()->Equals(old_manifest); | 1194 !extension->manifest_value()->value()->Equals(old_manifest); |
| 1194 if (update_required) { | 1195 if (update_required) { |
| 1195 UpdateExtensionPref(extension->id(), kPrefManifest, | 1196 UpdateExtensionPref(extension->id(), kPrefManifest, |
| 1196 extension->manifest_value()->DeepCopy()); | 1197 extension->manifest_value()->value()->DeepCopy()); |
| 1197 } | 1198 } |
| 1198 } | 1199 } |
| 1199 } | 1200 } |
| 1200 | 1201 |
| 1201 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) { | 1202 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) { |
| 1202 const DictionaryValue* dict = GetExtensionPref(extension_id); | 1203 const DictionaryValue* dict = GetExtensionPref(extension_id); |
| 1203 if (!dict) | 1204 if (!dict) |
| 1204 return FilePath(); | 1205 return FilePath(); |
| 1205 | 1206 |
| 1206 std::string path; | 1207 std::string path; |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1830 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1831 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
| 1831 PrefService::UNSYNCABLE_PREF); | 1832 PrefService::UNSYNCABLE_PREF); |
| 1832 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1833 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
| 1833 PrefService::UNSYNCABLE_PREF); | 1834 PrefService::UNSYNCABLE_PREF); |
| 1834 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1835 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
| 1835 PrefService::UNSYNCABLE_PREF); | 1836 PrefService::UNSYNCABLE_PREF); |
| 1836 prefs->RegisterStringPref(kWebStoreLogin, | 1837 prefs->RegisterStringPref(kWebStoreLogin, |
| 1837 std::string() /* default_value */, | 1838 std::string() /* default_value */, |
| 1838 PrefService::UNSYNCABLE_PREF); | 1839 PrefService::UNSYNCABLE_PREF); |
| 1839 } | 1840 } |
| OLD | NEW |