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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 | Annotate | Revision Log
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 "chrome/browser/prefs/pref_model_associator.h"
9 #include "chrome/browser/prefs/pref_service.h"
10
11 // TODO(joi) Move to c/b/prefs and rename PrefServiceSyncableObserver.
12 class PrefServiceObserver;
13
14 namespace syncer {
15 class SyncableService;
16 }
17
18 // A PrefService that can be synced. Users are forced to declare
19 // whether preferences are syncable or not when registering them to
20 // this PrefService.
21 class PrefServiceSyncable : public PrefService {
22 public:
23 // Enum used when registering preferences to determine if it should be synced
24 // or not. This is only used for profile prefs, not local state prefs.
25 // See the Register*Pref methods for profile prefs below.
26 enum PrefSyncStatus {
27 UNSYNCABLE_PREF,
28 SYNCABLE_PREF
29 };
30
31 // You may wish to use PrefServiceBuilder or one of its subclasses
32 // for simplified construction.
33 PrefServiceSyncable(
34 PrefNotifierImpl* pref_notifier,
35 PrefValueStore* pref_value_store,
36 PersistentPrefStore* user_prefs,
37 DefaultPrefStore* default_store,
38 base::Callback<void(PersistentPrefStore::PrefReadError)>
39 read_error_callback,
40 bool async);
41 virtual ~PrefServiceSyncable();
42
43 // Creates an incognito copy of the pref service that shares most pref stores
44 // but uses a fresh non-persistent overlay for the user pref store and an
45 // individual extension pref store (to cache the effective extension prefs for
46 // incognito windows).
47 PrefServiceSyncable* CreateIncognitoPrefService(
48 PrefStore* incognito_extension_prefs);
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 bool IsSyncing();
55
56 void AddObserver(PrefServiceObserver* observer);
57 void RemoveObserver(PrefServiceObserver* observer);
58
59 virtual void UnregisterPreference(const char* path) OVERRIDE;
60
61 void RegisterBooleanPref(const char* path,
62 bool default_value,
63 PrefSyncStatus sync_status);
64 void RegisterIntegerPref(const char* path,
65 int default_value,
66 PrefSyncStatus sync_status);
67 void RegisterDoublePref(const char* path,
68 double default_value,
69 PrefSyncStatus sync_status);
70 void RegisterStringPref(const char* path,
71 const std::string& default_value,
72 PrefSyncStatus sync_status);
73 void RegisterFilePathPref(const char* path,
74 const FilePath& default_value,
75 PrefSyncStatus sync_status);
76 void RegisterListPref(const char* path,
77 PrefSyncStatus sync_status);
78 void RegisterDictionaryPref(const char* path,
79 PrefSyncStatus sync_status);
80 void RegisterListPref(const char* path,
81 base::ListValue* default_value,
82 PrefSyncStatus sync_status);
83 void RegisterDictionaryPref(const char* path,
84 base::DictionaryValue* default_value,
85 PrefSyncStatus sync_status);
86 void RegisterLocalizedBooleanPref(const char* path,
87 int locale_default_message_id,
88 PrefSyncStatus sync_status);
89 void RegisterLocalizedIntegerPref(const char* path,
90 int locale_default_message_id,
91 PrefSyncStatus sync_status);
92 void RegisterLocalizedDoublePref(const char* path,
93 int locale_default_message_id,
94 PrefSyncStatus sync_status);
95 void RegisterLocalizedStringPref(const char* path,
96 int locale_default_message_id,
97 PrefSyncStatus sync_status);
98 void RegisterInt64Pref(const char* path,
99 int64 default_value,
100 PrefSyncStatus sync_status);
101 void RegisterUint64Pref(const char* path,
102 uint64 default_value,
103 PrefSyncStatus sync_status);
104
105 // TODO(zea): Have PrefServiceSyncable implement
106 // syncer::SyncableService directly.
107 syncer::SyncableService* GetSyncableService();
108
109 // Do not call this after having derived an incognito or per tab pref service.
110 virtual void UpdateCommandLinePrefStore(PrefStore* cmd_line_store) OVERRIDE;
111
112 private:
113 friend class PrefModelAssociator;
114
115 // Invoked internally when the IsSyncing() state changes.
116 void OnIsSyncingChanged();
117
118 // Registers a preference at |path| with |default_value|. If the
119 // preference is syncable per |sync_status|, also registers it with
120 // PrefModelAssociator.
121 void RegisterSyncablePreference(const char* path,
122 Value* default_value,
123 PrefSyncStatus sync_status);
124
125 // Whether CreateIncognitoPrefService() has been called to create a
126 // "forked" PrefService.
127 bool pref_service_forked_;
128
129 PrefModelAssociator pref_sync_associator_;
130
131 ObserverList<PrefServiceObserver> observer_list_;
132
133 DISALLOW_COPY_AND_ASSIGN(PrefServiceSyncable);
134 };
135
136 #endif // CHROME_BROWSER_PREFS_PREF_SERVICE_SYNCABLE_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service_simple.cc ('k') | chrome/browser/prefs/pref_service_syncable.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698