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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/autoclick/autoclick_controller.h" | 9 #include "ash/autoclick/autoclick_controller.h" |
10 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "ui/base/ime/chromeos/extension_ime_util.h" | 50 #include "ui/base/ime/chromeos/extension_ime_util.h" |
51 #include "ui/base/ime/chromeos/ime_keyboard.h" | 51 #include "ui/base/ime/chromeos/ime_keyboard.h" |
52 #include "ui/base/ime/chromeos/input_method_manager.h" | 52 #include "ui/base/ime/chromeos/input_method_manager.h" |
53 #include "ui/display/manager/display_manager.h" | 53 #include "ui/display/manager/display_manager.h" |
54 #include "ui/events/event_constants.h" | 54 #include "ui/events/event_constants.h" |
55 #include "ui/events/event_utils.h" | 55 #include "ui/events/event_utils.h" |
56 #include "url/gurl.h" | 56 #include "url/gurl.h" |
57 | 57 |
58 namespace chromeos { | 58 namespace chromeos { |
59 | 59 |
| 60 namespace { |
| 61 |
60 static const char kFallbackInputMethodLocale[] = "en-US"; | 62 static const char kFallbackInputMethodLocale[] = "en-US"; |
61 | 63 |
| 64 // The keyboard preferences that determine how we remap modifier keys. These |
| 65 // preferences will be saved in global user preferences dictionary so that they |
| 66 // can be used on signin screen. |
| 67 const char* const kLanguageRemapPrefs[] = { |
| 68 prefs::kLanguageRemapSearchKeyTo, prefs::kLanguageRemapControlKeyTo, |
| 69 prefs::kLanguageRemapAltKeyTo, prefs::kLanguageRemapCapsLockKeyTo, |
| 70 prefs::kLanguageRemapEscapeKeyTo, prefs::kLanguageRemapBackspaceKeyTo, |
| 71 prefs::kLanguageRemapDiamondKeyTo}; |
| 72 |
| 73 } // namespace |
| 74 |
62 Preferences::Preferences() | 75 Preferences::Preferences() |
63 : prefs_(NULL), | 76 : prefs_(NULL), |
64 input_method_manager_(input_method::InputMethodManager::Get()), | 77 input_method_manager_(input_method::InputMethodManager::Get()), |
65 user_(NULL), | 78 user_(NULL), |
66 user_is_primary_(false) { | 79 user_is_primary_(false) { |
67 // Do not observe shell, if there is no shell instance; e.g., in some unit | 80 // Do not observe shell, if there is no shell instance; e.g., in some unit |
68 // tests. | 81 // tests. |
69 if (ash::WmShell::HasInstance()) | 82 if (ash::WmShell::HasInstance()) |
70 ash::WmShell::Get()->AddShellObserver(this); | 83 ash::WmShell::Get()->AddShellObserver(this); |
71 } | 84 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); | 403 prefs::kLanguageXkbAutoRepeatDelay, prefs, callback); |
391 xkb_auto_repeat_interval_pref_.Init( | 404 xkb_auto_repeat_interval_pref_.Init( |
392 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); | 405 prefs::kLanguageXkbAutoRepeatInterval, prefs, callback); |
393 | 406 |
394 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, | 407 wake_on_wifi_darkconnect_.Init(prefs::kWakeOnWifiDarkConnect, prefs, |
395 callback); | 408 callback); |
396 | 409 |
397 pref_change_registrar_.Init(prefs); | 410 pref_change_registrar_.Init(prefs); |
398 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); | 411 pref_change_registrar_.Add(prefs::kResolveTimezoneByGeolocation, callback); |
399 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); | 412 pref_change_registrar_.Add(prefs::kUse24HourClock, callback); |
| 413 for (auto remap_pref : kLanguageRemapPrefs) |
| 414 pref_change_registrar_.Add(remap_pref, callback); |
400 } | 415 } |
401 | 416 |
402 void Preferences::Init(Profile* profile, const user_manager::User* user) { | 417 void Preferences::Init(Profile* profile, const user_manager::User* user) { |
403 DCHECK(profile); | 418 DCHECK(profile); |
404 DCHECK(user); | 419 DCHECK(user); |
405 sync_preferences::PrefServiceSyncable* prefs = | 420 sync_preferences::PrefServiceSyncable* prefs = |
406 PrefServiceSyncableFromProfile(profile); | 421 PrefServiceSyncableFromProfile(profile); |
407 // This causes OnIsSyncingChanged to be called when the value of | 422 // This causes OnIsSyncingChanged to be called when the value of |
408 // PrefService::IsSyncing() changes. | 423 // PrefService::IsSyncing() changes. |
409 prefs->AddObserver(this); | 424 prefs->AddObserver(this); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 720 } |
706 } | 721 } |
707 | 722 |
708 if (pref_name == prefs::kUse24HourClock || | 723 if (pref_name == prefs::kUse24HourClock || |
709 reason != REASON_ACTIVE_USER_CHANGED) { | 724 reason != REASON_ACTIVE_USER_CHANGED) { |
710 const bool value = prefs_->GetBoolean(prefs::kUse24HourClock); | 725 const bool value = prefs_->GetBoolean(prefs::kUse24HourClock); |
711 user_manager::known_user::SetBooleanPref(user_->GetAccountId(), | 726 user_manager::known_user::SetBooleanPref(user_->GetAccountId(), |
712 prefs::kUse24HourClock, value); | 727 prefs::kUse24HourClock, value); |
713 } | 728 } |
714 | 729 |
| 730 for (auto remap_pref : kLanguageRemapPrefs) { |
| 731 if (pref_name == remap_pref || reason != REASON_ACTIVE_USER_CHANGED) { |
| 732 const int value = prefs_->GetInteger(remap_pref); |
| 733 user_manager::known_user::SetIntegerPref(user_->GetAccountId(), |
| 734 remap_pref, value); |
| 735 } |
| 736 } |
| 737 |
715 system::InputDeviceSettings::Get()->UpdateTouchDevicesStatusFromPrefs(); | 738 system::InputDeviceSettings::Get()->UpdateTouchDevicesStatusFromPrefs(); |
716 } | 739 } |
717 | 740 |
718 void Preferences::OnIsSyncingChanged() { | 741 void Preferences::OnIsSyncingChanged() { |
719 DVLOG(1) << "OnIsSyncingChanged"; | 742 DVLOG(1) << "OnIsSyncingChanged"; |
720 ForceNaturalScrollDefault(); | 743 ForceNaturalScrollDefault(); |
721 } | 744 } |
722 | 745 |
723 void Preferences::ForceNaturalScrollDefault() { | 746 void Preferences::ForceNaturalScrollDefault() { |
724 DVLOG(1) << "ForceNaturalScrollDefault"; | 747 DVLOG(1) << "ForceNaturalScrollDefault"; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 touch_hud_projection_enabled_.SetValue(enabled); | 829 touch_hud_projection_enabled_.SetValue(enabled); |
807 } | 830 } |
808 | 831 |
809 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { | 832 void Preferences::ActiveUserChanged(const user_manager::User* active_user) { |
810 if (active_user != user_) | 833 if (active_user != user_) |
811 return; | 834 return; |
812 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); | 835 ApplyPreferences(REASON_ACTIVE_USER_CHANGED, ""); |
813 } | 836 } |
814 | 837 |
815 } // namespace chromeos | 838 } // namespace chromeos |
OLD | NEW |