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