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

Side by Side Diff: ash/virtual_keyboard_controller.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 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 "ash/virtual_keyboard_controller.h" 5 #include "ash/virtual_keyboard_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 11 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "ui/events/devices/device_data_manager.h"
15 #include "ui/events/devices/input_device.h" 14 #include "ui/events/devices/input_device.h"
15 #include "ui/events/devices/input_device_manager.h"
16 #include "ui/events/devices/touchscreen_device.h" 16 #include "ui/events/devices/touchscreen_device.h"
17 #include "ui/keyboard/keyboard_switches.h" 17 #include "ui/keyboard/keyboard_switches.h"
18 #include "ui/keyboard/keyboard_util.h" 18 #include "ui/keyboard/keyboard_util.h"
19 19
20 namespace ash { 20 namespace ash {
21 namespace { 21 namespace {
22 22
23 // Checks whether smart deployment is enabled. 23 // Checks whether smart deployment is enabled.
24 bool IsSmartVirtualKeyboardEnabled() { 24 bool IsSmartVirtualKeyboardEnabled() {
25 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 25 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
26 keyboard::switches::kEnableVirtualKeyboard)) { 26 keyboard::switches::kEnableVirtualKeyboard)) {
27 return false; 27 return false;
28 } 28 }
29 return keyboard::IsSmartDeployEnabled(); 29 return keyboard::IsSmartDeployEnabled();
30 } 30 }
31 31
32 } // namespace 32 } // namespace
33 33
34 VirtualKeyboardController::VirtualKeyboardController() 34 VirtualKeyboardController::VirtualKeyboardController()
35 : has_external_keyboard_(false), 35 : has_external_keyboard_(false),
36 has_internal_keyboard_(false), 36 has_internal_keyboard_(false),
37 has_touchscreen_(false), 37 has_touchscreen_(false),
38 ignore_external_keyboard_(false) { 38 ignore_external_keyboard_(false) {
39 Shell::GetInstance()->AddShellObserver(this); 39 Shell::GetInstance()->AddShellObserver(this);
40 ui::DeviceDataManager::GetInstance()->AddObserver(this); 40 ui::InputDeviceManager::GetInstance()->AddObserver(this);
41 UpdateDevices(); 41 UpdateDevices();
42 } 42 }
43 43
44 VirtualKeyboardController::~VirtualKeyboardController() { 44 VirtualKeyboardController::~VirtualKeyboardController() {
45 Shell::GetInstance()->RemoveShellObserver(this); 45 Shell::GetInstance()->RemoveShellObserver(this);
46 ui::DeviceDataManager::GetInstance()->RemoveObserver(this); 46 ui::InputDeviceManager::GetInstance()->RemoveObserver(this);
47 } 47 }
48 48
49 void VirtualKeyboardController::OnMaximizeModeStarted() { 49 void VirtualKeyboardController::OnMaximizeModeStarted() {
50 if (!IsSmartVirtualKeyboardEnabled()) { 50 if (!IsSmartVirtualKeyboardEnabled()) {
51 SetKeyboardEnabled(true); 51 SetKeyboardEnabled(true);
52 } else { 52 } else {
53 UpdateKeyboardEnabled(); 53 UpdateKeyboardEnabled();
54 } 54 }
55 } 55 }
56 56
(...skipping 12 matching lines...) Expand all
69 void VirtualKeyboardController::OnKeyboardDeviceConfigurationChanged() { 69 void VirtualKeyboardController::OnKeyboardDeviceConfigurationChanged() {
70 UpdateDevices(); 70 UpdateDevices();
71 } 71 }
72 72
73 void VirtualKeyboardController::ToggleIgnoreExternalKeyboard() { 73 void VirtualKeyboardController::ToggleIgnoreExternalKeyboard() {
74 ignore_external_keyboard_ = !ignore_external_keyboard_; 74 ignore_external_keyboard_ = !ignore_external_keyboard_;
75 UpdateKeyboardEnabled(); 75 UpdateKeyboardEnabled();
76 } 76 }
77 77
78 void VirtualKeyboardController::UpdateDevices() { 78 void VirtualKeyboardController::UpdateDevices() {
79 ui::DeviceDataManager* device_data_manager = 79 ui::InputDeviceManager* device_data_manager =
80 ui::DeviceDataManager::GetInstance(); 80 ui::InputDeviceManager::GetInstance();
81 81
82 // Checks for touchscreens. 82 // Checks for touchscreens.
83 has_touchscreen_ = device_data_manager->touchscreen_devices().size() > 0; 83 has_touchscreen_ = device_data_manager->GetTouchscreenDevices().size() > 0;
84 84
85 // Checks for keyboards. 85 // Checks for keyboards.
86 has_external_keyboard_ = false; 86 has_external_keyboard_ = false;
87 has_internal_keyboard_ = false; 87 has_internal_keyboard_ = false;
88 for (const ui::InputDevice& device : 88 for (const ui::InputDevice& device :
89 device_data_manager->keyboard_devices()) { 89 device_data_manager->GetKeyboardDevices()) {
90 if (has_internal_keyboard_ && has_external_keyboard_) 90 if (has_internal_keyboard_ && has_external_keyboard_)
91 break; 91 break;
92 ui::InputDeviceType type = device.type; 92 ui::InputDeviceType type = device.type;
93 if (type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) 93 if (type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL)
94 has_internal_keyboard_ = true; 94 has_internal_keyboard_ = true;
95 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL) 95 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)
96 has_external_keyboard_ = true; 96 has_external_keyboard_ = true;
97 } 97 }
98 // Update keyboard state. 98 // Update keyboard state.
99 UpdateKeyboardEnabled(); 99 UpdateKeyboardEnabled();
(...skipping 27 matching lines...) Expand all
127 if (is_enabled == was_enabled) 127 if (is_enabled == was_enabled)
128 return; 128 return;
129 if (is_enabled) { 129 if (is_enabled) {
130 Shell::GetInstance()->CreateKeyboard(); 130 Shell::GetInstance()->CreateKeyboard();
131 } else { 131 } else {
132 Shell::GetInstance()->DeactivateKeyboard(); 132 Shell::GetInstance()->DeactivateKeyboard();
133 } 133 }
134 } 134 }
135 135
136 } // namespace ash 136 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touch_transformer_controller.cc ('k') | ash/wm/maximize_mode/scoped_disable_internal_mouse_and_keyboard_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698