OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ | 5 #ifndef CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ |
6 #define CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ | 6 #define CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "chrome/browser/prefs/pref_service_syncable.h" | |
13 #include "chrome/browser/prefs/synced_pref_observer.h" | 12 #include "chrome/browser/prefs/synced_pref_observer.h" |
14 | 13 |
| 14 class PrefServiceSyncable; |
| 15 |
15 // Manages the registration of one or more SyncedPrefObservers on a | 16 // Manages the registration of one or more SyncedPrefObservers on a |
16 // PrefServiceSyncable. This is modeled after base::PrefChangeRegistrar, and | 17 // PrefServiceSyncable. This is modeled after base::PrefChangeRegistrar, and |
17 // it should be used whenever it's necessary to determine whether a pref change | 18 // it should be used whenever it's necessary to determine whether a pref change |
18 // has come from sync or from some other mechanism (managed, UI, external, etc.) | 19 // has come from sync or from some other mechanism (managed, UI, external, etc.) |
19 class SyncedPrefChangeRegistrar : public SyncedPrefObserver { | 20 class SyncedPrefChangeRegistrar : public SyncedPrefObserver { |
20 public: | 21 public: |
21 // Registered callbacks may optionally take a path argument. | 22 // Registered callbacks may optionally take a path argument. |
22 // The boolean argument indicates whether (true) or not (false) | 23 // The boolean argument indicates whether (true) or not (false) |
23 // the change was a result of syncing. | 24 // the change was a result of syncing. |
24 typedef base::Callback<void(bool)> ChangeCallback; | 25 typedef base::Callback<void(bool)> ChangeCallback; |
(...skipping 23 matching lines...) Expand all Loading... |
48 | 49 |
49 typedef std::map<std::string, NamedChangeCallback> ObserverMap; | 50 typedef std::map<std::string, NamedChangeCallback> ObserverMap; |
50 | 51 |
51 PrefServiceSyncable* pref_service_; | 52 PrefServiceSyncable* pref_service_; |
52 ObserverMap observers_; | 53 ObserverMap observers_; |
53 | 54 |
54 DISALLOW_COPY_AND_ASSIGN(SyncedPrefChangeRegistrar); | 55 DISALLOW_COPY_AND_ASSIGN(SyncedPrefChangeRegistrar); |
55 }; | 56 }; |
56 | 57 |
57 #endif // CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ | 58 #endif // CHROME_BROWSER_PREFS_SYNCED_PREF_CHANGE_REGISTRAR_H_ |
OLD | NEW |