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 keyboard::KeyboardOverscrolOverride g_keyboard_overscroll_override = |
| 48 keyboard::KEYBOARD_OVERSCROLL_OVERRIDE_NONE; |
| 49 |
47 } // namespace | 50 } // namespace |
48 | 51 |
49 namespace keyboard { | 52 namespace keyboard { |
50 | 53 |
51 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( | 54 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( |
52 const gfx::Rect& window_bounds) { | 55 const gfx::Rect& window_bounds) { |
53 // Initialize default keyboard height to 0. The keyboard window height should | 56 // Initialize default keyboard height to 0. The keyboard window height should |
54 // only be set by window.resizeTo in virtual keyboard web contents. Otherwise, | 57 // only be set by window.resizeTo in virtual keyboard web contents. Otherwise, |
55 // the default height may conflict with the new height and causing some | 58 // the default height may conflict with the new height and causing some |
56 // strange animation issues. For keyboard usability experiments, a full screen | 59 // strange animation issues. For keyboard usability experiments, a full screen |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } | 105 } |
103 | 106 |
104 bool IsKeyboardUsabilityExperimentEnabled() { | 107 bool IsKeyboardUsabilityExperimentEnabled() { |
105 return CommandLine::ForCurrentProcess()->HasSwitch( | 108 return CommandLine::ForCurrentProcess()->HasSwitch( |
106 switches::kKeyboardUsabilityExperiment); | 109 switches::kKeyboardUsabilityExperiment); |
107 } | 110 } |
108 | 111 |
109 bool IsKeyboardOverscrollEnabled() { | 112 bool IsKeyboardOverscrollEnabled() { |
110 if (!IsKeyboardEnabled()) | 113 if (!IsKeyboardEnabled()) |
111 return false; | 114 return false; |
| 115 |
112 // Users of the accessibility on-screen keyboard are likely to be using mouse | 116 // Users of the accessibility on-screen keyboard are likely to be using mouse |
113 // input, which may interfere with overscrolling. | 117 // input, which may interfere with overscrolling. |
114 if (g_accessibility_keyboard_enabled) | 118 if (g_accessibility_keyboard_enabled) |
115 return false; | 119 return false; |
| 120 |
| 121 // If overscroll enabled override is set, use it instead. Currently |
| 122 // login / out-of-box disable keyboard overscroll. http://crbug.com/363635 |
| 123 if (g_keyboard_overscroll_override != KEYBOARD_OVERSCROLL_OVERRIDE_NONE) { |
| 124 return g_keyboard_overscroll_override == |
| 125 KEYBOARD_OVERSCROLL_OVERRIDE_ENABLED; |
| 126 } |
| 127 |
116 if (CommandLine::ForCurrentProcess()->HasSwitch( | 128 if (CommandLine::ForCurrentProcess()->HasSwitch( |
117 switches::kDisableVirtualKeyboardOverscroll)) { | 129 switches::kDisableVirtualKeyboardOverscroll)) { |
118 return false; | 130 return false; |
119 } | 131 } |
120 return true; | 132 return true; |
121 } | 133 } |
122 | 134 |
| 135 void SetKeyboardOverscrollOverride(KeyboardOverscrolOverride override) { |
| 136 g_keyboard_overscroll_override = override; |
| 137 } |
| 138 |
123 bool IsInputViewEnabled() { | 139 bool IsInputViewEnabled() { |
124 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) | 140 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) |
125 return true; | 141 return true; |
126 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) | 142 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) |
127 return false; | 143 return false; |
128 // Default value if no command line flags specified. | 144 // Default value if no command line flags specified. |
129 return true; | 145 return true; |
130 } | 146 } |
131 | 147 |
132 bool InsertText(const base::string16& text, aura::Window* root_window) { | 148 bool InsertText(const base::string16& text, aura::Window* root_window) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 353 } |
338 | 354 |
339 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 355 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
340 UMA_HISTOGRAM_ENUMERATION( | 356 UMA_HISTOGRAM_ENUMERATION( |
341 "VirtualKeyboard.KeyboardControlEvent", | 357 "VirtualKeyboard.KeyboardControlEvent", |
342 event, | 358 event, |
343 keyboard::KEYBOARD_CONTROL_MAX); | 359 keyboard::KEYBOARD_CONTROL_MAX); |
344 } | 360 } |
345 | 361 |
346 } // namespace keyboard | 362 } // namespace keyboard |
OLD | NEW |