Chromium Code Reviews| 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 = | |
|
bartfab (slow)
2014/06/16 10:20:13
Nit: Should this be in an #ifdef? It is not used o
rsadam
2014/06/16 13:45:35
Tthe virtual keyboard is only ever created on CHRO
bartfab (slow)
2014/06/16 14:14:02
I see nothing in the gyp files excluding this file
| |
| 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 15 matching lines...) Expand all Loading... | |
| 75 } | 78 } |
| 76 | 79 |
| 77 void SetAccessibilityKeyboardEnabled(bool enabled) { | 80 void SetAccessibilityKeyboardEnabled(bool enabled) { |
| 78 g_accessibility_keyboard_enabled = enabled; | 81 g_accessibility_keyboard_enabled = enabled; |
| 79 } | 82 } |
| 80 | 83 |
| 81 bool GetAccessibilityKeyboardEnabled() { | 84 bool GetAccessibilityKeyboardEnabled() { |
| 82 return g_accessibility_keyboard_enabled; | 85 return g_accessibility_keyboard_enabled; |
| 83 } | 86 } |
| 84 | 87 |
| 85 void SetTouchKeyboardEnabled(bool enabled) { | 88 void SetTouchKeyboardEnabled(bool enabled) { |
|
bartfab (slow)
2014/06/16 10:20:13
What UI is used to control this? Can we gray out t
rsadam
2014/06/16 13:45:34
There isn't a UI for this - it's enabled when the
| |
| 86 g_touch_keyboard_enabled = enabled; | 89 g_touch_keyboard_enabled = enabled; |
| 87 } | 90 } |
| 88 | 91 |
| 89 bool GetTouchKeyboardEnabled() { | 92 bool GetTouchKeyboardEnabled() { |
| 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) |
|
bartfab (slow)
2014/06/16 10:20:13
Could you check whether this can be used to overri
rsadam
2014/06/16 13:45:34
The keyboard only shows on text input focus - but
| |
| 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() || g_touch_keyboard_enabled || | |
|
bartfab (slow)
2014/06/16 10:20:13
Nit: Could you reformat this so there is one condi
rsadam
2014/06/16 13:45:34
Done.
| |
| 113 (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED); | |
| 105 } | 114 } |
| 106 | 115 |
| 107 bool IsKeyboardUsabilityExperimentEnabled() { | 116 bool IsKeyboardUsabilityExperimentEnabled() { |
| 108 return CommandLine::ForCurrentProcess()->HasSwitch( | 117 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 109 switches::kKeyboardUsabilityExperiment); | 118 switches::kKeyboardUsabilityExperiment); |
| 110 } | 119 } |
| 111 | 120 |
| 112 bool IsKeyboardOverscrollEnabled() { | 121 bool IsKeyboardOverscrollEnabled() { |
| 113 if (!IsKeyboardEnabled()) | 122 if (!IsKeyboardEnabled()) |
| 114 return false; | 123 return false; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 129 switches::kDisableVirtualKeyboardOverscroll)) { | 138 switches::kDisableVirtualKeyboardOverscroll)) { |
| 130 return false; | 139 return false; |
| 131 } | 140 } |
| 132 return true; | 141 return true; |
| 133 } | 142 } |
| 134 | 143 |
| 135 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { | 144 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { |
| 136 g_keyboard_overscroll_override = override; | 145 g_keyboard_overscroll_override = override; |
| 137 } | 146 } |
| 138 | 147 |
| 148 void SetKeyboardShowOverride(KeyboardShowOverride override) { | |
| 149 g_keyboard_show_override = override; | |
| 150 } | |
| 151 | |
| 139 bool IsInputViewEnabled() { | 152 bool IsInputViewEnabled() { |
| 140 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) | 153 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) |
| 141 return true; | 154 return true; |
| 142 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) | 155 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) |
| 143 return false; | 156 return false; |
| 144 // Default value if no command line flags specified. | 157 // Default value if no command line flags specified. |
| 145 return true; | 158 return true; |
| 146 } | 159 } |
| 147 | 160 |
| 148 bool IsExperimentalInputViewEnabled() { | 161 bool IsExperimentalInputViewEnabled() { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 } | 374 } |
| 362 | 375 |
| 363 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 376 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
| 364 UMA_HISTOGRAM_ENUMERATION( | 377 UMA_HISTOGRAM_ENUMERATION( |
| 365 "VirtualKeyboard.KeyboardControlEvent", | 378 "VirtualKeyboard.KeyboardControlEvent", |
| 366 event, | 379 event, |
| 367 keyboard::KEYBOARD_CONTROL_MAX); | 380 keyboard::KEYBOARD_CONTROL_MAX); |
| 368 } | 381 } |
| 369 | 382 |
| 370 } // namespace keyboard | 383 } // namespace keyboard |
| OLD | NEW |