Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: ui/keyboard/keyboard_util.cc

Issue 240443006: Remove native VK window height logic and wait for resizeTo to setup VK window height (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 25 matching lines...) Expand all
36 CHECK(!details.dispatcher_destroyed); 36 CHECK(!details.dispatcher_destroyed);
37 } 37 }
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 // The ratio between the height of the keyboard and the screen when using the
47 // usability keyboard.
48 const float kUsabilityKeyboardHeightRatio = 1.0f;
49
50 // The default ratio between the height of the keyboard and the screen.
51 const float kDefaultKeyboardHeightRatio = 0.41f;
52
53 // The ratio between the height of the keyboard and the screen when using the
54 // accessibility keyboard.
55 const float kAccessibilityKeyboardHeightRatio = 0.3f;
56
57 float GetKeyboardHeightRatio(){
58 if (keyboard::IsKeyboardUsabilityExperimentEnabled()) {
59 return kUsabilityKeyboardHeightRatio;
60 } else if (keyboard::GetAccessibilityKeyboardEnabled()) {
61 return kAccessibilityKeyboardHeightRatio;
62 }
63 return kDefaultKeyboardHeightRatio;
64 }
65
66 bool g_touch_keyboard_enabled = false; 46 bool g_touch_keyboard_enabled = false;
67 47
68 } // namespace 48 } // namespace
69 49
70 namespace keyboard { 50 namespace keyboard {
71 51
72 gfx::Rect DefaultKeyboardBoundsFromWindowBounds( 52 gfx::Rect DefaultKeyboardBoundsFromWindowBounds(
73 const gfx::Rect& window_bounds) { 53 const gfx::Rect& window_bounds) {
74 const float kKeyboardHeightRatio = GetKeyboardHeightRatio(); 54 // Initialize default keyboard height to 0. The keyboard window height should
55 // 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
57 // strange animation issues. For keyboard usability experiments, a full screen
58 // virtual keyboard window is always preferred.
75 int keyboard_height = 59 int keyboard_height =
76 static_cast<int>(window_bounds.height() * kKeyboardHeightRatio); 60 keyboard::IsKeyboardUsabilityExperimentEnabled() ?
61 window_bounds.height() : 0;
62
77 return gfx::Rect( 63 return gfx::Rect(
78 window_bounds.x(), 64 window_bounds.x(),
79 window_bounds.y() + window_bounds.height() - keyboard_height, 65 window_bounds.y() + window_bounds.height() - keyboard_height,
80 window_bounds.width(), 66 window_bounds.width(),
81 keyboard_height); 67 keyboard_height);
82 } 68 }
83 69
84 void SetAccessibilityKeyboardEnabled(bool enabled) { 70 void SetAccessibilityKeyboardEnabled(bool enabled) {
85 g_accessibility_keyboard_enabled = enabled; 71 g_accessibility_keyboard_enabled = enabled;
86 } 72 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 320 }
335 321
336 void LogKeyboardControlEvent(KeyboardControlEvent event) { 322 void LogKeyboardControlEvent(KeyboardControlEvent event) {
337 UMA_HISTOGRAM_ENUMERATION( 323 UMA_HISTOGRAM_ENUMERATION(
338 "VirtualKeyboard.KeyboardControlEvent", 324 "VirtualKeyboard.KeyboardControlEvent",
339 event, 325 event,
340 keyboard::KEYBOARD_CONTROL_MAX); 326 keyboard::KEYBOARD_CONTROL_MAX);
341 } 327 }
342 328
343 } // namespace keyboard 329 } // namespace keyboard
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698