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

Side by Side Diff: chrome/browser/chromeos/events/event_rewriter.cc

Issue 2702393003: [ChromeOS] Expose keyboard remapping to signin screen. (Closed)
Patch Set: Address alemate@'s comment. Created 3 years, 10 months 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
OLDNEW
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"
28 #include "components/user_manager/known_user.h"
26 #include "components/user_manager/user_manager.h" 29 #include "components/user_manager/user_manager.h"
27 #include "ui/base/ime/chromeos/ime_keyboard.h" 30 #include "ui/base/ime/chromeos/ime_keyboard.h"
28 #include "ui/base/ime/chromeos/input_method_manager.h" 31 #include "ui/base/ime/chromeos/input_method_manager.h"
29 #include "ui/events/devices/input_device_manager.h" 32 #include "ui/events/devices/input_device_manager.h"
30 #include "ui/events/event.h" 33 #include "ui/events/event.h"
31 #include "ui/events/event_utils.h" 34 #include "ui/events/event_utils.h"
32 #include "ui/events/keycodes/dom/dom_code.h" 35 #include "ui/events/keycodes/dom/dom_code.h"
33 #include "ui/events/keycodes/dom/dom_key.h" 36 #include "ui/events/keycodes/dom/dom_key.h"
34 #include "ui/events/keycodes/dom/keycode_converter.h" 37 #include "ui/events/keycodes/dom/keycode_converter.h"
35 #include "ui/events/keycodes/keyboard_code_conversion.h" 38 #include "ui/events/keycodes/keyboard_code_conversion.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, ui::VKEY_F15}}}; 128 {ui::EF_NONE, ui::DomCode::F15, ui::DomKey::F15, ui::VKEY_F15}}};
126 129
127 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0]; 130 const ModifierRemapping* kModifierRemappingCtrl = &kModifierRemappings[0];
128 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1]; 131 const ModifierRemapping* kModifierRemappingNeoMod3 = &kModifierRemappings[1];
129 132
130 // Gets a remapped key for |pref_name| key. For example, to find out which 133 // 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 134 // key Search is currently remapped to, call the function with
132 // prefs::kLanguageRemapSearchKeyTo. 135 // prefs::kLanguageRemapSearchKeyTo.
133 const ModifierRemapping* GetRemappedKey(const std::string& pref_name, 136 const ModifierRemapping* GetRemappedKey(const std::string& pref_name,
134 const PrefService& pref_service) { 137 const PrefService& pref_service) {
135 if (!pref_service.FindPreference(pref_name.c_str())) 138 int value = -1;
136 return NULL; // The |pref_name| hasn't been registered. On login screen? 139 // 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()); 140 // dictionary.
141 if (LoginDisplayHost::default_host()) {
142 const AccountId focused_account_id = LoginDisplayHost::default_host()
143 ->GetOobeUI()
144 ->signin_screen_handler()
145 ->focused_pod_account_id();
146 if (!focused_account_id.empty()) {
xiyuan 2017/02/22 17:40:18 nit: empty() -> is_valid()
147 user_manager::known_user::GetIntegerPref(focused_account_id, pref_name,
148 &value);
Alexander Alekseev 2017/02/22 10:51:50 I am not an owner of this file, but it seems to me
xdai1 2017/02/22 18:36:16 Done.
149 }
150 }
151
152 if (value == -1) {
153 if (pref_service.FindPreference(pref_name))
154 value = pref_service.GetInteger(pref_name);
155 else
156 return nullptr;
157 }
158
138 for (size_t i = 0; i < arraysize(kModifierRemappings); ++i) { 159 for (size_t i = 0; i < arraysize(kModifierRemappings); ++i) {
139 if (value == kModifierRemappings[i].remap_to) 160 if (value == kModifierRemappings[i].remap_to)
140 return &kModifierRemappings[i]; 161 return &kModifierRemappings[i];
141 } 162 }
142 return NULL; 163 return nullptr;
143 } 164 }
144 165
145 bool HasDiamondKey() { 166 bool HasDiamondKey() {
146 return base::CommandLine::ForCurrentProcess()->HasSwitch( 167 return base::CommandLine::ForCurrentProcess()->HasSwitch(
147 chromeos::switches::kHasChromeOSDiamondKey); 168 chromeos::switches::kHasChromeOSDiamondKey);
148 } 169 }
149 170
150 bool IsISOLevel5ShiftUsedByCurrentInputMethod() { 171 bool IsISOLevel5ShiftUsedByCurrentInputMethod() {
151 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask, 172 // 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 173 // 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
1155 for (const auto& keyboard : keyboard_devices) { 1176 for (const auto& keyboard : keyboard_devices) {
1156 if (keyboard.id == device_id) { 1177 if (keyboard.id == device_id) {
1157 return KeyboardDeviceAddedInternal( 1178 return KeyboardDeviceAddedInternal(
1158 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id); 1179 keyboard.id, keyboard.name, keyboard.vendor_id, keyboard.product_id);
1159 } 1180 }
1160 } 1181 }
1161 return kDeviceUnknown; 1182 return kDeviceUnknown;
1162 } 1183 }
1163 1184
1164 } // namespace chromeos 1185 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698