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 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 base::LazyInstance<base::Time> g_keyboard_load_time_start = | 39 base::LazyInstance<base::Time> g_keyboard_load_time_start = |
40 LAZY_INSTANCE_INITIALIZER; | 40 LAZY_INSTANCE_INITIALIZER; |
41 | 41 |
42 bool g_accessibility_keyboard_enabled = false; | 42 bool g_accessibility_keyboard_enabled = false; |
43 | 43 |
44 base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER; | 44 base::LazyInstance<GURL> g_override_content_url = LAZY_INSTANCE_INITIALIZER; |
45 | 45 |
46 bool g_touch_keyboard_enabled = false; | 46 bool g_touch_keyboard_enabled = false; |
47 | 47 |
48 bool g_keyboard_overscroll_override_enabled = false; | |
49 | |
50 bool g_keyboard_overscroll_enabled_override_value = true; | |
kevers
2014/05/21 13:56:11
Feels a bit messy using 2 booleans here. Can we re
Nikita (slow)
2014/05/21 17:21:04
Done.
| |
51 | |
48 } // namespace | 52 } // namespace |
49 | 53 |
50 namespace keyboard { | 54 namespace keyboard { |
51 | 55 |
52 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( | 56 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( |
53 const gfx::Rect& window_bounds) { | 57 const gfx::Rect& window_bounds) { |
54 // Initialize default keyboard height to 0. The keyboard window height should | 58 // Initialize default keyboard height to 0. The keyboard window height should |
55 // only be set by window.resizeTo in virtual keyboard web contents. Otherwise, | 59 // only be set by window.resizeTo in virtual keyboard web contents. Otherwise, |
56 // the default height may conflict with the new height and causing some | 60 // the default height may conflict with the new height and causing some |
57 // strange animation issues. For keyboard usability experiments, a full screen | 61 // strange animation issues. For keyboard usability experiments, a full screen |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 } | 107 } |
104 | 108 |
105 bool IsKeyboardUsabilityExperimentEnabled() { | 109 bool IsKeyboardUsabilityExperimentEnabled() { |
106 return CommandLine::ForCurrentProcess()->HasSwitch( | 110 return CommandLine::ForCurrentProcess()->HasSwitch( |
107 switches::kKeyboardUsabilityExperiment); | 111 switches::kKeyboardUsabilityExperiment); |
108 } | 112 } |
109 | 113 |
110 bool IsKeyboardOverscrollEnabled() { | 114 bool IsKeyboardOverscrollEnabled() { |
111 if (!IsKeyboardEnabled()) | 115 if (!IsKeyboardEnabled()) |
112 return false; | 116 return false; |
117 | |
113 // Users of the accessibility on-screen keyboard are likely to be using mouse | 118 // Users of the accessibility on-screen keyboard are likely to be using mouse |
114 // input, which may interfere with overscrolling. | 119 // input, which may interfere with overscrolling. |
115 if (g_accessibility_keyboard_enabled) | 120 if (g_accessibility_keyboard_enabled) |
116 return false; | 121 return false; |
122 | |
123 // If overscroll enabled override is set, use it instead. Currently | |
124 // login / out-of-box disable keyboard overscroll. http://crbug.com/363635 | |
125 if (g_keyboard_overscroll_override_enabled) | |
126 return g_keyboard_overscroll_enabled_override_value; | |
127 | |
117 if (CommandLine::ForCurrentProcess()->HasSwitch( | 128 if (CommandLine::ForCurrentProcess()->HasSwitch( |
118 switches::kDisableVirtualKeyboardOverscroll)) { | 129 switches::kDisableVirtualKeyboardOverscroll)) { |
119 return false; | 130 return false; |
120 } | 131 } |
121 return true; | 132 return true; |
122 } | 133 } |
123 | 134 |
135 void SetKeyboardOverscrollEnabledOverrideValue(bool enabled) { | |
136 g_keyboard_overscroll_enabled_override_value = enabled; | |
137 } | |
138 | |
139 void SetKeyboardOverscrollOverrideEnabled(bool enabled) { | |
140 g_keyboard_overscroll_override_enabled = enabled; | |
141 } | |
142 | |
124 bool IsInputViewEnabled() { | 143 bool IsInputViewEnabled() { |
125 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) | 144 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableInputView)) |
126 return true; | 145 return true; |
127 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) | 146 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableInputView)) |
128 return false; | 147 return false; |
129 // Default value if no command line flags specified. | 148 // Default value if no command line flags specified. |
130 return true; | 149 return true; |
131 } | 150 } |
132 | 151 |
133 bool InsertText(const base::string16& text, aura::Window* root_window) { | 152 bool InsertText(const base::string16& text, aura::Window* root_window) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 } | 357 } |
339 | 358 |
340 void LogKeyboardControlEvent(KeyboardControlEvent event) { | 359 void LogKeyboardControlEvent(KeyboardControlEvent event) { |
341 UMA_HISTOGRAM_ENUMERATION( | 360 UMA_HISTOGRAM_ENUMERATION( |
342 "VirtualKeyboard.KeyboardControlEvent", | 361 "VirtualKeyboard.KeyboardControlEvent", |
343 event, | 362 event, |
344 keyboard::KEYBOARD_CONTROL_MAX); | 363 keyboard::KEYBOARD_CONTROL_MAX); |
345 } | 364 } |
346 | 365 |
347 } // namespace keyboard | 366 } // namespace keyboard |
OLD | NEW |