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 "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/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 ui::DeviceDataManager::GetInstance()->AddObserver(this); | 29 ui::DeviceDataManager::GetInstance()->AddObserver(this); |
30 UpdateDevices(); | 30 UpdateDevices(); |
31 } | 31 } |
32 | 32 |
33 VirtualKeyboardController::~VirtualKeyboardController() { | 33 VirtualKeyboardController::~VirtualKeyboardController() { |
34 Shell::GetInstance()->RemoveShellObserver(this); | 34 Shell::GetInstance()->RemoveShellObserver(this); |
35 ui::DeviceDataManager::GetInstance()->RemoveObserver(this); | 35 ui::DeviceDataManager::GetInstance()->RemoveObserver(this); |
36 } | 36 } |
37 | 37 |
38 void VirtualKeyboardController::OnMaximizeModeStarted() { | 38 void VirtualKeyboardController::OnMaximizeModeStarted() { |
39 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 39 if (!IsSmartVirtualKeyboardEnabled()) |
40 keyboard::switches::kAutoVirtualKeyboard)) { | |
41 SetKeyboardEnabled(true); | 40 SetKeyboardEnabled(true); |
42 } | |
43 } | 41 } |
44 | 42 |
45 void VirtualKeyboardController::OnMaximizeModeEnded() { | 43 void VirtualKeyboardController::OnMaximizeModeEnded() { |
46 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 44 if (!IsSmartVirtualKeyboardEnabled()) |
47 keyboard::switches::kAutoVirtualKeyboard)) { | |
48 SetKeyboardEnabled(false); | 45 SetKeyboardEnabled(false); |
49 } | |
50 } | 46 } |
51 | 47 |
52 void VirtualKeyboardController::OnTouchscreenDeviceConfigurationChanged() { | 48 void VirtualKeyboardController::OnTouchscreenDeviceConfigurationChanged() { |
53 UpdateDevices(); | 49 UpdateDevices(); |
54 } | 50 } |
55 | 51 |
56 void VirtualKeyboardController::OnKeyboardDeviceConfigurationChanged() { | 52 void VirtualKeyboardController::OnKeyboardDeviceConfigurationChanged() { |
57 UpdateDevices(); | 53 UpdateDevices(); |
58 } | 54 } |
59 | 55 |
(...skipping 19 matching lines...) Expand all Loading... |
79 ui::InputDeviceType type = device.type; | 75 ui::InputDeviceType type = device.type; |
80 if (type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) | 76 if (type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL) |
81 has_internal_keyboard_ = true; | 77 has_internal_keyboard_ = true; |
82 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL) | 78 if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL) |
83 has_external_keyboard_ = true; | 79 has_external_keyboard_ = true; |
84 } | 80 } |
85 // Update keyboard state. | 81 // Update keyboard state. |
86 UpdateKeyboardEnabled(); | 82 UpdateKeyboardEnabled(); |
87 } | 83 } |
88 | 84 |
| 85 bool VirtualKeyboardController::IsSmartVirtualKeyboardEnabled() { |
| 86 return !CommandLine::ForCurrentProcess()->HasSwitch( |
| 87 keyboard::switches::kDisableSmartVirtualKeyboard); |
| 88 } |
| 89 |
89 void VirtualKeyboardController::UpdateKeyboardEnabled() { | 90 void VirtualKeyboardController::UpdateKeyboardEnabled() { |
90 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 91 if (!IsSmartVirtualKeyboardEnabled()) { |
91 keyboard::switches::kAutoVirtualKeyboard)) { | |
92 SetKeyboardEnabled(Shell::GetInstance() | 92 SetKeyboardEnabled(Shell::GetInstance() |
93 ->maximize_mode_controller() | 93 ->maximize_mode_controller() |
94 ->IsMaximizeModeWindowManagerEnabled()); | 94 ->IsMaximizeModeWindowManagerEnabled()); |
95 return; | 95 return; |
96 } | 96 } |
97 SetKeyboardEnabled(!has_internal_keyboard_ && has_touchscreen_ && | 97 SetKeyboardEnabled(!has_internal_keyboard_ && has_touchscreen_ && |
98 (!has_external_keyboard_ || ignore_external_keyboard_)); | 98 (!has_external_keyboard_ || ignore_external_keyboard_)); |
99 ash::Shell::GetInstance() | 99 ash::Shell::GetInstance() |
100 ->system_tray_notifier() | 100 ->system_tray_notifier() |
101 ->NotifyVirtualKeyboardSuppressionChanged(!has_internal_keyboard_ && | 101 ->NotifyVirtualKeyboardSuppressionChanged(!has_internal_keyboard_ && |
102 has_touchscreen_ && | 102 has_touchscreen_ && |
103 has_external_keyboard_); | 103 has_external_keyboard_); |
104 } | 104 } |
105 | 105 |
106 void VirtualKeyboardController::SetKeyboardEnabled(bool enabled) { | 106 void VirtualKeyboardController::SetKeyboardEnabled(bool enabled) { |
107 keyboard::SetTouchKeyboardEnabled(enabled); | 107 keyboard::SetTouchKeyboardEnabled(enabled); |
108 if (enabled) { | 108 if (enabled) { |
109 Shell::GetInstance()->CreateKeyboard(); | 109 Shell::GetInstance()->CreateKeyboard(); |
110 } else { | 110 } else { |
111 if (!keyboard::IsKeyboardEnabled()) | 111 if (!keyboard::IsKeyboardEnabled()) |
112 Shell::GetInstance()->DeactivateKeyboard(); | 112 Shell::GetInstance()->DeactivateKeyboard(); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 } // namespace ash | 116 } // namespace ash |
OLD | NEW |