Index: ui/keyboard/keyboard_controller.cc |
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc |
index ca8e54fcc4af7d903c842c95e7e273516de48d62..4bb458da7a72b30f128ad2299f2b0c67c1ab88d7 100644 |
--- a/ui/keyboard/keyboard_controller.cc |
+++ b/ui/keyboard/keyboard_controller.cc |
@@ -220,44 +220,15 @@ 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 && |
- !IsKeyboardUsabilityExperimentEnabled() && |
- !lock_keyboard_) { |
- should_show = false; |
- } else { |
- if (container_->children().empty()) { |
- keyboard::MarkKeyboardLoadStarted(); |
- aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
- keyboard->Show(); |
- container_->AddChild(keyboard); |
- } |
- if (type != ui::TEXT_INPUT_TYPE_NONE) |
- proxy_->SetUpdateInputType(type); |
- container_->parent()->StackChildAtTop(container_.get()); |
- should_show = true; |
+ if (IsKeyboardUsabilityExperimentEnabled()) { |
+ OnShowImeIfNeeded(); |
+ return; |
} |
- 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; |
- |
- NotifyKeyboardBoundsChanging(container_->children()[0]->bounds()); |
- |
- proxy_->ShowKeyboardContainer(container_.get()); |
- } else { |
+ ui::TextInputType type = |
+ client ? client->GetTextInputType() : ui::TEXT_INPUT_TYPE_NONE; |
+ if (type == ui::TEXT_INPUT_TYPE_NONE && !lock_keyboard_) { |
+ if (keyboard_visible_ /* && !IsKeyboardUsabilityExperimentEnabled() */) { |
sadrul
2014/01/10 19:53:21
Remove the /* comment
kevers
2014/01/13 16:59:10
Done.
|
// Set the visibility state here so that any queries for visibility |
// before the timer fires returns the correct future value. |
keyboard_visible_ = false; |
@@ -267,6 +238,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); |
sadrul
2014/01/10 19:53:21
Don't you need to show the keyboard window here?
kevers
2014/01/13 16:59:10
Added a comment to clarify. We only wish to show t
|
} |
// 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. |
@@ -279,6 +257,34 @@ void KeyboardController::OnInputMethodDestroyed( |
input_method_ = NULL; |
} |
+void KeyboardController::OnShowImeIfNeeded() { |
+ if (!container_.get()) |
+ return; |
+ |
+ if (container_->children().empty()) { |
+ aura::Window* keyboard = proxy_->GetKeyboardWindow(); |
+ keyboard->Show(); |
+ container_->AddChild(keyboard); |
+ } |
+ if (keyboard_visible_) |
+ return; |
+ |
+ 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; |
+ |
+ NotifyKeyboardBoundsChanging(container_->children()[0]->bounds()); |
+ |
+ proxy_->ShowKeyboardContainer(container_.get()); |
+} |
+ |
bool KeyboardController::WillHideKeyboard() const { |
return weak_factory_.HasWeakPtrs(); |
} |