Index: ui/keyboard/keyboard_controller.cc |
diff --git a/ui/keyboard/keyboard_controller.cc b/ui/keyboard/keyboard_controller.cc |
index f74ff7a612e1b63b927472462f1de31f6665b55f..745917c0cb4dc6618822d7396615e21de37f72f5 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,8 +294,7 @@ void KeyboardController::NotifyKeyboardBoundsChanging( |
// the render process crashed. |
if (view) { |
aura::Window *window = view->GetNativeView(); |
- if (window != keyboard_window && |
- window->GetRootWindow() == root_window) { |
+ if (window->GetRootWindow() == root_window) { |
kevers
2014/08/20 14:02:29
Not clear to me why we need a bounds changed obser
bshe
2014/08/20 14:59:59
Sorry. It shouldn't be removed. I thought I could
|
gfx::Rect window_bounds = window->GetBoundsInScreen(); |
gfx::Rect intersect = gfx::IntersectRects(window_bounds, |
new_bounds); |
@@ -358,8 +363,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. |
+ wait_for_resize_to_show_ = false; |
proxy_->ReloadKeyboardIfNeeded(); |
+ } |
} |
void KeyboardController::OnTextInputStateChanged( |
@@ -451,8 +460,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) { |
+ wait_for_resize_to_show_ = true; |
+ return; |
+ } |
keyboard_visible_ = true; |
@@ -538,7 +551,7 @@ void KeyboardController::HideAnimationFinished() { |
void KeyboardController::AddBoundsChangedObserver(aura::Window* window) { |
aura::Window* target_window = GetFrameWindow(window); |
- if (target_window && |
+ if (target_window && target_window != proxy_->GetKeyboardWindow() && |
!target_window->HasObserver(window_bounds_observer_.get())) { |
target_window->AddObserver(window_bounds_observer_.get()); |
} |