summaryrefslogtreecommitdiffstats
path: root/components/user_prefs
diff options
context:
space:
mode:
authoralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-27 22:18:55 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-27 22:18:55 +0000
commit43fe640e64aac277a5e0b28fe6b58d2973164df8 (patch)
tree367962ca89c283d63bb3ef810e6593f3b0317811 /components/user_prefs
parentcbe30167853f161d2aaa16846d9b8bea16027858 (diff)
downloadchromium_src-43fe640e64aac277a5e0b28fe6b58d2973164df8.zip
chromium_src-43fe640e64aac277a5e0b28fe6b58d2973164df8.tar.gz
chromium_src-43fe640e64aac277a5e0b28fe6b58d2973164df8.tar.bz2
sync: Implementation of Priority Preferences.
Priority preferences are similar to normal preferences but are never encrypted and are synced ahead of other datatypes. Because they're never encrypted, on first sync, they can be synced immediately after login, before the user is prompted for a passphrase. Expected uses of priority preferences include hardware setting (eg. trackpad speed, scroll direction, etc.) as well as settings that could be 2-way synced with existing Google Account settings (eg. language). BUG=168648 Review URL: https://chromiumcodereview.appspot.com/12033093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/user_prefs')
-rw-r--r--components/user_prefs/pref_registry_syncable.cc9
-rw-r--r--components/user_prefs/pref_registry_syncable.h20
2 files changed, 19 insertions, 10 deletions
diff --git a/components/user_prefs/pref_registry_syncable.cc b/components/user_prefs/pref_registry_syncable.cc
index 874f8a6..81eb65c 100644
--- a/components/user_prefs/pref_registry_syncable.cc
+++ b/components/user_prefs/pref_registry_syncable.cc
@@ -62,7 +62,7 @@ PrefRegistrySyncable::PrefRegistrySyncable() {
PrefRegistrySyncable::~PrefRegistrySyncable() {
}
-const std::set<std::string>&
+const PrefRegistrySyncable::PrefToStatus&
PrefRegistrySyncable::syncable_preferences() const {
return syncable_preferences_;
}
@@ -202,11 +202,12 @@ void PrefRegistrySyncable::RegisterSyncablePreference(
PrefSyncStatus sync_status) {
PrefRegistry::RegisterPreference(path, default_value);
- if (sync_status == SYNCABLE_PREF) {
- syncable_preferences_.insert(path);
+ if (sync_status == PrefRegistrySyncable::SYNCABLE_PREF ||
+ sync_status == PrefRegistrySyncable::SYNCABLE_PRIORITY_PREF) {
+ syncable_preferences_[path] = sync_status;
if (!callback_.is_null())
- callback_.Run(path);
+ callback_.Run(path, sync_status);
}
}
diff --git a/components/user_prefs/pref_registry_syncable.h b/components/user_prefs/pref_registry_syncable.h
index 08477f2..811209b 100644
--- a/components/user_prefs/pref_registry_syncable.h
+++ b/components/user_prefs/pref_registry_syncable.h
@@ -30,19 +30,27 @@ class Value;
// does this for Chrome.
class USER_PREFS_EXPORT PrefRegistrySyncable : public PrefRegistry {
public:
- typedef base::Callback<void(const char* path)> SyncableRegistrationCallback;
-
// Enum used when registering preferences to determine if it should
- // be synced or not.
+ // be synced or not. Syncable priority preferences are preferences that are
+ // never encrypted and are synced before other datatypes. Because they're
+ // never encrypted, on first sync, they can be synced down before the user
+ // is prompted for a passphrase.
enum PrefSyncStatus {
UNSYNCABLE_PREF,
- SYNCABLE_PREF
+ SYNCABLE_PREF,
+ SYNCABLE_PRIORITY_PREF,
};
+ typedef
+ base::Callback<void(const char* path, const PrefSyncStatus sync_status)>
+ SyncableRegistrationCallback;
+
PrefRegistrySyncable();
+ typedef std::map<std::string, PrefSyncStatus> PrefToStatus;
+
// Retrieve the set of syncable preferences currently registered.
- const std::set<std::string>& syncable_preferences() const;
+ const PrefToStatus& syncable_preferences() const;
// Exactly one callback can be set for the event of a syncable
// preference being registered. It will be fired after the
@@ -111,7 +119,7 @@ class USER_PREFS_EXPORT PrefRegistrySyncable : public PrefRegistry {
SyncableRegistrationCallback callback_;
// Contains the names of all registered preferences that are syncable.
- std::set<std::string> syncable_preferences_;
+ PrefToStatus syncable_preferences_;
DISALLOW_COPY_AND_ASSIGN(PrefRegistrySyncable);
};