| 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 | 37 |
| 38 base::LazyInstance<base::Time> g_keyboard_load_time_start = | 38 base::LazyInstance<base::Time> g_keyboard_load_time_start = |
| 39 LAZY_INSTANCE_INITIALIZER; | 39 LAZY_INSTANCE_INITIALIZER; |
| 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 bool g_kiosk_keyboard_enabled = false; |
| 48 |
| 47 keyboard::KeyboardOverscrolOverride g_keyboard_overscroll_override = | 49 keyboard::KeyboardOverscrolOverride g_keyboard_overscroll_override = |
| 48 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE; | 50 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE; |
| 49 | 51 |
| 50 } // namespace | 52 } // namespace |
| 51 | 53 |
| 52 namespace keyboard { | 54 namespace keyboard { |
| 53 | 55 |
| 54 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( | 56 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( |
| 55 const gfx::Rect& window_bounds) { | 57 const gfx::Rect& window_bounds) { |
| 56 // Initialize default keyboard height to 0. The keyboard window height should | 58 // Initialize default keyboard height to 0. The keyboard window height should |
| (...skipping 26 matching lines...) Expand all Loading... |
| 83 } | 85 } |
| 84 | 86 |
| 85 void SetTouchKeyboardEnabled(bool enabled) { | 87 void SetTouchKeyboardEnabled(bool enabled) { |
| 86 g_touch_keyboard_enabled = enabled; | 88 g_touch_keyboard_enabled = enabled; |
| 87 } | 89 } |
| 88 | 90 |
| 89 bool GetTouchKeyboardEnabled() { | 91 bool GetTouchKeyboardEnabled() { |
| 90 return g_touch_keyboard_enabled; | 92 return g_touch_keyboard_enabled; |
| 91 } | 93 } |
| 92 | 94 |
| 95 void SetKioskKeyboardEnabled(bool enabled) { |
| 96 g_kiosk_keyboard_enabled = enabled; |
| 97 } |
| 98 |
| 99 bool GetKioskKeyboardEnabled() { |
| 100 return g_kiosk_keyboard_enabled; |
| 101 } |
| 102 |
| 93 std::string GetKeyboardLayout() { | 103 std::string GetKeyboardLayout() { |
| 94 // TODO(bshe): layout string is currently hard coded. We should use more | 104 // TODO(bshe): layout string is currently hard coded. We should use more |
| 95 // standard keyboard layouts. | 105 // standard keyboard layouts. |
| 96 return GetAccessibilityKeyboardEnabled() ? "system-qwerty" : "qwerty"; | 106 return GetAccessibilityKeyboardEnabled() ? "system-qwerty" : "qwerty"; |
| 97 } | 107 } |
| 98 | 108 |
| 99 bool IsKeyboardEnabled() { | 109 bool IsKeyboardEnabled() { |
| 100 return g_accessibility_keyboard_enabled || | 110 return g_accessibility_keyboard_enabled || |
| 101 CommandLine::ForCurrentProcess()->HasSwitch( | 111 CommandLine::ForCurrentProcess()->HasSwitch( |
| 102 switches::kEnableVirtualKeyboard) || | 112 switches::kEnableVirtualKeyboard) || |
| 103 IsKeyboardUsabilityExperimentEnabled() || | 113 IsKeyboardUsabilityExperimentEnabled() || g_touch_keyboard_enabled || |
| 104 g_touch_keyboard_enabled; | 114 g_kiosk_keyboard_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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 } | 363 } |
| 354 | 364 |
| 355 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 365 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
| 356 UMA_HISTOGRAM_ENUMERATION( | 366 UMA_HISTOGRAM_ENUMERATION( |
| 357 "VirtualKeyboard.KeyboardControlEvent", | 367 "VirtualKeyboard.KeyboardControlEvent", |
| 358 event, | 368 event, |
| 359 keyboard::KEYBOARD_CONTROL_MAX); | 369 keyboard::KEYBOARD_CONTROL_MAX); |
| 360 } | 370 } |
| 361 | 371 |
| 362 } // namespace keyboard | 372 } // namespace keyboard |
| OLD | NEW |