OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/keyboard/keyboard_util.h" | 5 #include "ui/keyboard/keyboard_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 bool IsKeyboardEnabled() { | 100 bool IsKeyboardEnabled() { |
101 // Accessibility setting prioritized over policy setting. | 101 // Accessibility setting prioritized over policy setting. |
102 if (g_accessibility_keyboard_enabled) | 102 if (g_accessibility_keyboard_enabled) |
103 return true; | 103 return true; |
104 // Policy strictly disables showing a virtual keyboard. | 104 // Policy strictly disables showing a virtual keyboard. |
105 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED) | 105 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED) |
106 return false; | 106 return false; |
107 // Check if any of the flags are enabled. | 107 // Check if any of the flags are enabled. |
108 return CommandLine::ForCurrentProcess()->HasSwitch( | 108 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
109 switches::kEnableVirtualKeyboard) || | 109 switches::kEnableVirtualKeyboard) || |
110 g_touch_keyboard_enabled || | 110 g_touch_keyboard_enabled || |
111 (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED); | 111 (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED); |
112 } | 112 } |
113 | 113 |
114 bool IsKeyboardOverscrollEnabled() { | 114 bool IsKeyboardOverscrollEnabled() { |
115 if (!IsKeyboardEnabled()) | 115 if (!IsKeyboardEnabled()) |
116 return false; | 116 return false; |
117 | 117 |
118 // Users of the accessibility on-screen keyboard are likely to be using mouse | 118 // Users of the accessibility on-screen keyboard are likely to be using mouse |
119 // input, which may interfere with overscrolling. | 119 // input, which may interfere with overscrolling. |
120 if (g_accessibility_keyboard_enabled) | 120 if (g_accessibility_keyboard_enabled) |
121 return false; | 121 return false; |
122 | 122 |
123 // If overscroll enabled override is set, use it instead. Currently | 123 // If overscroll enabled override is set, use it instead. Currently |
124 // login / out-of-box disable keyboard overscroll. http://crbug.com/363635 | 124 // login / out-of-box disable keyboard overscroll. http://crbug.com/363635 |
125 if (g_keyboard_overscroll_override != KEYBOARD_OVERSCROLL_OVERRIDE_NONE) { | 125 if (g_keyboard_overscroll_override != KEYBOARD_OVERSCROLL_OVERRIDE_NONE) { |
126 return g_keyboard_overscroll_override == | 126 return g_keyboard_overscroll_override == |
127 KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED; | 127 KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED; |
128 } | 128 } |
129 | 129 |
130 if (CommandLine::ForCurrentProcess()->HasSwitch( | 130 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
131 switches::kDisableVirtualKeyboardOverscroll)) { | 131 switches::kDisableVirtualKeyboardOverscroll)) { |
132 return false; | 132 return false; |
133 } | 133 } |
134 return true; | 134 return true; |
135 } | 135 } |
136 | 136 |
137 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { | 137 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { |
138 g_keyboard_overscroll_override = override; | 138 g_keyboard_overscroll_override = override; |
139 } | 139 } |
140 | 140 |
141 void SetKeyboardShowOverride(KeyboardShowOverride override) { | 141 void SetKeyboardShowOverride(KeyboardShowOverride override) { |
142 g_keyboard_show_override = override; | 142 g_keyboard_show_override = override; |
143 } | 143 } |
144 | 144 |
145 bool IsInputViewEnabled() { | 145 bool IsInputViewEnabled() { |
146 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) | 146 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 147 switches::kEnableInputView)) |
147 return true; | 148 return true; |
148 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) | 149 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 150 switches::kDisableInputView)) |
149 return false; | 151 return false; |
150 // Default value if no command line flags specified. | 152 // Default value if no command line flags specified. |
151 return true; | 153 return true; |
152 } | 154 } |
153 | 155 |
154 bool IsExperimentalInputViewEnabled() { | 156 bool IsExperimentalInputViewEnabled() { |
155 if (CommandLine::ForCurrentProcess()->HasSwitch( | 157 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
156 switches::kEnableExperimentalInputViewFeatures)) { | 158 switches::kEnableExperimentalInputViewFeatures)) { |
157 return true; | 159 return true; |
158 } | 160 } |
159 return false; | 161 return false; |
160 } | 162 } |
161 | 163 |
162 bool InsertText(const base::string16& text) { | 164 bool InsertText(const base::string16& text) { |
163 keyboard::KeyboardController* controller = KeyboardController::GetInstance(); | 165 keyboard::KeyboardController* controller = KeyboardController::GetInstance(); |
164 if (!controller) | 166 if (!controller) |
165 return false; | 167 return false; |
166 | 168 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 385 } |
384 | 386 |
385 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 387 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
386 UMA_HISTOGRAM_ENUMERATION( | 388 UMA_HISTOGRAM_ENUMERATION( |
387 "VirtualKeyboard.KeyboardControlEvent", | 389 "VirtualKeyboard.KeyboardControlEvent", |
388 event, | 390 event, |
389 keyboard::KEYBOARD_CONTROL_MAX); | 391 keyboard::KEYBOARD_CONTROL_MAX); |
390 } | 392 } |
391 | 393 |
392 } // namespace keyboard | 394 } // namespace keyboard |
OLD | NEW |