OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/events/event_rewriter.h" | 5 #include "chrome/browser/chromeos/events/event_rewriter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/common/wm/window_state.h" | 11 #include "ash/common/wm/window_state.h" |
12 #include "ash/sticky_keys/sticky_keys_controller.h" | 12 #include "ash/sticky_keys/sticky_keys_controller.h" |
13 #include "ash/wm/window_util.h" | 13 #include "ash/wm/window_util.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
21 #include "chrome/browser/extensions/extension_commands_global_registry.h" | 21 #include "chrome/browser/extensions/extension_commands_global_registry.h" |
22 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
23 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | |
24 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | |
23 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
24 #include "chromeos/chromeos_switches.h" | 26 #include "chromeos/chromeos_switches.h" |
25 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
26 #include "components/user_manager/user_manager.h" | 28 #include "components/user_manager/user_manager.h" |
27 #include "ui/base/ime/chromeos/ime_keyboard.h" | 29 #include "ui/base/ime/chromeos/ime_keyboard.h" |
28 #include "ui/base/ime/chromeos/input_method_manager.h" | 30 #include "ui/base/ime/chromeos/input_method_manager.h" |
29 #include "ui/events/devices/input_device_manager.h" | 31 #include "ui/events/devices/input_device_manager.h" |
30 #include "ui/events/event.h" | 32 #include "ui/events/event.h" |
31 #include "ui/events/event_utils.h" | 33 #include "ui/events/event_utils.h" |
32 #include "ui/events/keycodes/dom/dom_code.h" | 34 #include "ui/events/keycodes/dom/dom_code.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, ui::VKEY_F15}}}; | 127 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, ui::VKEY_F15}}}; |
126 | 128 |
127 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0]; | 129 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0]; |
128 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1]; | 130 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1]; |
129 | 131 |
130 // Gets a remapped key for |pref_name| key. For example, to find out which | 132 // Gets a remapped key for |pref_name| key. For example, to find out which |
131 // key Search is currently remapped to, call the function with | 133 // key Search is currently remapped to, call the function with |
132 // prefs::kLanguageRemapSearchKeyTo. | 134 // prefs::kLanguageRemapSearchKeyTo. |
133 const ModifierRemapping* GetRemappedKey(const std::string& pref_name, | 135 const ModifierRemapping* GetRemappedKey(const std::string& pref_name, |
134 const PrefService& pref_service) { | 136 const PrefService& pref_service) { |
135 if (!pref_service.FindPreference(pref_name.c_str())) | 137 int value = -1; |
136 return NULL; // The |pref_name| hasn't been registered. On login screen? | 138 // If we're at the login screen, try to get the pref from the global prefs |
137 const int value = pref_service.GetInteger(pref_name.c_str()); | 139 // dictionary. |
140 if (!LoginDisplayHost::default_host() || | |
141 !LoginDisplayHost::default_host() | |
142 ->GetOobeUI() | |
143 ->signin_screen_handler() | |
144 ->GetKeyboardRemappedPrefValue(pref_name, &value)) { | |
145 if (!pref_service.FindPreference(pref_name)) | |
146 return nullptr; | |
147 else | |
xiyuan
2017/02/22 18:50:58
nit: this "else" can be removed.
xdai1
2017/02/22 19:26:30
Done.
| |
148 value = pref_service.GetInteger(pref_name); | |
149 } | |
150 | |
138 for (size_t i = 0; i < arraysize(kModifierRemappings); ++i) { | 151 for (size_t i = 0; i < arraysize(kModifierRemappings); ++i) { |
139 if (value == kModifierRemappings[i].remap_to) | 152 if (value == kModifierRemappings[i].remap_to) |
140 return &kModifierRemappings[i]; | 153 return &kModifierRemappings[i]; |
141 } | 154 } |
142 return NULL; | 155 return nullptr; |
143 } | 156 } |
144 | 157 |
145 bool HasDiamondKey() { | 158 bool HasDiamondKey() { |
146 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 159 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
147 chromeos::switches::kHasChromeOSDiamondKey); | 160 chromeos::switches::kHasChromeOSDiamondKey); |
148 } | 161 } |
149 | 162 |
150 bool IsISOLevel5ShiftUsedByCurrentInputMethod() { | 163 bool IsISOLevel5ShiftUsedByCurrentInputMethod() { |
151 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask, | 164 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask, |
152 // it's not possible to make both features work. For now, we don't remap | 165 // it's not possible to make both features work. For now, we don't remap |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1155 for (const auto& keyboard : keyboard_devices) { | 1168 for (const auto& keyboard : keyboard_devices) { |
1156 if (keyboard.id == device_id) { | 1169 if (keyboard.id == device_id) { |
1157 return KeyboardDeviceAddedInternal( | 1170 return KeyboardDeviceAddedInternal( |
1158 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); | 1171 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); |
1159 } | 1172 } |
1160 } | 1173 } |
1161 return kDeviceUnknown; | 1174 return kDeviceUnknown; |
1162 } | 1175 } |
1163 | 1176 |
1164 } // namespace chromeos | 1177 } // namespace chromeos |
OLD | NEW |