Index: chrome/browser/prefs/pref_model_associator.h |
diff --git a/chrome/browser/prefs/pref_model_associator.h b/chrome/browser/prefs/pref_model_associator.h |
index 584e27172252a7b7853654bc33d9fe3f1e6f9e28..539d38a301c9b71d15547053c8c8093cd5268cd0 100644 |
--- a/chrome/browser/prefs/pref_model_associator.h |
+++ b/chrome/browser/prefs/pref_model_associator.h |
@@ -11,7 +11,10 @@ |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
+#include "base/containers/hash_tables.h" |
+#include "base/observer_list.h" |
#include "base/threading/non_thread_safe.h" |
+#include "chrome/browser/prefs/synced_pref_observer.h" |
#include "sync/api/sync_data.h" |
#include "sync/api/syncable_service.h" |
@@ -97,6 +100,14 @@ class PrefModelAssociator |
// Note this does not refer to SYNCABLE_PREF. |
bool IsPrefSynced(const std::string& name) const; |
+ // Adds a SyncedPrefObserver to watch for changes to a specific pref. |
+ void AddSyncedPrefObserver(const std::string& name, |
+ SyncedPrefObserver* observer); |
+ |
+ // Removes a SyncedPrefObserver from a pref's list of observers. |
+ void RemoveSyncedPrefObserver(const std::string& name, |
+ SyncedPrefObserver* observer); |
+ |
protected: |
friend class ProfileSyncServicePreferenceTest; |
@@ -157,6 +168,18 @@ class PrefModelAssociator |
// PRIORITY_PREFERENCES. |
syncer::ModelType type_; |
+ private: |
+ // Map prefs to lists of observers. Observers will receive notification when |
+ // a pref changes, including the detail of whether or not the change came |
+ // from sync. |
+ typedef ObserverList<SyncedPrefObserver> SyncedPrefObserverList; |
+ typedef base::hash_map<std::string, SyncedPrefObserverList*> |
+ SyncedPrefObserverMap; |
+ |
+ void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; |
+ |
+ SyncedPrefObserverMap synced_pref_observers_; |
+ |
DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); |
}; |