| 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 26 matching lines...) Expand all Loading... |
| 37 ui::EF_IS_SYNTHESIZED, ui::DomKey::PROCESS, | 37 ui::EF_IS_SYNTHESIZED, ui::DomKey::PROCESS, |
| 38 ui::EventTimeForNow()); | 38 ui::EventTimeForNow()); |
| 39 ui::EventDispatchDetails details = | 39 ui::EventDispatchDetails details = |
| 40 host->event_processor()->OnEventFromSource(&event); | 40 host->event_processor()->OnEventFromSource(&event); |
| 41 CHECK(!details.dispatcher_destroyed); | 41 CHECK(!details.dispatcher_destroyed); |
| 42 } | 42 } |
| 43 | 43 |
| 44 base::LazyInstance<base::Time> g_keyboard_load_time_start = | 44 base::LazyInstance<base::Time> g_keyboard_load_time_start = |
| 45 LAZY_INSTANCE_INITIALIZER; | 45 LAZY_INSTANCE_INITIALIZER; |
| 46 | 46 |
| 47 bool g_force_disable_keyboard_for_web_ui = false; |
| 48 |
| 47 bool g_accessibility_keyboard_enabled = false; | 49 bool g_accessibility_keyboard_enabled = false; |
| 48 | 50 |
| 49 bool g_hotrod_keyboard_enabled = false; | 51 bool g_hotrod_keyboard_enabled = false; |
| 50 | 52 |
| 51 bool g_touch_keyboard_enabled = false; | 53 bool g_touch_keyboard_enabled = false; |
| 52 | 54 |
| 53 keyboard::KeyboardState g_requested_keyboard_state = | 55 keyboard::KeyboardState g_requested_keyboard_state = |
| 54 keyboard::KEYBOARD_STATE_AUTO; | 56 keyboard::KEYBOARD_STATE_AUTO; |
| 55 | 57 |
| 56 keyboard::KeyboardOverscrolOverride g_keyboard_overscroll_override = | 58 keyboard::KeyboardOverscrolOverride g_keyboard_overscroll_override = |
| 57 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE; | 59 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE; |
| 58 | 60 |
| 59 keyboard::KeyboardShowOverride g_keyboard_show_override = | 61 keyboard::KeyboardShowOverride g_keyboard_show_override = |
| 60 keyboard::KEYBOARD_SHOW_OVERRIDE_NONE; | 62 keyboard::KEYBOARD_SHOW_OVERRIDE_NONE; |
| 61 | 63 |
| 62 } // namespace | 64 } // namespace |
| 63 | 65 |
| 64 namespace keyboard { | 66 namespace keyboard { |
| 65 | 67 |
| 66 gfx::Rect FullWidthKeyboardBoundsFromRootBounds(const gfx::Rect& root_bounds, | 68 gfx::Rect FullWidthKeyboardBoundsFromRootBounds(const gfx::Rect& root_bounds, |
| 67 int keyboard_height) { | 69 int keyboard_height) { |
| 68 return gfx::Rect( | 70 return gfx::Rect( |
| 69 root_bounds.x(), | 71 root_bounds.x(), |
| 70 root_bounds.bottom() - keyboard_height, | 72 root_bounds.bottom() - keyboard_height, |
| 71 root_bounds.width(), | 73 root_bounds.width(), |
| 72 keyboard_height); | 74 keyboard_height); |
| 73 } | 75 } |
| 74 | 76 |
| 77 void SetForceDisableVirtualKeyboardForWebUi(bool disable) { |
| 78 g_force_disable_keyboard_for_web_ui = disable; |
| 79 } |
| 80 |
| 81 bool GetForceDisableVirtualKeyboardForWebUi() { |
| 82 return g_force_disable_keyboard_for_web_ui; |
| 83 } |
| 84 |
| 75 void SetAccessibilityKeyboardEnabled(bool enabled) { | 85 void SetAccessibilityKeyboardEnabled(bool enabled) { |
| 76 g_accessibility_keyboard_enabled = enabled; | 86 g_accessibility_keyboard_enabled = enabled; |
| 77 } | 87 } |
| 78 | 88 |
| 79 bool GetAccessibilityKeyboardEnabled() { | 89 bool GetAccessibilityKeyboardEnabled() { |
| 80 return g_accessibility_keyboard_enabled; | 90 return g_accessibility_keyboard_enabled; |
| 81 } | 91 } |
| 82 | 92 |
| 83 void SetHotrodKeyboardEnabled(bool enabled) { | 93 void SetHotrodKeyboardEnabled(bool enabled) { |
| 84 g_hotrod_keyboard_enabled = enabled; | 94 g_hotrod_keyboard_enabled = enabled; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 104 return g_requested_keyboard_state; | 114 return g_requested_keyboard_state; |
| 105 } | 115 } |
| 106 | 116 |
| 107 std::string GetKeyboardLayout() { | 117 std::string GetKeyboardLayout() { |
| 108 // TODO(bshe): layout string is currently hard coded. We should use more | 118 // TODO(bshe): layout string is currently hard coded. We should use more |
| 109 // standard keyboard layouts. | 119 // standard keyboard layouts. |
| 110 return GetAccessibilityKeyboardEnabled() ? "system-qwerty" : "qwerty"; | 120 return GetAccessibilityKeyboardEnabled() ? "system-qwerty" : "qwerty"; |
| 111 } | 121 } |
| 112 | 122 |
| 113 bool IsKeyboardEnabled() { | 123 bool IsKeyboardEnabled() { |
| 124 // Blocks keyboard from showing up regardless of other settings. |
| 125 if (g_force_disable_keyboard_for_web_ui) |
| 126 return false; |
| 114 // Accessibility setting prioritized over policy setting. | 127 // Accessibility setting prioritized over policy setting. |
| 115 if (g_accessibility_keyboard_enabled) | 128 if (g_accessibility_keyboard_enabled) |
| 116 return true; | 129 return true; |
| 117 // Policy strictly disables showing a virtual keyboard. | 130 // Policy strictly disables showing a virtual keyboard. |
| 118 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED) | 131 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_DISABLED) |
| 119 return false; | 132 return false; |
| 120 // Policy strictly enables the keyboard. | 133 // Policy strictly enables the keyboard. |
| 121 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED) | 134 if (g_keyboard_show_override == keyboard::KEYBOARD_SHOW_OVERRIDE_ENABLED) |
| 122 return true; | 135 return true; |
| 123 // Run-time flag to enable keyboard has been included. | 136 // Run-time flag to enable keyboard has been included. |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 385 } |
| 373 | 386 |
| 374 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 387 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
| 375 UMA_HISTOGRAM_ENUMERATION( | 388 UMA_HISTOGRAM_ENUMERATION( |
| 376 "VirtualKeyboard.KeyboardControlEvent", | 389 "VirtualKeyboard.KeyboardControlEvent", |
| 377 event, | 390 event, |
| 378 keyboard::KEYBOARD_CONTROL_MAX); | 391 keyboard::KEYBOARD_CONTROL_MAX); |
| 379 } | 392 } |
| 380 | 393 |
| 381 } // namespace keyboard | 394 } // namespace keyboard |
| OLD | NEW |