OLD | NEW |
---|---|
(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_REGISTRY_SYNCABLE_H_ | |
6 #define CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_ | |
7 | |
8 #include <set> | |
9 #include <string> | |
10 | |
11 #include "chrome/browser/prefs/pref_registry.h" | |
12 | |
13 namespace base { | |
14 class DictionaryValue; | |
15 class FilePath; | |
16 class ListValue; | |
17 class Value; | |
18 } | |
19 | |
20 // A PrefRegistry that forces users to choose whether each registered | |
21 // preference is syncable or not. | |
22 class PrefRegistrySyncable : public PrefRegistry { | |
23 public: | |
24 typedef base::Callback<void(const char* path)> SyncableRegistrationCallback; | |
25 | |
26 // Enum used when registering preferences to determine if it should | |
27 // be synced or not. | |
28 enum PrefSyncStatus { | |
29 UNSYNCABLE_PREF, | |
30 SYNCABLE_PREF | |
31 }; | |
32 | |
33 PrefRegistrySyncable(); | |
34 | |
35 // Retrieve the set of syncable preferences currently registered. | |
36 const std::set<std::string>& syncable_preferences() const; | |
37 | |
38 // Exactly one callback can be set for the event of a syncable | |
39 // preference being registered. It will be fired after the | |
40 // registration has occurred. | |
41 // | |
42 // Calling this method after a callback has already been set will | |
43 // make the object forget the previous callback and use the new one | |
44 // instead. | |
45 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb); | |
46 | |
47 void RegisterBooleanPref(const char* path, | |
48 bool default_value, | |
49 PrefSyncStatus sync_status); | |
50 void RegisterIntegerPref(const char* path, | |
51 int default_value, | |
52 PrefSyncStatus sync_status); | |
53 void RegisterDoublePref(const char* path, | |
54 double default_value, | |
55 PrefSyncStatus sync_status); | |
56 void RegisterStringPref(const char* path, | |
57 const std::string& default_value, | |
58 PrefSyncStatus sync_status); | |
59 void RegisterFilePathPref(const char* path, | |
60 const base::FilePath& default_value, | |
61 PrefSyncStatus sync_status); | |
62 void RegisterListPref(const char* path, | |
63 PrefSyncStatus sync_status); | |
64 void RegisterDictionaryPref(const char* path, | |
65 PrefSyncStatus sync_status); | |
66 void RegisterListPref(const char* path, | |
67 base::ListValue* default_value, | |
68 PrefSyncStatus sync_status); | |
69 void RegisterDictionaryPref(const char* path, | |
70 base::DictionaryValue* default_value, | |
71 PrefSyncStatus sync_status); | |
72 void RegisterLocalizedBooleanPref(const char* path, | |
73 int locale_default_message_id, | |
74 PrefSyncStatus sync_status); | |
75 void RegisterLocalizedIntegerPref(const char* path, | |
76 int locale_default_message_id, | |
77 PrefSyncStatus sync_status); | |
78 void RegisterLocalizedDoublePref(const char* path, | |
79 int locale_default_message_id, | |
80 PrefSyncStatus sync_status); | |
81 void RegisterLocalizedStringPref(const char* path, | |
82 int locale_default_message_id, | |
83 PrefSyncStatus sync_status); | |
84 void RegisterInt64Pref(const char* path, | |
85 int64 default_value, | |
86 PrefSyncStatus sync_status); | |
87 void RegisterUint64Pref(const char* path, | |
88 uint64 default_value, | |
89 PrefSyncStatus sync_status); | |
90 | |
91 // Returns a new PrefRegistrySyncable that uses the same defaults | |
92 // store. | |
93 scoped_refptr<PrefRegistrySyncable> ForkForIncognito(); | |
94 | |
95 private: | |
96 virtual ~PrefRegistrySyncable(); | |
97 | |
98 void RegisterSyncablePreference(const char* path, | |
99 base::Value* default_value, | |
100 PrefSyncStatus sync_status); | |
101 | |
102 SyncableRegistrationCallback callback_; | |
103 | |
104 // Contains the names of all registered preferences that are syncable. | |
105 std::set<std::string> syncable_preferences_; | |
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
DISALLOW_COPY_AND_ASSIGN?
Jói
2013/02/07 14:52:32
Done.
| |
106 }; | |
107 | |
108 #endif // CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_ | |
OLD | NEW |