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

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

Issue 47873003: Add a full screen virtual keyboard to virtual keyboard root window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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_controller.h" 5 #include "ui/keyboard/keyboard_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "ui/aura/layout_manager.h" 9 #include "ui/aura/layout_manager.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/aura/window_delegate.h" 11 #include "ui/aura/window_delegate.h"
12 #include "ui/base/cursor/cursor.h" 12 #include "ui/base/cursor/cursor.h"
13 #include "ui/base/hit_test.h" 13 #include "ui/base/hit_test.h"
14 #include "ui/base/ime/input_method.h" 14 #include "ui/base/ime/input_method.h"
15 #include "ui/base/ime/text_input_client.h" 15 #include "ui/base/ime/text_input_client.h"
16 #include "ui/base/ime/text_input_type.h" 16 #include "ui/base/ime/text_input_type.h"
17 #include "ui/gfx/path.h" 17 #include "ui/gfx/path.h"
18 #include "ui/gfx/rect.h" 18 #include "ui/gfx/rect.h"
19 #include "ui/gfx/skia_util.h" 19 #include "ui/gfx/skia_util.h"
20 #include "ui/keyboard/keyboard_controller_observer.h" 20 #include "ui/keyboard/keyboard_controller_observer.h"
21 #include "ui/keyboard/keyboard_controller_proxy.h" 21 #include "ui/keyboard/keyboard_controller_proxy.h"
22 #include "ui/keyboard/keyboard_switches.h" 22 #include "ui/keyboard/keyboard_switches.h"
23 #include "ui/keyboard/keyboard_util.h" 23 #include "ui/keyboard/keyboard_util.h"
24 24
25 namespace { 25 namespace {
26 26
27 const int kHideKeyboardDelayMs = 100; 27 const int kHideKeyboardDelayMs = 100;
28 28
29 gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds) { 29 gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds) {
30 const float kKeyboardHeightRatio = 0.3f; 30 const float kKeyboardHeightRatio =
31 keyboard::IsKeyboardUsabilityExperimentEnabled() ? 1.0f : 0.3f;
31 return gfx::Rect( 32 return gfx::Rect(
32 window_bounds.x(), 33 window_bounds.x(),
33 window_bounds.y() + window_bounds.height() * (1 - kKeyboardHeightRatio), 34 window_bounds.y() + window_bounds.height() * (1 - kKeyboardHeightRatio),
34 window_bounds.width(), 35 window_bounds.width(),
35 window_bounds.height() * kKeyboardHeightRatio); 36 window_bounds.height() * kKeyboardHeightRatio);
36 } 37 }
37 38
38 // The KeyboardWindowDelegate makes sure the keyboard-window does not get focus. 39 // The KeyboardWindowDelegate makes sure the keyboard-window does not get focus.
39 // This is necessary to make sure that the synthetic key-events reach the target 40 // This is necessary to make sure that the synthetic key-events reach the target
40 // window. 41 // window.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void KeyboardController::OnTextInputStateChanged( 185 void KeyboardController::OnTextInputStateChanged(
185 const ui::TextInputClient* client) { 186 const ui::TextInputClient* client) {
186 if (!container_.get()) 187 if (!container_.get())
187 return; 188 return;
188 189
189 bool was_showing = keyboard_visible_; 190 bool was_showing = keyboard_visible_;
190 bool should_show = was_showing; 191 bool should_show = was_showing;
191 ui::TextInputType type = 192 ui::TextInputType type =
192 client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; 193 client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
193 if (type == ui::TEXT_INPUT_TYPE_NONE && 194 if (type == ui::TEXT_INPUT_TYPE_NONE &&
194 !CommandLine::ForCurrentProcess()->HasSwitch( 195 !IsKeyboardUsabilityExperimentEnabled()) {
195 switches::kKeyboardUsabilityTest)) {
196 should_show = false; 196 should_show = false;
197 } else { 197 } else {
198 if (container_->children().empty()) { 198 if (container_->children().empty()) {
199 keyboard::MarkKeyboardLoadStarted(); 199 keyboard::MarkKeyboardLoadStarted();
200 aura::Window* keyboard = proxy_->GetKeyboardWindow(); 200 aura::Window* keyboard = proxy_->GetKeyboardWindow();
201 keyboard->Show(); 201 keyboard->Show();
202 container_->AddChild(keyboard); 202 container_->AddChild(keyboard);
203 container_->layout_manager()->OnWindowResized(); 203 container_->layout_manager()->OnWindowResized();
204 } 204 }
205 proxy_->SetUpdateInputType(type); 205 if (type != ui::TEXT_INPUT_TYPE_NONE)
206 proxy_->SetUpdateInputType(type);
206 container_->parent()->StackChildAtTop(container_.get()); 207 container_->parent()->StackChildAtTop(container_.get());
207 should_show = true; 208 should_show = true;
208 } 209 }
209 210
210 if (was_showing != should_show) { 211 if (was_showing != should_show) {
211 if (should_show) { 212 if (should_show) {
212 keyboard_visible_ = true; 213 keyboard_visible_ = true;
213 214
214 // If the controller is in the process of hiding the keyboard, do not log 215 // If the controller is in the process of hiding the keyboard, do not log
215 // the stat here since the keyboard will not actually be shown. 216 // the stat here since the keyboard will not actually be shown.
(...skipping 29 matching lines...) Expand all
245 const ui::InputMethod* input_method) { 246 const ui::InputMethod* input_method) {
246 DCHECK_EQ(input_method_, input_method); 247 DCHECK_EQ(input_method_, input_method);
247 input_method_ = NULL; 248 input_method_ = NULL;
248 } 249 }
249 250
250 bool KeyboardController::WillHideKeyboard() const { 251 bool KeyboardController::WillHideKeyboard() const {
251 return weak_factory_.HasWeakPtrs(); 252 return weak_factory_.HasWeakPtrs();
252 } 253 }
253 254
254 } // namespace keyboard 255 } // namespace keyboard
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc ('k') | ui/keyboard/keyboard_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698