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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 bool g_accessibility_keyboard_enabled = false; | 41 bool g_accessibility_keyboard_enabled = false; |
42 | 42 |
43 base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER; | 43 base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER; |
44 | 44 |
45 bool g_touch_keyboard_enabled = false; | 45 bool g_touch_keyboard_enabled = false; |
46 | 46 |
47 keyboard::KeyboardOverscrolOverride g_keyboard_overscroll_override = | 47 keyboard::KeyboardOverscrolOverride g_keyboard_overscroll_override = |
48 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE; | 48 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE; |
49 | 49 |
| 50 keyboard::KeyboardShowOverride g_keyboard_show_override = |
| 51 keyboard::KEYBOARD_SHOW_OVERRIDE_NONE; |
| 52 |
50 } // namespace | 53 } // namespace |
51 | 54 |
52 namespace keyboard { | 55 namespace keyboard { |
53 | 56 |
54 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( | 57 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( |
55 const gfx::Rect& window_bounds) { | 58 const gfx::Rect& window_bounds) { |
56 // Initialize default keyboard height to 0. The keyboard window height should | 59 // Initialize default keyboard height to 0. The keyboard window height should |
57 // only be set by window.resizeTo in virtual keyboard web contents. Otherwise, | 60 // only be set by window.resizeTo in virtual keyboard web contents. Otherwise, |
58 // the default height may conflict with the new height and causing some | 61 // the default height may conflict with the new height and causing some |
59 // strange animation issues. For keyboard usability experiments, a full screen | 62 // strange animation issues. For keyboard usability experiments, a full screen |
(...skipping 30 matching lines...) Expand all Loading... |
90 return g_touch_keyboard_enabled; | 93 return g_touch_keyboard_enabled; |
91 } | 94 } |
92 | 95 |
93 std::string GetKeyboardLayout() { | 96 std::string GetKeyboardLayout() { |
94 // TODO(bshe): layout string is currently hard coded. We should use more | 97 // TODO(bshe): layout string is currently hard coded. We should use more |
95 // standard keyboard layouts. | 98 // standard keyboard layouts. |
96 return GetAccessibilityKeyboardEnabled() ? "system-qwerty" : "qwerty"; | 99 return GetAccessibilityKeyboardEnabled() ? "system-qwerty" : "qwerty"; |
97 } | 100 } |
98 | 101 |
99 bool IsKeyboardEnabled() { | 102 bool IsKeyboardEnabled() { |
100 return g_accessibility_keyboard_enabled || | 103 // Accessibility setting prioritized over policy setting. |
101 CommandLine::ForCurrentProcess()->HasSwitch( | 104 if (g_accessibility_keyboard_enabled) |
102 switches::kEnableVirtualKeyboard) || | 105 return true; |
103 IsKeyboardUsabilityExperimentEnabled() || | 106 // Policy strictly disables showing a virtual keyboard. |
104 g_touch_keyboard_enabled; | 107 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED) |
| 108 return false; |
| 109 // Check if any of the flags are enabled. |
| 110 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 switches::kEnableVirtualKeyboard) || |
| 112 IsKeyboardUsabilityExperimentEnabled() || |
| 113 g_touch_keyboard_enabled || |
| 114 (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED); |
105 } | 115 } |
106 | 116 |
107 bool IsKeyboardUsabilityExperimentEnabled() { | 117 bool IsKeyboardUsabilityExperimentEnabled() { |
108 return CommandLine::ForCurrentProcess()->HasSwitch( | 118 return CommandLine::ForCurrentProcess()->HasSwitch( |
109 switches::kKeyboardUsabilityExperiment); | 119 switches::kKeyboardUsabilityExperiment); |
110 } | 120 } |
111 | 121 |
112 bool IsKeyboardOverscrollEnabled() { | 122 bool IsKeyboardOverscrollEnabled() { |
113 if (!IsKeyboardEnabled()) | 123 if (!IsKeyboardEnabled()) |
114 return false; | 124 return false; |
(...skipping 14 matching lines...) Expand all Loading... |
129 switches::kDisableVirtualKeyboardOverscroll)) { | 139 switches::kDisableVirtualKeyboardOverscroll)) { |
130 return false; | 140 return false; |
131 } | 141 } |
132 return true; | 142 return true; |
133 } | 143 } |
134 | 144 |
135 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { | 145 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { |
136 g_keyboard_overscroll_override = override; | 146 g_keyboard_overscroll_override = override; |
137 } | 147 } |
138 | 148 |
| 149 void SetKeyboardShowOverride(KeyboardShowOverride override) { |
| 150 g_keyboard_show_override = override; |
| 151 } |
| 152 |
139 bool IsInputViewEnabled() { | 153 bool IsInputViewEnabled() { |
140 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) | 154 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) |
141 return true; | 155 return true; |
142 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) | 156 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) |
143 return false; | 157 return false; |
144 // Default value if no command line flags specified. | 158 // Default value if no command line flags specified. |
145 return true; | 159 return true; |
146 } | 160 } |
147 | 161 |
148 bool IsExperimentalInputViewEnabled() { | 162 bool IsExperimentalInputViewEnabled() { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 375 } |
362 | 376 |
363 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 377 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
364 UMA_HISTOGRAM_ENUMERATION( | 378 UMA_HISTOGRAM_ENUMERATION( |
365 "VirtualKeyboard.KeyboardControlEvent", | 379 "VirtualKeyboard.KeyboardControlEvent", |
366 event, | 380 event, |
367 keyboard::KEYBOARD_CONTROL_MAX); | 381 keyboard::KEYBOARD_CONTROL_MAX); |
368 } | 382 } |
369 | 383 |
370 } // namespace keyboard | 384 } // namespace keyboard |
OLD | NEW |