| Index: ui/keyboard/keyboard_controller.cc
|
| diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc
|
| index 313bc04f0cd77a1df96babfe2e17b852f3f513d2..ff4d7ea197c8cce48c322c8637bfe48eabee2335 100644
|
| --- a/ui/keyboard/keyboard_controller.cc
|
| +++ b/ui/keyboard/keyboard_controller.cc
|
| @@ -184,43 +184,10 @@ void KeyboardController::OnTextInputStateChanged(
|
| if (!container_.get())
|
| return;
|
|
|
| - bool was_showing = keyboard_visible_;
|
| - bool should_show = was_showing;
|
| ui::TextInputType type =
|
| client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE;
|
| if (type == ui::TEXT_INPUT_TYPE_NONE) {
|
| - should_show = false;
|
| - } else {
|
| - if (container_->children().empty()) {
|
| - aura::Window* keyboard = proxy_->GetKeyboardWindow();
|
| - keyboard->Show();
|
| - container_->AddChild(keyboard);
|
| - container_->layout_manager()->OnWindowResized();
|
| - }
|
| - proxy_->SetUpdateInputType(type);
|
| - container_->parent()->StackChildAtTop(container_.get());
|
| - should_show = true;
|
| - }
|
| -
|
| - if (was_showing != should_show) {
|
| - if (should_show) {
|
| - keyboard_visible_ = true;
|
| -
|
| - // If the controller is in the process of hiding the keyboard, do not log
|
| - // the stat here since the keyboard will not actually be shown.
|
| - if (!WillHideKeyboard())
|
| - keyboard::LogKeyboardControlEvent(keyboard::KEYBOARD_CONTROL_SHOW);
|
| -
|
| - weak_factory_.InvalidateWeakPtrs();
|
| - if (container_->IsVisible())
|
| - return;
|
| -
|
| - FOR_EACH_OBSERVER(
|
| - KeyboardControllerObserver,
|
| - observer_list_,
|
| - OnKeyboardBoundsChanging(container_->children()[0]->bounds()));
|
| - proxy_->ShowKeyboardContainer(container_.get());
|
| - } else {
|
| + if (keyboard_visible_) {
|
| // Set the visibility state here so that any queries for visibility
|
| // before the timer fires returns the correct future value.
|
| keyboard_visible_ = false;
|
| @@ -230,6 +197,13 @@ void KeyboardController::OnTextInputStateChanged(
|
| weak_factory_.GetWeakPtr(), HIDE_REASON_AUTOMATIC),
|
| base::TimeDelta::FromMilliseconds(kHideKeyboardDelayMs));
|
| }
|
| + } else {
|
| + // Abort a pending keyboard hide.
|
| + if (WillHideKeyboard()) {
|
| + weak_factory_.InvalidateWeakPtrs();
|
| + keyboard_visible_ = true;
|
| + }
|
| + proxy_->SetUpdateInputType(type);
|
| }
|
| // TODO(bryeung): whenever the TextInputClient changes we need to notify the
|
| // keyboard (with the TextInputType) so that it can reset it's state (e.g.
|
| @@ -242,6 +216,33 @@ void KeyboardController::OnInputMethodDestroyed(
|
| input_method_ = NULL;
|
| }
|
|
|
| +void KeyboardController::OnShowVirtualKeyboard() {
|
| + if (container_->children().empty()) {
|
| + aura::Window* keyboard = proxy_->GetKeyboardWindow();
|
| + keyboard->Show();
|
| + container_->AddChild(keyboard);
|
| + container_->layout_manager()->OnWindowResized();
|
| + }
|
| + if (keyboard_visible_)
|
| + return;
|
| +
|
| + // If the controller is in the process of hiding the keyboard, do not log
|
| + // the stat here since the keyboard will not actually be shown.
|
| + if (!WillHideKeyboard())
|
| + keyboard::LogKeyboardControlEvent(keyboard::KEYBOARD_CONTROL_SHOW);
|
| +
|
| + weak_factory_.InvalidateWeakPtrs();
|
| + if (container_->IsVisible())
|
| + return;
|
| +
|
| + FOR_EACH_OBSERVER(
|
| + KeyboardControllerObserver,
|
| + observer_list_,
|
| + OnKeyboardBoundsChanging(container_->children()[0]->bounds()));
|
| + proxy_->ShowKeyboardContainer(container_.get());
|
| + keyboard_visible_ = true;
|
| +}
|
| +
|
| bool KeyboardController::WillHideKeyboard() const {
|
| return weak_factory_.HasWeakPtrs();
|
| }
|
|
|