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 return ReadPrefAsBooleanAndReturn(extension_id, kPrefNeedsSync); |
| 1861 } |
| 1862 |
| 1863 void ExtensionPrefs::SetNeedsSync(const std::string& extension_id, |
| 1864 bool needs_sync) { |
| 1865 UpdateExtensionPref(extension_id, kPrefNeedsSync, |
| 1866 needs_sync ? new base::FundamentalValue(true) : nullptr); |
| 1867 } |
| 1868 |
1855 ExtensionPrefs::ExtensionPrefs( | 1869 ExtensionPrefs::ExtensionPrefs( |
1856 PrefService* prefs, | 1870 PrefService* prefs, |
1857 const base::FilePath& root_dir, | 1871 const base::FilePath& root_dir, |
1858 ExtensionPrefValueMap* extension_pref_value_map, | 1872 ExtensionPrefValueMap* extension_pref_value_map, |
1859 scoped_ptr<AppSorting> app_sorting, | 1873 scoped_ptr<AppSorting> app_sorting, |
1860 scoped_ptr<TimeProvider> time_provider, | 1874 scoped_ptr<TimeProvider> time_provider, |
1861 bool extensions_disabled, | 1875 bool extensions_disabled, |
1862 const std::vector<ExtensionPrefsObserver*>& early_observers) | 1876 const std::vector<ExtensionPrefsObserver*>& early_observers) |
1863 : prefs_(prefs), | 1877 : prefs_(prefs), |
1864 install_directory_(root_dir), | 1878 install_directory_(root_dir), |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2109 extension_pref_value_map_->RegisterExtension( | 2123 extension_pref_value_map_->RegisterExtension( |
2110 extension_id, install_time, is_enabled, is_incognito_enabled); | 2124 extension_id, install_time, is_enabled, is_incognito_enabled); |
2111 | 2125 |
2112 FOR_EACH_OBSERVER( | 2126 FOR_EACH_OBSERVER( |
2113 ExtensionPrefsObserver, | 2127 ExtensionPrefsObserver, |
2114 observer_list_, | 2128 observer_list_, |
2115 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2129 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
2116 } | 2130 } |
2117 | 2131 |
2118 } // namespace extensions | 2132 } // namespace extensions |
OLD | NEW |