Chromium Code Reviews| Index: chrome/browser/chromeos/preferences.cc |
| =================================================================== |
| --- chrome/browser/chromeos/preferences.cc (revision 200880) |
| +++ chrome/browser/chromeos/preferences.cc (working copy) |
| @@ -49,7 +49,8 @@ |
| } |
| Preferences::Preferences(input_method::InputMethodManager* input_method_manager) |
| - : input_method_manager_(input_method_manager) { |
| + : prefs_(NULL), |
|
xiyuan
2013/05/21 02:01:44
Good catch.
|
| + input_method_manager_(input_method_manager) { |
| } |
| Preferences::~Preferences() { |
| @@ -525,6 +526,11 @@ |
| // Initialize preferences to currently saved state. |
| NotifyPrefChanged(NULL); |
| + // Listen to changes in device hierarchy. |
| + pointer_device_observer_.reset(new system::PointerDeviceObserver()); |
| + pointer_device_observer_->AddObserver(this); |
| + pointer_device_observer_->Init(); |
| + |
| // If a guest is logged in, initialize the prefs as if this is the first |
| // login. |
| if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| @@ -544,7 +550,7 @@ |
| NotifyPrefChanged(&pref_name); |
| } |
| -void Preferences::NotifyPrefChanged(const std::string* pref_name) { |
| +void Preferences::SetTouchpadPrefs(const std::string* pref_name) { |
| if (!pref_name || *pref_name == prefs::kTapToClickEnabled) { |
| const bool enabled = tap_to_click_enabled_.GetValue(); |
| system::touchpad_settings::SetTapToClick(enabled); |
| @@ -584,19 +590,20 @@ |
| else |
| UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Started", enabled); |
| } |
| - if (!pref_name || *pref_name == prefs::kNaturalScroll) { |
| - // Force natural scroll default if we've sync'd and if the cmd line arg is |
| - // set. |
| - ForceNaturalScrollDefault(); |
| + if (!pref_name || *pref_name == prefs::kTouchpadSensitivity) { |
| + const int sensitivity = touchpad_sensitivity_.GetValue(); |
| + system::touchpad_settings::SetSensitivity(sensitivity); |
| + if (pref_name) { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Touchpad.Sensitivity.Changed", sensitivity, 1, 5, 5); |
| + } else { |
| + UMA_HISTOGRAM_CUSTOM_COUNTS( |
| + "Touchpad.Sensitivity.Started", sensitivity, 1, 5, 5); |
| + } |
| + } |
| +} |
| - const bool enabled = natural_scroll_.GetValue(); |
| - DVLOG(1) << "Natural scroll set to " << enabled; |
| - ui::SetNaturalScroll(enabled); |
| - if (pref_name) |
| - UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); |
| - else |
| - UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); |
| - } |
| +void Preferences::SetMousePrefs(const std::string* pref_name) { |
| if (!pref_name || *pref_name == prefs::kMouseSensitivity) { |
| const int sensitivity = mouse_sensitivity_.GetValue(); |
| system::mouse_settings::SetSensitivity(sensitivity); |
| @@ -608,17 +615,6 @@ |
| "Mouse.Sensitivity.Started", sensitivity, 1, 5, 5); |
| } |
| } |
| - if (!pref_name || *pref_name == prefs::kTouchpadSensitivity) { |
| - const int sensitivity = touchpad_sensitivity_.GetValue(); |
| - system::touchpad_settings::SetSensitivity(sensitivity); |
| - if (pref_name) { |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Touchpad.Sensitivity.Changed", sensitivity, 1, 5, 5); |
| - } else { |
| - UMA_HISTOGRAM_CUSTOM_COUNTS( |
| - "Touchpad.Sensitivity.Started", sensitivity, 1, 5, 5); |
| - } |
| - } |
| if (!pref_name || *pref_name == prefs::kPrimaryMouseButtonRight) { |
| const bool right = primary_mouse_button_right_.GetValue(); |
| system::mouse_settings::SetPrimaryButtonRight(right); |
| @@ -634,6 +630,25 @@ |
| prefs->SetBoolean(prefs::kOwnerPrimaryMouseButtonRight, right); |
| } |
| } |
| +} |
| + |
| +void Preferences::NotifyPrefChanged(const std::string* pref_name) { |
| + SetTouchpadPrefs(pref_name); |
| + SetMousePrefs(pref_name); |
| + |
| + if (!pref_name || *pref_name == prefs::kNaturalScroll) { |
| + // 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; |
| + ui::SetNaturalScroll(enabled); |
| + if (pref_name) |
| + UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); |
| + else |
| + UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); |
| + } |
| if (!pref_name || *pref_name == prefs::kDownloadDefaultDirectory) { |
| const base::FilePath pref_path = download_default_directory_.GetValue(); |
| // TODO(haruki): Remove this when migration completes. crbug.com/229304. |
| @@ -889,6 +904,14 @@ |
| } |
| } |
| +void Preferences::TouchpadExists(bool exists) { |
| + SetTouchpadPrefs(NULL); |
| +} |
| + |
| +void Preferences::MouseExists(bool exists) { |
| + SetMousePrefs(NULL); |
| +} |
| + |
| void Preferences::SetLanguageConfigBoolean(const char* section, |
| const char* name, |
| bool value) { |