| 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_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::IsKeyboardUsabilityTestEnabled() ? 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 switches::kKeyboardUsabilityTest)) { | 196 switches::kKeyboardUsabilityTest)) { |
| 196 should_show = false; | 197 should_show = false; |
| 197 } else { | 198 } else { |
| 198 if (container_->children().empty()) { | 199 if (container_->children().empty()) { |
| 199 keyboard::MarkKeyboardLoadStarted(); | 200 keyboard::MarkKeyboardLoadStarted(); |
| 200 aura::Window* keyboard = proxy_->GetKeyboardWindow(); | 201 aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
| 201 keyboard->Show(); | 202 keyboard->Show(); |
| 202 container_->AddChild(keyboard); | 203 container_->AddChild(keyboard); |
| 203 container_->layout_manager()->OnWindowResized(); | 204 container_->layout_manager()->OnWindowResized(); |
| 204 } | 205 } |
| 205 proxy_->SetUpdateInputType(type); | 206 if (type != ui::TEXT_INPUT_TYPE_NONE) |
| 207 proxy_->SetUpdateInputType(type); |
| 206 container_->parent()->StackChildAtTop(container_.get()); | 208 container_->parent()->StackChildAtTop(container_.get()); |
| 207 should_show = true; | 209 should_show = true; |
| 208 } | 210 } |
| 209 | 211 |
| 210 if (was_showing != should_show) { | 212 if (was_showing != should_show) { |
| 211 if (should_show) { | 213 if (should_show) { |
| 212 keyboard_visible_ = true; | 214 keyboard_visible_ = true; |
| 213 | 215 |
| 214 // If the controller is in the process of hiding the keyboard, do not log | 216 // 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. | 217 // the stat here since the keyboard will not actually be shown. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 245 const ui::InputMethod* input_method) { | 247 const ui::InputMethod* input_method) { |
| 246 DCHECK_EQ(input_method_, input_method); | 248 DCHECK_EQ(input_method_, input_method); |
| 247 input_method_ = NULL; | 249 input_method_ = NULL; |
| 248 } | 250 } |
| 249 | 251 |
| 250 bool KeyboardController::WillHideKeyboard() const { | 252 bool KeyboardController::WillHideKeyboard() const { |
| 251 return weak_factory_.HasWeakPtrs(); | 253 return weak_factory_.HasWeakPtrs(); |
| 252 } | 254 } |
| 253 | 255 |
| 254 } // namespace keyboard | 256 } // namespace keyboard |
| OLD | NEW |