OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/preferences.h" | 5 #include "chrome/browser/chromeos/preferences.h" |
6 | 6 |
7 #include "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 380 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
381 | 381 |
382 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, callback); | 382 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, callback); |
383 | 383 |
384 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, callback); | 384 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, callback); |
385 } | 385 } |
386 | 386 |
387 void Preferences::Init(PrefService* prefs) { | 387 void Preferences::Init(PrefService* prefs) { |
388 InitUserPrefs(prefs); | 388 InitUserPrefs(prefs); |
389 | 389 |
390 // This causes OnIsSyncingChanged to be called when the value of | |
391 // PrefService::IsSyncing() changes. | |
392 prefs->AddObserver(this); | |
xiyuan
2012/12/20 01:44:28
Where do we RemoveObserver?
achuithb
2012/12/20 01:53:31
Done.
| |
393 | |
390 // Initialize preferences to currently saved state. | 394 // Initialize preferences to currently saved state. |
391 NotifyPrefChanged(NULL); | 395 NotifyPrefChanged(NULL); |
392 | 396 |
393 // If a guest is logged in, initialize the prefs as if this is the first | 397 // If a guest is logged in, initialize the prefs as if this is the first |
394 // login. | 398 // login. |
395 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { | 399 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
396 LoginUtils::Get()->SetFirstLoginPrefs(prefs); | 400 LoginUtils::Get()->SetFirstLoginPrefs(prefs); |
397 } | 401 } |
398 } | 402 } |
399 | 403 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
443 } | 447 } |
444 if (!pref_name || *pref_name == prefs::kEnableTouchpadThreeFingerSwipe) { | 448 if (!pref_name || *pref_name == prefs::kEnableTouchpadThreeFingerSwipe) { |
445 const bool enabled = three_finger_swipe_enabled_.GetValue(); | 449 const bool enabled = three_finger_swipe_enabled_.GetValue(); |
446 system::touchpad_settings::SetThreeFingerSwipe(enabled); | 450 system::touchpad_settings::SetThreeFingerSwipe(enabled); |
447 if (pref_name) | 451 if (pref_name) |
448 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Changed", enabled); | 452 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Changed", enabled); |
449 else | 453 else |
450 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Started", enabled); | 454 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Started", enabled); |
451 } | 455 } |
452 if (!pref_name || *pref_name == prefs::kNaturalScroll) { | 456 if (!pref_name || *pref_name == prefs::kNaturalScroll) { |
453 // Force natural scroll to on if kNaturalScrollDefault is specified on the | 457 // Force natural scroll default if we've sync'd and if the cmd line arg is |
454 // cmd line. | 458 // set. |
455 if (CommandLine::ForCurrentProcess()->HasSwitch( | 459 ForceNaturalScrollDefault(); |
456 switches::kNaturalScrollDefault) && | |
457 !pref_name && | |
458 !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { | |
459 natural_scroll_.SetValue(true); | |
460 DVLOG(1) << "Natural scroll forced to true"; | |
461 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true); | |
462 } | |
463 | 460 |
464 const bool enabled = natural_scroll_.GetValue(); | 461 const bool enabled = natural_scroll_.GetValue(); |
465 DVLOG(1) << "Natural scroll set to " << enabled; | 462 DVLOG(1) << "Natural scroll set to " << enabled; |
466 ui::SetNaturalScroll(enabled); | 463 ui::SetNaturalScroll(enabled); |
467 if (pref_name) | 464 if (pref_name) |
468 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); | 465 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); |
469 else | 466 else |
470 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); | 467 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); |
471 } | 468 } |
472 if (!pref_name || *pref_name == prefs::kMouseSensitivity) { | 469 if (!pref_name || *pref_name == prefs::kMouseSensitivity) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
670 if (disable_drive_.GetValue()) { | 667 if (disable_drive_.GetValue()) { |
671 if (drive::util::IsUnderDriveMountPoint( | 668 if (drive::util::IsUnderDriveMountPoint( |
672 download_default_directory_.GetValue())) { | 669 download_default_directory_.GetValue())) { |
673 prefs_->SetFilePath(prefs::kDownloadDefaultDirectory, | 670 prefs_->SetFilePath(prefs::kDownloadDefaultDirectory, |
674 download_util::GetDefaultDownloadDirectory()); | 671 download_util::GetDefaultDownloadDirectory()); |
675 } | 672 } |
676 } | 673 } |
677 } | 674 } |
678 } | 675 } |
679 | 676 |
677 void Preferences::OnIsSyncingChanged() { | |
678 DVLOG(1) << "OnIsSyncingChanged"; | |
679 ForceNaturalScrollDefault(); | |
680 } | |
681 | |
682 void Preferences::ForceNaturalScrollDefault() { | |
683 DVLOG(1) << "ForceNaturalScrollDefault"; | |
684 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
685 switches::kNaturalScrollDefault) && | |
686 prefs_->IsSyncing() && | |
687 !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) { | |
688 DVLOG(1) << "Natural scroll forced to true"; | |
689 natural_scroll_.SetValue(true); | |
690 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true); | |
691 } | |
692 | |
xiyuan
2012/12/20 01:44:28
nit: nuke this emptly line
achuithb
2012/12/20 01:53:31
Done.
| |
693 } | |
694 | |
680 void Preferences::SetLanguageConfigBoolean(const char* section, | 695 void Preferences::SetLanguageConfigBoolean(const char* section, |
681 const char* name, | 696 const char* name, |
682 bool value) { | 697 bool value) { |
683 input_method::InputMethodConfigValue config; | 698 input_method::InputMethodConfigValue config; |
684 config.type = input_method::InputMethodConfigValue::kValueTypeBool; | 699 config.type = input_method::InputMethodConfigValue::kValueTypeBool; |
685 config.bool_value = value; | 700 config.bool_value = value; |
686 input_method_manager_->SetInputMethodConfig(section, name, config); | 701 input_method_manager_->SetInputMethodConfig(section, name, config); |
687 } | 702 } |
688 | 703 |
689 void Preferences::SetLanguageConfigInteger(const char* section, | 704 void Preferences::SetLanguageConfigInteger(const char* section, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 | 783 |
769 input_method::AutoRepeatRate rate; | 784 input_method::AutoRepeatRate rate; |
770 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); | 785 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); |
771 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); | 786 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); |
772 DCHECK(rate.initial_delay_in_ms > 0); | 787 DCHECK(rate.initial_delay_in_ms > 0); |
773 DCHECK(rate.repeat_interval_in_ms > 0); | 788 DCHECK(rate.repeat_interval_in_ms > 0); |
774 input_method::XKeyboard::SetAutoRepeatRate(rate); | 789 input_method::XKeyboard::SetAutoRepeatRate(rate); |
775 } | 790 } |
776 | 791 |
777 } // namespace chromeos | 792 } // namespace chromeos |
OLD | NEW |