Chromium Code Reviews| Index: chrome/browser/chromeos/preferences.cc |
| =================================================================== |
| --- chrome/browser/chromeos/preferences.cc (revision 173817) |
| +++ chrome/browser/chromeos/preferences.cc (working copy) |
| @@ -387,6 +387,10 @@ |
| void Preferences::Init(PrefService* prefs) { |
| InitUserPrefs(prefs); |
| + // This causes OnIsSyncingChanged to be called when the value of |
| + // PrefService::IsSyncing() changes. |
| + prefs->AddObserver(this); |
|
xiyuan
2012/12/20 01:44:28
Where do we RemoveObserver?
achuithb
2012/12/20 01:53:31
Done.
|
| + |
| // Initialize preferences to currently saved state. |
| NotifyPrefChanged(NULL); |
| @@ -450,16 +454,9 @@ |
| UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Started", enabled); |
| } |
| if (!pref_name || *pref_name == prefs::kNaturalScroll) { |
| - // Force natural scroll to on if kNaturalScrollDefault is specified on the |
| - // cmd line. |
| - if (CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kNaturalScrollDefault) && |
| - !pref_name && |
| - !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { |
| - natural_scroll_.SetValue(true); |
| - DVLOG(1) << "Natural scroll forced to true"; |
| - UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true); |
| - } |
| + // Force natural scroll default if we've sync'd and if the cmd line arg is |
| + // set. |
| + ForceNaturalScrollDefault(); |
| const bool enabled = natural_scroll_.GetValue(); |
| DVLOG(1) << "Natural scroll set to " << enabled; |
| @@ -677,6 +674,24 @@ |
| } |
| } |
| +void Preferences::OnIsSyncingChanged() { |
| + DVLOG(1) << "OnIsSyncingChanged"; |
| + ForceNaturalScrollDefault(); |
| +} |
| + |
| +void Preferences::ForceNaturalScrollDefault() { |
| + DVLOG(1) << "ForceNaturalScrollDefault"; |
| + if (CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kNaturalScrollDefault) && |
| + prefs_->IsSyncing() && |
| + !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { |
| + DVLOG(1) << "Natural scroll forced to true"; |
| + natural_scroll_.SetValue(true); |
| + UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true); |
| + } |
| + |
|
xiyuan
2012/12/20 01:44:28
nit: nuke this emptly line
achuithb
2012/12/20 01:53:31
Done.
|
| +} |
| + |
| void Preferences::SetLanguageConfigBoolean(const char* section, |
| const char* name, |
| bool value) { |