Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: chrome/browser/chromeos/preferences.cc

Issue 11640032: Delay forcing natural scroll setting until after initial sync. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 30 matching lines...) Expand all
41 41
42 Preferences::Preferences() 42 Preferences::Preferences()
43 : prefs_(NULL), 43 : prefs_(NULL),
44 input_method_manager_(input_method::GetInputMethodManager()) { 44 input_method_manager_(input_method::GetInputMethodManager()) {
45 } 45 }
46 46
47 Preferences::Preferences(input_method::InputMethodManager* input_method_manager) 47 Preferences::Preferences(input_method::InputMethodManager* input_method_manager)
48 : input_method_manager_(input_method_manager) { 48 : input_method_manager_(input_method_manager) {
49 } 49 }
50 50
51 Preferences::~Preferences() {} 51 Preferences::~Preferences() {
52 prefs_->RemoveObserver(this);
53 }
52 54
53 // static 55 // static
54 void Preferences::RegisterUserPrefs(PrefService* prefs) { 56 void Preferences::RegisterUserPrefs(PrefService* prefs) {
55 std::string hardware_keyboard_id; 57 std::string hardware_keyboard_id;
56 // TODO(yusukes): Remove the runtime hack. 58 // TODO(yusukes): Remove the runtime hack.
57 if (base::chromeos::IsRunningOnChromeOS()) { 59 if (base::chromeos::IsRunningOnChromeOS()) {
58 input_method::InputMethodManager* manager = 60 input_method::InputMethodManager* manager =
59 input_method::GetInputMethodManager(); 61 input_method::GetInputMethodManager();
60 if (manager) { 62 if (manager) {
61 hardware_keyboard_id = 63 hardware_keyboard_id =
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); 382 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback);
381 383
382 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, callback); 384 enable_screen_lock_.Init(prefs::kEnableScreenLock, prefs, callback);
383 385
384 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, callback); 386 enable_drm_.Init(prefs::kEnableCrosDRM, prefs, callback);
385 } 387 }
386 388
387 void Preferences::Init(PrefService* prefs) { 389 void Preferences::Init(PrefService* prefs) {
388 InitUserPrefs(prefs); 390 InitUserPrefs(prefs);
389 391
392 // This causes OnIsSyncingChanged to be called when the value of
sky 2012/12/20 16:29:17 OnIsSyncingChanged()
393 // PrefService::IsSyncing() changes.
394 prefs->AddObserver(this);
395
390 // Initialize preferences to currently saved state. 396 // Initialize preferences to currently saved state.
391 NotifyPrefChanged(NULL); 397 NotifyPrefChanged(NULL);
392 398
393 // If a guest is logged in, initialize the prefs as if this is the first 399 // If a guest is logged in, initialize the prefs as if this is the first
394 // login. 400 // login.
395 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { 401 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) {
396 LoginUtils::Get()->SetFirstLoginPrefs(prefs); 402 LoginUtils::Get()->SetFirstLoginPrefs(prefs);
397 } 403 }
398 } 404 }
399 405
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 } 449 }
444 if (!pref_name || *pref_name == prefs::kEnableTouchpadThreeFingerSwipe) { 450 if (!pref_name || *pref_name == prefs::kEnableTouchpadThreeFingerSwipe) {
445 const bool enabled = three_finger_swipe_enabled_.GetValue(); 451 const bool enabled = three_finger_swipe_enabled_.GetValue();
446 system::touchpad_settings::SetThreeFingerSwipe(enabled); 452 system::touchpad_settings::SetThreeFingerSwipe(enabled);
447 if (pref_name) 453 if (pref_name)
448 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Changed", enabled); 454 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Changed", enabled);
449 else 455 else
450 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Started", enabled); 456 UMA_HISTOGRAM_BOOLEAN("Touchpad.ThreeFingerSwipe.Started", enabled);
451 } 457 }
452 if (!pref_name || *pref_name == prefs::kNaturalScroll) { 458 if (!pref_name || *pref_name == prefs::kNaturalScroll) {
453 // Force natural scroll to on if kNaturalScrollDefault is specified on the 459 // Force natural scroll default if we've sync'd and if the cmd line arg is
454 // cmd line. 460 // set.
455 if (CommandLine::ForCurrentProcess()->HasSwitch( 461 ForceNaturalScrollDefault();
sky 2012/12/20 16:29:17 If you invoke ForceNaturalScrollDefault() here and
xiyuan 2012/12/20 17:07:49 ForceNaturalScrollDefault just attempts to provide
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 462
464 const bool enabled = natural_scroll_.GetValue(); 463 const bool enabled = natural_scroll_.GetValue();
465 DVLOG(1) << "Natural scroll set to " << enabled; 464 DVLOG(1) << "Natural scroll set to " << enabled;
466 ui::SetNaturalScroll(enabled); 465 ui::SetNaturalScroll(enabled);
467 if (pref_name) 466 if (pref_name)
468 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled); 467 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Changed", enabled);
469 else 468 else
470 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled); 469 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Started", enabled);
471 } 470 }
472 if (!pref_name || *pref_name == prefs::kMouseSensitivity) { 471 if (!pref_name || *pref_name == prefs::kMouseSensitivity) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 if (disable_drive_.GetValue()) { 669 if (disable_drive_.GetValue()) {
671 if (drive::util::IsUnderDriveMountPoint( 670 if (drive::util::IsUnderDriveMountPoint(
672 download_default_directory_.GetValue())) { 671 download_default_directory_.GetValue())) {
673 prefs_->SetFilePath(prefs::kDownloadDefaultDirectory, 672 prefs_->SetFilePath(prefs::kDownloadDefaultDirectory,
674 download_util::GetDefaultDownloadDirectory()); 673 download_util::GetDefaultDownloadDirectory());
675 } 674 }
676 } 675 }
677 } 676 }
678 } 677 }
679 678
679 void Preferences::OnIsSyncingChanged() {
680 DVLOG(1) << "OnIsSyncingChanged";
681 ForceNaturalScrollDefault();
682 }
683
684 void Preferences::ForceNaturalScrollDefault() {
685 DVLOG(1) << "ForceNaturalScrollDefault";
686 if (CommandLine::ForCurrentProcess()->HasSwitch(
687 switches::kNaturalScrollDefault) &&
688 prefs_->IsSyncing() &&
689 !prefs_->GetUserPrefValue(prefs::kNaturalScroll)) {
690 DVLOG(1) << "Natural scroll forced to true";
691 natural_scroll_.SetValue(true);
692 UMA_HISTOGRAM_BOOLEAN("Touchpad.NaturalScroll.Forced", true);
693 }
694 }
695
680 void Preferences::SetLanguageConfigBoolean(const char* section, 696 void Preferences::SetLanguageConfigBoolean(const char* section,
681 const char* name, 697 const char* name,
682 bool value) { 698 bool value) {
683 input_method::InputMethodConfigValue config; 699 input_method::InputMethodConfigValue config;
684 config.type = input_method::InputMethodConfigValue::kValueTypeBool; 700 config.type = input_method::InputMethodConfigValue::kValueTypeBool;
685 config.bool_value = value; 701 config.bool_value = value;
686 input_method_manager_->SetInputMethodConfig(section, name, config); 702 input_method_manager_->SetInputMethodConfig(section, name, config);
687 } 703 }
688 704
689 void Preferences::SetLanguageConfigInteger(const char* section, 705 void Preferences::SetLanguageConfigInteger(const char* section,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 784
769 input_method::AutoRepeatRate rate; 785 input_method::AutoRepeatRate rate;
770 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue(); 786 rate.initial_delay_in_ms = xkb_auto_repeat_delay_pref_.GetValue();
771 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue(); 787 rate.repeat_interval_in_ms = xkb_auto_repeat_interval_pref_.GetValue();
772 DCHECK(rate.initial_delay_in_ms > 0); 788 DCHECK(rate.initial_delay_in_ms > 0);
773 DCHECK(rate.repeat_interval_in_ms > 0); 789 DCHECK(rate.repeat_interval_in_ms > 0);
774 input_method::XKeyboard::SetAutoRepeatRate(rate); 790 input_method::XKeyboard::SetAutoRepeatRate(rate);
775 } 791 }
776 792
777 } // namespace chromeos 793 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698