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

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

Issue 12033093: sync: Implementation of Priority Preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_PREF_REGISTRY_SYNCABLE_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_
6 #define CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_ 6 #define CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/prefs/pref_registry.h" 11 #include "base/prefs/pref_registry.h"
12 12
13 namespace base { 13 namespace base {
14 class DictionaryValue; 14 class DictionaryValue;
15 class FilePath; 15 class FilePath;
16 class ListValue; 16 class ListValue;
17 class Value; 17 class Value;
18 } 18 }
19 19
20 // A PrefRegistry that forces users to choose whether each registered 20 // A PrefRegistry that forces users to choose whether each registered
21 // preference is syncable or not. 21 // preference is syncable or not.
22 class PrefRegistrySyncable : public PrefRegistry { 22 class PrefRegistrySyncable : public PrefRegistry {
23 public: 23 public:
24 typedef base::Callback<void(const char* path)> SyncableRegistrationCallback;
25
26 // Enum used when registering preferences to determine if it should 24 // Enum used when registering preferences to determine if it should
27 // be synced or not. 25 // be synced or not.
28 enum PrefSyncStatus { 26 enum PrefSyncStatus {
29 UNSYNCABLE_PREF, 27 UNSYNCABLE_PREF,
30 SYNCABLE_PREF 28 SYNCABLE_PREF,
29 SYNCABLE_PRIORITY_PREF,
31 }; 30 };
32 31
32 typedef
33 base::Callback<void(const char* path, const PrefSyncStatus sync_status)>
34 SyncableRegistrationCallback;
35
33 PrefRegistrySyncable(); 36 PrefRegistrySyncable();
34 37
38 typedef std::map<std::string, PrefSyncStatus> PrefToStatus;
39
35 // Retrieve the set of syncable preferences currently registered. 40 // Retrieve the set of syncable preferences currently registered.
36 const std::set<std::string>& syncable_preferences() const; 41 const PrefToStatus& syncable_preferences() const;
37 42
38 // Exactly one callback can be set for the event of a syncable 43 // Exactly one callback can be set for the event of a syncable
39 // preference being registered. It will be fired after the 44 // preference being registered. It will be fired after the
40 // registration has occurred. 45 // registration has occurred.
41 // 46 //
42 // Calling this method after a callback has already been set will 47 // Calling this method after a callback has already been set will
43 // make the object forget the previous callback and use the new one 48 // make the object forget the previous callback and use the new one
44 // instead. 49 // instead.
45 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb); 50 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb);
46 51
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 private: 100 private:
96 virtual ~PrefRegistrySyncable(); 101 virtual ~PrefRegistrySyncable();
97 102
98 void RegisterSyncablePreference(const char* path, 103 void RegisterSyncablePreference(const char* path,
99 base::Value* default_value, 104 base::Value* default_value,
100 PrefSyncStatus sync_status); 105 PrefSyncStatus sync_status);
101 106
102 SyncableRegistrationCallback callback_; 107 SyncableRegistrationCallback callback_;
103 108
104 // Contains the names of all registered preferences that are syncable. 109 // Contains the names of all registered preferences that are syncable.
105 std::set<std::string> syncable_preferences_; 110 PrefToStatus syncable_preferences_;
106 111
107 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable); 112 DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable);
108 }; 113 };
109 114
110 #endif // CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_ 115 #endif // CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698