Index: ui/keyboard/keyboard_controller.cc |
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc |
index f74ff7a612e1b63b927472462f1de31f6665b55f..77f3e0617994d1935f2e8fda6d4035dbc0721036 100644 |
--- a/ui/keyboard/keyboard_controller.cc |
+++ b/ui/keyboard/keyboard_controller.cc |
@@ -206,6 +206,7 @@ class WindowBoundsChangeObserver : public aura::WindowObserver { |
virtual void OnWindowBoundsChanged(aura::Window* window, |
const gfx::Rect& old_bounds, |
const gfx::Rect& new_bounds) OVERRIDE; |
+ virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
}; |
void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window, |
@@ -215,6 +216,11 @@ void WindowBoundsChangeObserver::OnWindowBoundsChanged(aura::Window* window, |
controller->UpdateWindowInsets(window); |
} |
+void WindowBoundsChangeObserver::OnWindowDestroyed(aura::Window* window) { |
+ if (window->HasObserver(this)) |
+ window->RemoveObserver(this); |
+} |
+ |
// static |
KeyboardController* KeyboardController::instance_ = NULL; |
@@ -288,7 +294,11 @@ void KeyboardController::NotifyKeyboardBoundsChanging( |
// the render process crashed. |
if (view) { |
aura::Window *window = view->GetNativeView(); |
+ // If virtual keyboard failed to load, a widget that displays error |
+ // message will be created and adds as a child of the virtual keyboard |
+ // window. We want to avoid add BoundsChangedObserver to that window. |
if (window != keyboard_window && |
+ GetFrameWindow(window) != keyboard_window && |
kevers
2014/08/20 15:16:04
Think you only need second check.
bshe
2014/08/20 15:29:23
Done.
|
window->GetRootWindow() == root_window) { |
gfx::Rect window_bounds = window->GetBoundsInScreen(); |
gfx::Rect intersect = gfx::IntersectRects(window_bounds, |
@@ -358,8 +368,12 @@ void KeyboardController::OnWindowHierarchyChanged( |
} |
void KeyboardController::Reload() { |
- if (proxy_->HasKeyboardWindow()) |
+ if (proxy_->HasKeyboardWindow()) { |
+ // A reload should never try to show virtual keyboard. If keyboard is not |
+ // visible before reload, it should keep invisible after reload. |
+ show_on_resize_ = false; |
proxy_->ReloadKeyboardIfNeeded(); |
+ } |
} |
void KeyboardController::OnTextInputStateChanged( |
@@ -451,8 +465,12 @@ void KeyboardController::ShowKeyboardInternal() { |
proxy_->ReloadKeyboardIfNeeded(); |
- if (keyboard_visible_ || proxy_->GetKeyboardWindow()->bounds().height() == 0) |
+ if (keyboard_visible_) { |
return; |
+ } else if (proxy_->GetKeyboardWindow()->bounds().height() == 0) { |
+ show_on_resize_ = true; |
+ return; |
+ } |
keyboard_visible_ = true; |