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/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 | 185 |
186 // A list of installed ids and a signature. | 186 // A list of installed ids and a signature. |
187 const char kInstallSignature[] = "extensions.install_signature"; | 187 const char kInstallSignature[] = "extensions.install_signature"; |
188 | 188 |
189 // A boolean preference that indicates whether the extension should not be | 189 // A boolean preference that indicates whether the extension should not be |
190 // synced. Default value is false. | 190 // synced. Default value is false. |
191 const char kPrefDoNotSync[] = "do_not_sync"; | 191 const char kPrefDoNotSync[] = "do_not_sync"; |
192 | 192 |
193 const char kCorruptedDisableCount[] = "extensions.corrupted_disable_count"; | 193 const char kCorruptedDisableCount[] = "extensions.corrupted_disable_count"; |
194 | 194 |
195 // A boolean preference that indicates whether the extension has local changes | |
196 // that need to be synced. Default value is false. | |
197 const char kPrefNeedsSync[] = "needs_sync"; | |
198 | |
195 // Provider of write access to a dictionary storing extension prefs. | 199 // Provider of write access to a dictionary storing extension prefs. |
196 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { | 200 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { |
197 public: | 201 public: |
198 ScopedExtensionPrefUpdate(PrefService* service, | 202 ScopedExtensionPrefUpdate(PrefService* service, |
199 const std::string& extension_id) : | 203 const std::string& extension_id) : |
200 DictionaryPrefUpdate(service, pref_names::kExtensions), | 204 DictionaryPrefUpdate(service, pref_names::kExtensions), |
201 extension_id_(extension_id) {} | 205 extension_id_(extension_id) {} |
202 | 206 |
203 ~ScopedExtensionPrefUpdate() override {} | 207 ~ScopedExtensionPrefUpdate() override {} |
204 | 208 |
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1845 | 1849 |
1846 int ExtensionPrefs::GetCorruptedDisableCount() const { | 1850 int ExtensionPrefs::GetCorruptedDisableCount() const { |
1847 return prefs_->GetInteger(kCorruptedDisableCount); | 1851 return prefs_->GetInteger(kCorruptedDisableCount); |
1848 } | 1852 } |
1849 | 1853 |
1850 void ExtensionPrefs::IncrementCorruptedDisableCount() { | 1854 void ExtensionPrefs::IncrementCorruptedDisableCount() { |
1851 int count = prefs_->GetInteger(kCorruptedDisableCount); | 1855 int count = prefs_->GetInteger(kCorruptedDisableCount); |
1852 prefs_->SetInteger(kCorruptedDisableCount, count + 1); | 1856 prefs_->SetInteger(kCorruptedDisableCount, count + 1); |
1853 } | 1857 } |
1854 | 1858 |
1859 bool ExtensionPrefs::NeedsSync(const std::string& extension_id) const { | |
1860 bool needs_sync; | |
1861 if (!ReadPrefAsBoolean(extension_id, kPrefNeedsSync, &needs_sync)) | |
1862 return false; | |
1863 | |
1864 return needs_sync; | |
not at google - send to devlin
2015/07/15 20:27:57
Looks like there is a helper to simplify this, "Re
Marc Treib
2015/07/16 09:22:34
Indeed! Thanks, done.
| |
1865 } | |
1866 | |
1867 void ExtensionPrefs::SetNeedsSync(const std::string& extension_id, | |
1868 bool needs_sync) { | |
1869 UpdateExtensionPref(extension_id, kPrefNeedsSync, | |
1870 needs_sync ? new base::FundamentalValue(true) : nullptr); | |
1871 } | |
1872 | |
1855 ExtensionPrefs::ExtensionPrefs( | 1873 ExtensionPrefs::ExtensionPrefs( |
1856 PrefService* prefs, | 1874 PrefService* prefs, |
1857 const base::FilePath& root_dir, | 1875 const base::FilePath& root_dir, |
1858 ExtensionPrefValueMap* extension_pref_value_map, | 1876 ExtensionPrefValueMap* extension_pref_value_map, |
1859 scoped_ptr<AppSorting> app_sorting, | 1877 scoped_ptr<AppSorting> app_sorting, |
1860 scoped_ptr<TimeProvider> time_provider, | 1878 scoped_ptr<TimeProvider> time_provider, |
1861 bool extensions_disabled, | 1879 bool extensions_disabled, |
1862 const std::vector<ExtensionPrefsObserver*>& early_observers) | 1880 const std::vector<ExtensionPrefsObserver*>& early_observers) |
1863 : prefs_(prefs), | 1881 : prefs_(prefs), |
1864 install_directory_(root_dir), | 1882 install_directory_(root_dir), |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2109 extension_pref_value_map_->RegisterExtension( | 2127 extension_pref_value_map_->RegisterExtension( |
2110 extension_id, install_time, is_enabled, is_incognito_enabled); | 2128 extension_id, install_time, is_enabled, is_incognito_enabled); |
2111 | 2129 |
2112 FOR_EACH_OBSERVER( | 2130 FOR_EACH_OBSERVER( |
2113 ExtensionPrefsObserver, | 2131 ExtensionPrefsObserver, |
2114 observer_list_, | 2132 observer_list_, |
2115 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2133 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
2116 } | 2134 } |
2117 | 2135 |
2118 } // namespace extensions | 2136 } // namespace extensions |
OLD | NEW |