| 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 "ui/aura/layout_manager.h" | 9 #include "ui/aura/layout_manager.h" |
| 9 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| 10 #include "ui/aura/window_delegate.h" | 11 #include "ui/aura/window_delegate.h" |
| 11 #include "ui/base/cursor/cursor.h" | 12 #include "ui/base/cursor/cursor.h" |
| 12 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
| 13 #include "ui/base/ime/input_method.h" | 14 #include "ui/base/ime/input_method.h" |
| 14 #include "ui/base/ime/text_input_client.h" | 15 #include "ui/base/ime/text_input_client.h" |
| 15 #include "ui/base/ime/text_input_type.h" | 16 #include "ui/base/ime/text_input_type.h" |
| 16 #include "ui/gfx/path.h" | 17 #include "ui/gfx/path.h" |
| 17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 18 #include "ui/gfx/skia_util.h" | 19 #include "ui/gfx/skia_util.h" |
| 19 #include "ui/keyboard/keyboard_controller_observer.h" | 20 #include "ui/keyboard/keyboard_controller_observer.h" |
| 20 #include "ui/keyboard/keyboard_controller_proxy.h" | 21 #include "ui/keyboard/keyboard_controller_proxy.h" |
| 22 #include "ui/keyboard/keyboard_switches.h" |
| 21 #include "ui/keyboard/keyboard_util.h" | 23 #include "ui/keyboard/keyboard_util.h" |
| 22 | 24 |
| 23 namespace { | 25 namespace { |
| 24 | 26 |
| 25 const int kHideKeyboardDelayMs = 100; | 27 const int kHideKeyboardDelayMs = 100; |
| 26 | 28 |
| 27 gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds) { | 29 gfx::Rect KeyboardBoundsFromWindowBounds(const gfx::Rect& window_bounds) { |
| 28 const float kKeyboardHeightRatio = 0.3f; | 30 const float kKeyboardHeightRatio = 0.3f; |
| 29 return gfx::Rect( | 31 return gfx::Rect( |
| 30 window_bounds.x(), | 32 window_bounds.x(), |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 183 |
| 182 void KeyboardController::OnTextInputStateChanged( | 184 void KeyboardController::OnTextInputStateChanged( |
| 183 const ui::TextInputClient* client) { | 185 const ui::TextInputClient* client) { |
| 184 if (!container_.get()) | 186 if (!container_.get()) |
| 185 return; | 187 return; |
| 186 | 188 |
| 187 bool was_showing = keyboard_visible_; | 189 bool was_showing = keyboard_visible_; |
| 188 bool should_show = was_showing; | 190 bool should_show = was_showing; |
| 189 ui::TextInputType type = | 191 ui::TextInputType type = |
| 190 client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; | 192 client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; |
| 191 if (type == ui::TEXT_INPUT_TYPE_NONE) { | 193 if (type == ui::TEXT_INPUT_TYPE_NONE && |
| 194 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 195 switches::kKeyboardUsabilityTest)) { |
| 192 should_show = false; | 196 should_show = false; |
| 193 } else { | 197 } else { |
| 194 if (container_->children().empty()) { | 198 if (container_->children().empty()) { |
| 195 aura::Window* keyboard = proxy_->GetKeyboardWindow(); | 199 aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
| 196 keyboard->Show(); | 200 keyboard->Show(); |
| 197 container_->AddChild(keyboard); | 201 container_->AddChild(keyboard); |
| 198 container_->layout_manager()->OnWindowResized(); | 202 container_->layout_manager()->OnWindowResized(); |
| 199 } | 203 } |
| 200 proxy_->SetUpdateInputType(type); | 204 proxy_->SetUpdateInputType(type); |
| 201 container_->parent()->StackChildAtTop(container_.get()); | 205 container_->parent()->StackChildAtTop(container_.get()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 const ui::InputMethod* input_method) { | 244 const ui::InputMethod* input_method) { |
| 241 DCHECK_EQ(input_method_, input_method); | 245 DCHECK_EQ(input_method_, input_method); |
| 242 input_method_ = NULL; | 246 input_method_ = NULL; |
| 243 } | 247 } |
| 244 | 248 |
| 245 bool KeyboardController::WillHideKeyboard() const { | 249 bool KeyboardController::WillHideKeyboard() const { |
| 246 return weak_factory_.HasWeakPtrs(); | 250 return weak_factory_.HasWeakPtrs(); |
| 247 } | 251 } |
| 248 | 252 |
| 249 } // namespace keyboard | 253 } // namespace keyboard |
| OLD | NEW |