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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc

Issue 2028593004: Add new InputDeviceManager interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_keyboard
Patch Set: Fix windows compile error. Created 4 years, 6 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 (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/ui/webui/options/chromeos/keyboard_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/keyboard_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "ash/new_window_delegate.h" 9 #include "ash/new_window_delegate.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "chromeos/chromeos_switches.h" 17 #include "chromeos/chromeos_switches.h"
18 #include "content/public/browser/web_ui.h" 18 #include "content/public/browser/web_ui.h"
19 #include "ui/base/ime/chromeos/ime_keyboard.h" 19 #include "ui/base/ime/chromeos/ime_keyboard.h"
20 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/events/devices/device_data_manager.h" 21 #include "ui/events/devices/input_device_manager.h"
22 22
23 namespace { 23 namespace {
24 const struct ModifierKeysSelectItem { 24 const struct ModifierKeysSelectItem {
25 int message_id; 25 int message_id;
26 chromeos::input_method::ModifierKey value; 26 chromeos::input_method::ModifierKey value;
27 } kModifierKeysSelectItems[] = { 27 } kModifierKeysSelectItems[] = {
28 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_SEARCH, 28 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_SEARCH,
29 chromeos::input_method::kSearchKey }, 29 chromeos::input_method::kSearchKey },
30 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_CTRL, 30 { IDS_OPTIONS_SETTINGS_LANGUAGES_KEY_LEFT_CTRL,
31 chromeos::input_method::kControlKey }, 31 chromeos::input_method::kControlKey },
(...skipping 12 matching lines...) Expand all
44 const char* kDataValuesNames[] = { 44 const char* kDataValuesNames[] = {
45 "remapSearchKeyToValue", 45 "remapSearchKeyToValue",
46 "remapControlKeyToValue", 46 "remapControlKeyToValue",
47 "remapAltKeyToValue", 47 "remapAltKeyToValue",
48 "remapCapsLockKeyToValue", 48 "remapCapsLockKeyToValue",
49 "remapDiamondKeyToValue", 49 "remapDiamondKeyToValue",
50 }; 50 };
51 51
52 bool HasExternalKeyboard() { 52 bool HasExternalKeyboard() {
53 for (const ui::InputDevice& keyboard : 53 for (const ui::InputDevice& keyboard :
54 ui::DeviceDataManager::GetInstance()->keyboard_devices()) { 54 ui::InputDeviceManager::GetInstance()->GetKeyboardDevices()) {
55 if (keyboard.type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL) 55 if (keyboard.type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)
56 return true; 56 return true;
57 } 57 }
58 58
59 return false; 59 return false;
60 } 60 }
61 } // namespace 61 } // namespace
62 62
63 namespace chromeos { 63 namespace chromeos {
64 namespace options { 64 namespace options {
65 65
66 KeyboardHandler::KeyboardHandler() { 66 KeyboardHandler::KeyboardHandler() {
67 ui::DeviceDataManager::GetInstance()->AddObserver(this); 67 ui::InputDeviceManager::GetInstance()->AddObserver(this);
68 } 68 }
69 69
70 KeyboardHandler::~KeyboardHandler() { 70 KeyboardHandler::~KeyboardHandler() {
71 ui::DeviceDataManager::GetInstance()->RemoveObserver(this); 71 ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
72 } 72 }
73 73
74 void KeyboardHandler::GetLocalizedValues( 74 void KeyboardHandler::GetLocalizedValues(
75 base::DictionaryValue* localized_strings) { 75 base::DictionaryValue* localized_strings) {
76 DCHECK(localized_strings); 76 DCHECK(localized_strings);
77 RegisterTitle(localized_strings, "keyboardOverlay", 77 RegisterTitle(localized_strings, "keyboardOverlay",
78 IDS_OPTIONS_KEYBOARD_OVERLAY_TITLE); 78 IDS_OPTIONS_KEYBOARD_OVERLAY_TITLE);
79 79
80 localized_strings->SetString("remapSearchKeyToContent", 80 localized_strings->SetString("remapSearchKeyToContent",
81 l10n_util::GetStringUTF16( 81 l10n_util::GetStringUTF16(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 void KeyboardHandler::UpdateCapsLockOptions() const { 181 void KeyboardHandler::UpdateCapsLockOptions() const {
182 const base::FundamentalValue show_caps_lock_options(HasExternalKeyboard()); 182 const base::FundamentalValue show_caps_lock_options(HasExternalKeyboard());
183 web_ui()->CallJavascriptFunction( 183 web_ui()->CallJavascriptFunction(
184 "options.KeyboardOverlay.showCapsLockOptions", 184 "options.KeyboardOverlay.showCapsLockOptions",
185 show_caps_lock_options); 185 show_caps_lock_options);
186 } 186 }
187 187
188 } // namespace options 188 } // namespace options
189 } // namespace chromeos 189 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698