Chromium Code Reviews| 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 <string> | |
| 9 | |
| 10 #include "chrome/browser/prefs/pref_registry.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class DictionaryValue; | |
| 14 class ListValue; | |
| 15 class Value; | |
| 16 } | |
| 17 | |
| 18 class FilePath; | |
| 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; | |
|
Mattias Nissler (ping if slow)
2013/01/31 15:30:19
Callback needs #include or forward-declaration
| |
| 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 // Exactly one callback can be set for the event of a syncable | |
| 36 // preference being registered. It will be fired after the | |
| 37 // registration has occurred. | |
| 38 // | |
| 39 // Calling this method after a callback has already been set will | |
| 40 // make the object forget the previous callback and use the new one | |
| 41 // instead. | |
| 42 void SetSyncableRegistrationCallback(const SyncableRegistrationCallback& cb); | |
| 43 | |
| 44 void RegisterBooleanPref(const char* path, | |
| 45 bool default_value, | |
| 46 PrefSyncStatus sync_status); | |
| 47 void RegisterIntegerPref(const char* path, | |
| 48 int default_value, | |
| 49 PrefSyncStatus sync_status); | |
| 50 void RegisterDoublePref(const char* path, | |
| 51 double default_value, | |
| 52 PrefSyncStatus sync_status); | |
| 53 void RegisterStringPref(const char* path, | |
| 54 const std::string& default_value, | |
| 55 PrefSyncStatus sync_status); | |
| 56 void RegisterFilePathPref(const char* path, | |
| 57 const FilePath& default_value, | |
| 58 PrefSyncStatus sync_status); | |
| 59 void RegisterListPref(const char* path, | |
| 60 PrefSyncStatus sync_status); | |
| 61 void RegisterDictionaryPref(const char* path, | |
| 62 PrefSyncStatus sync_status); | |
| 63 void RegisterListPref(const char* path, | |
| 64 base::ListValue* default_value, | |
| 65 PrefSyncStatus sync_status); | |
| 66 void RegisterDictionaryPref(const char* path, | |
| 67 base::DictionaryValue* default_value, | |
| 68 PrefSyncStatus sync_status); | |
| 69 void RegisterLocalizedBooleanPref(const char* path, | |
| 70 int locale_default_message_id, | |
| 71 PrefSyncStatus sync_status); | |
| 72 void RegisterLocalizedIntegerPref(const char* path, | |
| 73 int locale_default_message_id, | |
| 74 PrefSyncStatus sync_status); | |
| 75 void RegisterLocalizedDoublePref(const char* path, | |
| 76 int locale_default_message_id, | |
| 77 PrefSyncStatus sync_status); | |
| 78 void RegisterLocalizedStringPref(const char* path, | |
| 79 int locale_default_message_id, | |
| 80 PrefSyncStatus sync_status); | |
| 81 void RegisterInt64Pref(const char* path, | |
| 82 int64 default_value, | |
| 83 PrefSyncStatus sync_status); | |
| 84 void RegisterUint64Pref(const char* path, | |
| 85 uint64 default_value, | |
| 86 PrefSyncStatus sync_status); | |
| 87 | |
| 88 private: | |
| 89 virtual ~PrefRegistrySyncable(); | |
| 90 | |
| 91 void RegisterSyncablePreference(const char* path, | |
| 92 base::Value* default_value, | |
| 93 PrefSyncStatus sync_status); | |
| 94 | |
| 95 SyncableRegistrationCallback callback_; | |
|
Mattias Nissler (ping if slow)
2013/01/31 15:30:19
DISALLOW_COPY_AND_ASSIGN
| |
| 96 }; | |
| 97 | |
| 98 #endif // CHROME_BROWSER_PREFS_PREF_REGISTRY_SYNCABLE_H_ | |
| OLD | NEW |