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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) | 238 KeyboardController::KeyboardController(KeyboardControllerProxy* proxy) |
239 : proxy_(proxy), | 239 : proxy_(proxy), |
240 input_method_(NULL), | 240 input_method_(NULL), |
241 keyboard_visible_(false), | 241 keyboard_visible_(false), |
242 show_on_resize_(false), | 242 show_on_resize_(false), |
243 lock_keyboard_(false), | 243 lock_keyboard_(false), |
244 type_(ui::TEXT_INPUT_TYPE_NONE), | 244 type_(ui::TEXT_INPUT_TYPE_NONE), |
245 weak_factory_(this) { | 245 weak_factory_(this) { |
246 CHECK(proxy); | 246 CHECK(proxy); |
247 input_method_ = proxy_->GetInputMethod(); | 247 input_method_ = proxy_->GetInputMethod(); |
| 248 input_method_->SetSupportsOnScreenKeyboard(true); |
248 input_method_->AddObserver(this); | 249 input_method_->AddObserver(this); |
249 window_bounds_observer_.reset(new WindowBoundsChangeObserver()); | 250 window_bounds_observer_.reset(new WindowBoundsChangeObserver()); |
250 } | 251 } |
251 | 252 |
252 KeyboardController::~KeyboardController() { | 253 KeyboardController::~KeyboardController() { |
253 if (container_) | 254 if (container_) |
254 container_->RemoveObserver(this); | 255 container_->RemoveObserver(this); |
255 if (input_method_) | 256 if (input_method_) |
256 input_method_->RemoveObserver(this); | 257 input_method_->RemoveObserver(this); |
257 ResetWindowInsets(); | 258 ResetWindowInsets(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 void KeyboardController::OnInputMethodDestroyed( | 426 void KeyboardController::OnInputMethodDestroyed( |
426 const ui::InputMethod* input_method) { | 427 const ui::InputMethod* input_method) { |
427 DCHECK_EQ(input_method_, input_method); | 428 DCHECK_EQ(input_method_, input_method); |
428 input_method_ = NULL; | 429 input_method_ = NULL; |
429 } | 430 } |
430 | 431 |
431 void KeyboardController::OnShowImeIfNeeded() { | 432 void KeyboardController::OnShowImeIfNeeded() { |
432 ShowKeyboardInternal(); | 433 ShowKeyboardInternal(); |
433 } | 434 } |
434 | 435 |
| 436 void KeyboardController::OnKeyboardBoundsUnchanged() {} |
| 437 |
435 bool KeyboardController::ShouldEnableInsets(aura::Window* window) { | 438 bool KeyboardController::ShouldEnableInsets(aura::Window* window) { |
436 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); | 439 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); |
437 return (keyboard_window->GetRootWindow() == window->GetRootWindow() && | 440 return (keyboard_window->GetRootWindow() == window->GetRootWindow() && |
438 keyboard::IsKeyboardOverscrollEnabled() && | 441 keyboard::IsKeyboardOverscrollEnabled() && |
439 proxy_->GetKeyboardWindow()->IsVisible() && | 442 proxy_->GetKeyboardWindow()->IsVisible() && |
440 keyboard_visible_); | 443 keyboard_visible_); |
441 } | 444 } |
442 | 445 |
443 void KeyboardController::UpdateWindowInsets(aura::Window* window) { | 446 void KeyboardController::UpdateWindowInsets(aura::Window* window) { |
444 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); | 447 aura::Window *keyboard_window = proxy_->GetKeyboardWindow(); |
(...skipping 26 matching lines...) Expand all Loading... |
471 keyboard::MarkKeyboardLoadStarted(); | 474 keyboard::MarkKeyboardLoadStarted(); |
472 aura::Window* keyboard = proxy_->GetKeyboardWindow(); | 475 aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
473 keyboard->Show(); | 476 keyboard->Show(); |
474 container_->AddChild(keyboard); | 477 container_->AddChild(keyboard); |
475 keyboard->set_owned_by_parent(false); | 478 keyboard->set_owned_by_parent(false); |
476 } | 479 } |
477 | 480 |
478 proxy_->ReloadKeyboardIfNeeded(); | 481 proxy_->ReloadKeyboardIfNeeded(); |
479 | 482 |
480 if (keyboard_visible_) { | 483 if (keyboard_visible_) { |
| 484 proxy_->GetInputMethod()->OnKeyboardBoundsUnchanged(); |
481 return; | 485 return; |
482 } else if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { | 486 } else if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { |
483 show_on_resize_ = true; | 487 show_on_resize_ = true; |
484 return; | 488 return; |
485 } | 489 } |
486 | 490 |
487 keyboard_visible_ = true; | 491 keyboard_visible_ = true; |
488 | 492 |
489 // If the controller is in the process of hiding the keyboard, do not log | 493 // If the controller is in the process of hiding the keyboard, do not log |
490 // the stat here since the keyboard will not actually be shown. | 494 // the stat here since the keyboard will not actually be shown. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 proxy_->HideKeyboardContainer(container_.get()); | 568 proxy_->HideKeyboardContainer(container_.get()); |
565 } | 569 } |
566 | 570 |
567 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { | 571 void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
568 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; | 572 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; |
569 if (target_window) | 573 if (target_window) |
570 window_bounds_observer_->AddObservedWindow(target_window); | 574 window_bounds_observer_->AddObservedWindow(target_window); |
571 } | 575 } |
572 | 576 |
573 } // namespace keyboard | 577 } // namespace keyboard |
OLD | NEW |