| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/extension_prefs.h" | 5 #include "extensions/browser/extension_prefs.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_notifier.h" | 10 #include "base/prefs/pref_notifier.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // Am installation parameter bundled with an extension. | 188 // Am installation parameter bundled with an extension. |
| 189 const char kPrefInstallParam[] = "install_parameter"; | 189 const char kPrefInstallParam[] = "install_parameter"; |
| 190 | 190 |
| 191 // A list of installed ids and a signature. | 191 // A list of installed ids and a signature. |
| 192 const char kInstallSignature[] = "extensions.install_signature"; | 192 const char kInstallSignature[] = "extensions.install_signature"; |
| 193 | 193 |
| 194 // A boolean preference that indicates whether the extension should not be | 194 // A boolean preference that indicates whether the extension should not be |
| 195 // synced. Default value is false. | 195 // synced. Default value is false. |
| 196 const char kPrefDoNotSync[] = "do_not_sync"; | 196 const char kPrefDoNotSync[] = "do_not_sync"; |
| 197 | 197 |
| 198 const char kCorruptedDisableCount[] = "extensions.corrupted_disable_count"; |
| 199 |
| 198 // Provider of write access to a dictionary storing extension prefs. | 200 // Provider of write access to a dictionary storing extension prefs. |
| 199 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { | 201 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { |
| 200 public: | 202 public: |
| 201 ScopedExtensionPrefUpdate(PrefService* service, | 203 ScopedExtensionPrefUpdate(PrefService* service, |
| 202 const std::string& extension_id) : | 204 const std::string& extension_id) : |
| 203 DictionaryPrefUpdate(service, pref_names::kExtensions), | 205 DictionaryPrefUpdate(service, pref_names::kExtensions), |
| 204 extension_id_(extension_id) {} | 206 extension_id_(extension_id) {} |
| 205 | 207 |
| 206 virtual ~ScopedExtensionPrefUpdate() { | 208 virtual ~ScopedExtensionPrefUpdate() { |
| 207 } | 209 } |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1888 return install_parameter; | 1890 return install_parameter; |
| 1889 } | 1891 } |
| 1890 | 1892 |
| 1891 void ExtensionPrefs::SetInstallParam(const std::string& extension_id, | 1893 void ExtensionPrefs::SetInstallParam(const std::string& extension_id, |
| 1892 const std::string& install_parameter) { | 1894 const std::string& install_parameter) { |
| 1893 UpdateExtensionPref(extension_id, | 1895 UpdateExtensionPref(extension_id, |
| 1894 kPrefInstallParam, | 1896 kPrefInstallParam, |
| 1895 new base::StringValue(install_parameter)); | 1897 new base::StringValue(install_parameter)); |
| 1896 } | 1898 } |
| 1897 | 1899 |
| 1900 int ExtensionPrefs::GetCorruptedDisableCount() { |
| 1901 return prefs_->GetInteger(kCorruptedDisableCount); |
| 1902 } |
| 1903 |
| 1904 void ExtensionPrefs::IncrementCorruptedDisableCount() { |
| 1905 int count = prefs_->GetInteger(kCorruptedDisableCount); |
| 1906 prefs_->SetInteger(kCorruptedDisableCount, count + 1); |
| 1907 } |
| 1908 |
| 1898 ExtensionPrefs::ExtensionPrefs( | 1909 ExtensionPrefs::ExtensionPrefs( |
| 1899 PrefService* prefs, | 1910 PrefService* prefs, |
| 1900 const base::FilePath& root_dir, | 1911 const base::FilePath& root_dir, |
| 1901 ExtensionPrefValueMap* extension_pref_value_map, | 1912 ExtensionPrefValueMap* extension_pref_value_map, |
| 1902 scoped_ptr<AppSorting> app_sorting, | 1913 scoped_ptr<AppSorting> app_sorting, |
| 1903 scoped_ptr<TimeProvider> time_provider, | 1914 scoped_ptr<TimeProvider> time_provider, |
| 1904 bool extensions_disabled, | 1915 bool extensions_disabled, |
| 1905 const std::vector<ExtensionPrefsObserver*>& early_observers) | 1916 const std::vector<ExtensionPrefsObserver*>& early_observers) |
| 1906 : prefs_(prefs), | 1917 : prefs_(prefs), |
| 1907 install_directory_(root_dir), | 1918 install_directory_(root_dir), |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1995 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 2006 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 1996 | 2007 |
| 1997 registry->RegisterListPref(pref_names::kNativeMessagingBlacklist, | 2008 registry->RegisterListPref(pref_names::kNativeMessagingBlacklist, |
| 1998 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 2009 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 1999 registry->RegisterListPref(pref_names::kNativeMessagingWhitelist, | 2010 registry->RegisterListPref(pref_names::kNativeMessagingWhitelist, |
| 2000 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 2011 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 2001 registry->RegisterBooleanPref( | 2012 registry->RegisterBooleanPref( |
| 2002 pref_names::kNativeMessagingUserLevelHosts, | 2013 pref_names::kNativeMessagingUserLevelHosts, |
| 2003 true, // default value | 2014 true, // default value |
| 2004 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 2015 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 2016 registry->RegisterIntegerPref( |
| 2017 kCorruptedDisableCount, |
| 2018 0, // default value |
| 2019 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 2005 } | 2020 } |
| 2006 | 2021 |
| 2007 template <class ExtensionIdContainer> | 2022 template <class ExtensionIdContainer> |
| 2008 bool ExtensionPrefs::GetUserExtensionPrefIntoContainer( | 2023 bool ExtensionPrefs::GetUserExtensionPrefIntoContainer( |
| 2009 const char* pref, | 2024 const char* pref, |
| 2010 ExtensionIdContainer* id_container_out) { | 2025 ExtensionIdContainer* id_container_out) { |
| 2011 DCHECK(id_container_out->empty()); | 2026 DCHECK(id_container_out->empty()); |
| 2012 | 2027 |
| 2013 const base::Value* user_pref_value = prefs_->GetUserPrefValue(pref); | 2028 const base::Value* user_pref_value = prefs_->GetUserPrefValue(pref); |
| 2014 const base::ListValue* user_pref_as_list; | 2029 const base::ListValue* user_pref_as_list; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 extension_pref_value_map_->RegisterExtension( | 2207 extension_pref_value_map_->RegisterExtension( |
| 2193 extension_id, install_time, is_enabled, is_incognito_enabled); | 2208 extension_id, install_time, is_enabled, is_incognito_enabled); |
| 2194 | 2209 |
| 2195 FOR_EACH_OBSERVER( | 2210 FOR_EACH_OBSERVER( |
| 2196 ExtensionPrefsObserver, | 2211 ExtensionPrefsObserver, |
| 2197 observer_list_, | 2212 observer_list_, |
| 2198 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2213 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
| 2199 } | 2214 } |
| 2200 | 2215 |
| 2201 } // namespace extensions | 2216 } // namespace extensions |
| OLD | NEW |