Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chrome/browser/prefs/pref_service_syncable.h

Issue 1305213009: Componentize PrefSyncableService and support classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pref_service_syncable
Patch Set: Add missing dependency on //sync:test_support_sync_api for unit tests with gn Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_
6 #define CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_
7
8 #include <vector>
9
10 #include "base/callback_forward.h"
11 #include "base/prefs/pref_service.h"
12 #include "chrome/browser/prefs/pref_model_associator.h"
13 #include "chrome/browser/prefs/synced_pref_observer.h"
14 #include "components/pref_registry/pref_registry_syncable.h"
15
16 class PrefModelAssociatorClient;
17 class PrefServiceSyncableObserver;
18
19 namespace syncer {
20 class SyncableService;
21 }
22
23 // A PrefService that can be synced. Users are forced to declare
24 // whether preferences are syncable or not when registering them to
25 // this PrefService.
26 class PrefServiceSyncable : public PrefService {
27 public:
28 // You may wish to use PrefServiceFactory or one of its subclasses
29 // for simplified construction.
30 PrefServiceSyncable(
31 PrefNotifierImpl* pref_notifier,
32 PrefValueStore* pref_value_store,
33 PersistentPrefStore* user_prefs,
34 user_prefs::PrefRegistrySyncable* pref_registry,
35 const PrefModelAssociatorClient* pref_model_associato_client,
36 base::Callback<void(PersistentPrefStore::PrefReadError)>
37 read_error_callback,
38 bool async);
39 ~PrefServiceSyncable() override;
40
41 // Creates an incognito copy of the pref service that shares most pref stores
42 // but uses a fresh non-persistent overlay for the user pref store and an
43 // individual extension pref store (to cache the effective extension prefs for
44 // incognito windows). |overlay_pref_names| is a list of preference names
45 // whose changes will not be persisted by the returned incognito pref service.
46 PrefServiceSyncable* CreateIncognitoPrefService(
47 PrefStore* incognito_extension_pref_store,
48 const std::vector<const char*>& overlay_pref_names);
49
50 // Returns true if preferences state has synchronized with the remote
51 // preferences. If true is returned it can be assumed the local preferences
52 // has applied changes from the remote preferences. The two may not be
53 // identical if a change is in flight (from either side).
54 //
55 // TODO(albertb): Given that we now support priority preferences, callers of
56 // this method are likely better off making the preferences they care about
57 // into priority preferences and calling IsPrioritySyncing().
58 bool IsSyncing();
59
60 // Returns true if priority preferences state has synchronized with the remote
61 // priority preferences.
62 bool IsPrioritySyncing();
63
64 // Returns true if the pref under the given name is pulled down from sync.
65 // Note this does not refer to SYNCABLE_PREF.
66 bool IsPrefSynced(const std::string& name) const;
67
68 void AddObserver(PrefServiceSyncableObserver* observer);
69 void RemoveObserver(PrefServiceSyncableObserver* observer);
70
71 // TODO(zea): Have PrefServiceSyncable implement
72 // syncer::SyncableService directly.
73 syncer::SyncableService* GetSyncableService(const syncer::ModelType& type);
74
75 // Do not call this after having derived an incognito or per tab pref service.
76 void UpdateCommandLinePrefStore(PrefStore* cmd_line_store) override;
77
78 void AddSyncedPrefObserver(const std::string& name,
79 SyncedPrefObserver* observer);
80 void RemoveSyncedPrefObserver(const std::string& name,
81 SyncedPrefObserver* observer);
82
83 protected:
84 // Set the PrefModelAssociatorClient to use for that object during tests.
85 void SetPrefModelAssociatorClientForTesting(
86 const PrefModelAssociatorClient* pref_model_associator_client);
87
88 private:
89 friend class PrefModelAssociator;
90
91 void AddRegisteredSyncablePreference(const std::string& path, uint32 flags);
92
93 // Invoked internally when the IsSyncing() state changes.
94 void OnIsSyncingChanged();
95
96 // Process a local preference change. This can trigger new SyncChanges being
97 // sent to the syncer.
98 void ProcessPrefChange(const std::string& name);
99
100 // Whether CreateIncognitoPrefService() has been called to create a
101 // "forked" PrefService.
102 bool pref_service_forked_;
103
104 PrefModelAssociator pref_sync_associator_;
105 PrefModelAssociator priority_pref_sync_associator_;
106
107 base::ObserverList<PrefServiceSyncableObserver> observer_list_;
108
109 DISALLOW_COPY_AND_ASSIGN(PrefServiceSyncable);
110 };
111
112 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service_mock_factory.cc ('k') | chrome/browser/prefs/pref_service_syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698