| 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() { |
| 103 // Policy strictly disables showing a virtual keyboard. |
| 104 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED) |
| 105 return false; |
| 106 // Check if any of the flags are enabled. |
| 100 return g_accessibility_keyboard_enabled || | 107 return g_accessibility_keyboard_enabled || |
| 101 CommandLine::ForCurrentProcess()->HasSwitch( | 108 CommandLine::ForCurrentProcess()->HasSwitch( |
| 102 switches::kEnableVirtualKeyboard) || | 109 switches::kEnableVirtualKeyboard) || |
| 103 IsKeyboardUsabilityExperimentEnabled() || | 110 IsKeyboardUsabilityExperimentEnabled() || g_touch_keyboard_enabled || |
| 104 g_touch_keyboard_enabled; | 111 (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED); |
| 105 } | 112 } |
| 106 | 113 |
| 107 bool IsKeyboardUsabilityExperimentEnabled() { | 114 bool IsKeyboardUsabilityExperimentEnabled() { |
| 108 return CommandLine::ForCurrentProcess()->HasSwitch( | 115 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 109 switches::kKeyboardUsabilityExperiment); | 116 switches::kKeyboardUsabilityExperiment); |
| 110 } | 117 } |
| 111 | 118 |
| 112 bool IsKeyboardOverscrollEnabled() { | 119 bool IsKeyboardOverscrollEnabled() { |
| 113 if (!IsKeyboardEnabled()) | 120 if (!IsKeyboardEnabled()) |
| 114 return false; | 121 return false; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 129 switches::kDisableVirtualKeyboardOverscroll)) { | 136 switches::kDisableVirtualKeyboardOverscroll)) { |
| 130 return false; | 137 return false; |
| 131 } | 138 } |
| 132 return true; | 139 return true; |
| 133 } | 140 } |
| 134 | 141 |
| 135 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { | 142 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { |
| 136 g_keyboard_overscroll_override = override; | 143 g_keyboard_overscroll_override = override; |
| 137 } | 144 } |
| 138 | 145 |
| 146 void SetKeyboardShowOverride(KeyboardShowOverride override) { |
| 147 g_keyboard_show_override = override; |
| 148 } |
| 149 |
| 139 bool IsInputViewEnabled() { | 150 bool IsInputViewEnabled() { |
| 140 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) | 151 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) |
| 141 return true; | 152 return true; |
| 142 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) | 153 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) |
| 143 return false; | 154 return false; |
| 144 // Default value if no command line flags specified. | 155 // Default value if no command line flags specified. |
| 145 return true; | 156 return true; |
| 146 } | 157 } |
| 147 | 158 |
| 148 bool IsExperimentalInputViewEnabled() { | 159 bool IsExperimentalInputViewEnabled() { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 } | 372 } |
| 362 | 373 |
| 363 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 374 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
| 364 UMA_HISTOGRAM_ENUMERATION( | 375 UMA_HISTOGRAM_ENUMERATION( |
| 365 "VirtualKeyboard.KeyboardControlEvent", | 376 "VirtualKeyboard.KeyboardControlEvent", |
| 366 event, | 377 event, |
| 367 keyboard::KEYBOARD_CONTROL_MAX); | 378 keyboard::KEYBOARD_CONTROL_MAX); |
| 368 } | 379 } |
| 369 | 380 |
| 370 } // namespace keyboard | 381 } // namespace keyboard |
| OLD | NEW |