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.h" | |
16 #include "chrome/common/extensions/url_pattern.h" | 15 #include "chrome/common/extensions/url_pattern.h" |
17 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
18 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
19 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
20 | 19 |
21 using base::Time; | 20 using base::Time; |
22 | 21 |
23 namespace { | 22 namespace { |
24 | 23 |
25 // The number of apps per page. This isn't a hard limit, but new apps installed | 24 // The number of apps per page. This isn't a hard limit, but new apps installed |
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 extension_dict->Set(kPrefContentSettings, new ListValue()); | 1099 extension_dict->Set(kPrefContentSettings, new ListValue()); |
1101 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); | 1100 extension_dict->Set(kPrefIncognitoContentSettings, new ListValue()); |
1102 | 1101 |
1103 FilePath::StringType path = MakePathRelative(install_directory_, | 1102 FilePath::StringType path = MakePathRelative(install_directory_, |
1104 extension->path()); | 1103 extension->path()); |
1105 extension_dict->Set(kPrefPath, Value::CreateStringValue(path)); | 1104 extension_dict->Set(kPrefPath, Value::CreateStringValue(path)); |
1106 // We store prefs about LOAD extensions, but don't cache their manifest | 1105 // We store prefs about LOAD extensions, but don't cache their manifest |
1107 // since it may change on disk. | 1106 // since it may change on disk. |
1108 if (extension->location() != Extension::LOAD) { | 1107 if (extension->location() != Extension::LOAD) { |
1109 extension_dict->Set(kPrefManifest, | 1108 extension_dict->Set(kPrefManifest, |
1110 extension->manifest()->value()->DeepCopy()); | 1109 extension->manifest_value()->DeepCopy()); |
1111 } | 1110 } |
1112 | 1111 |
1113 if (extension->is_app()) { | 1112 if (extension->is_app()) { |
1114 if (page_index == -1) | 1113 if (page_index == -1) |
1115 page_index = GetNaturalAppPageIndex(); | 1114 page_index = GetNaturalAppPageIndex(); |
1116 extension_dict->Set(kPrefPageIndex, | 1115 extension_dict->Set(kPrefPageIndex, |
1117 Value::CreateIntegerValue(page_index)); | 1116 Value::CreateIntegerValue(page_index)); |
1118 extension_dict->Set(kPrefAppLaunchIndex, | 1117 extension_dict->Set(kPrefAppLaunchIndex, |
1119 Value::CreateIntegerValue(GetNextAppLaunchIndex(page_index))); | 1118 Value::CreateIntegerValue(GetNextAppLaunchIndex(page_index))); |
1120 } | 1119 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 } | 1189 } |
1191 | 1190 |
1192 void ExtensionPrefs::UpdateManifest(const Extension* extension) { | 1191 void ExtensionPrefs::UpdateManifest(const Extension* extension) { |
1193 if (extension->location() != Extension::LOAD) { | 1192 if (extension->location() != Extension::LOAD) { |
1194 const DictionaryValue* extension_dict = GetExtensionPref(extension->id()); | 1193 const DictionaryValue* extension_dict = GetExtensionPref(extension->id()); |
1195 if (!extension_dict) | 1194 if (!extension_dict) |
1196 return; | 1195 return; |
1197 DictionaryValue* old_manifest = NULL; | 1196 DictionaryValue* old_manifest = NULL; |
1198 bool update_required = | 1197 bool update_required = |
1199 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || | 1198 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || |
1200 !extension->manifest()->value()->Equals(old_manifest); | 1199 !extension->manifest_value()->Equals(old_manifest); |
1201 if (update_required) { | 1200 if (update_required) { |
1202 UpdateExtensionPref(extension->id(), kPrefManifest, | 1201 UpdateExtensionPref(extension->id(), kPrefManifest, |
1203 extension->manifest()->value()->DeepCopy()); | 1202 extension->manifest_value()->DeepCopy()); |
1204 } | 1203 } |
1205 } | 1204 } |
1206 } | 1205 } |
1207 | 1206 |
1208 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) { | 1207 FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) { |
1209 const DictionaryValue* dict = GetExtensionPref(extension_id); | 1208 const DictionaryValue* dict = GetExtensionPref(extension_id); |
1210 if (!dict) | 1209 if (!dict) |
1211 return FilePath(); | 1210 return FilePath(); |
1212 | 1211 |
1213 std::string path; | 1212 std::string path; |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1828 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
1830 PrefService::UNSYNCABLE_PREF); | 1829 PrefService::UNSYNCABLE_PREF); |
1831 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1830 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
1832 PrefService::UNSYNCABLE_PREF); | 1831 PrefService::UNSYNCABLE_PREF); |
1833 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1832 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
1834 PrefService::UNSYNCABLE_PREF); | 1833 PrefService::UNSYNCABLE_PREF); |
1835 prefs->RegisterStringPref(kWebStoreLogin, | 1834 prefs->RegisterStringPref(kWebStoreLogin, |
1836 std::string() /* default_value */, | 1835 std::string() /* default_value */, |
1837 PrefService::UNSYNCABLE_PREF); | 1836 PrefService::UNSYNCABLE_PREF); |
1838 } | 1837 } |
OLD | NEW |