| Index: content/browser/web_contents/web_contents_view_aura.cc
|
| diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
|
| index bc7ee3ada1c36fdf0dde2e5d033d022ab7f566f8..e54e082b5e19530578dba17834560846254ee7d8 100644
|
| --- a/content/browser/web_contents/web_contents_view_aura.cc
|
| +++ b/content/browser/web_contents/web_contents_view_aura.cc
|
| @@ -653,7 +653,7 @@ class WebContentsViewAura::WindowObserver
|
| public:
|
| explicit WindowObserver(WebContentsViewAura* view)
|
| : view_(view),
|
| - parent_(NULL) {
|
| + top_level_(NULL) {
|
| view_->window_->AddObserver(this);
|
| }
|
|
|
| @@ -661,20 +661,25 @@ class WebContentsViewAura::WindowObserver
|
| view_->window_->RemoveObserver(this);
|
| if (view_->window_->GetDispatcher())
|
| view_->window_->GetDispatcher()->RemoveRootWindowObserver(this);
|
| - if (parent_)
|
| - parent_->RemoveObserver(this);
|
| + if (top_level_)
|
| + top_level_->RemoveObserver(this);
|
| }
|
|
|
| // Overridden from aura::WindowObserver:
|
| virtual void OnWindowParentChanged(aura::Window* window,
|
| aura::Window* parent) OVERRIDE {
|
| - if (window == parent_)
|
| + if (window == top_level_)
|
| return;
|
| - if (parent_)
|
| - parent_->RemoveObserver(this);
|
| - parent_ = parent;
|
| - if (parent)
|
| - parent->AddObserver(this);
|
| +
|
| + if (top_level_) {
|
| + top_level_->RemoveObserver(this);
|
| + top_level_ = NULL;
|
| + }
|
| +
|
| + if (window && window != window->GetToplevelWindow())
|
| + top_level_ = window->GetToplevelWindow();
|
| + if (top_level_)
|
| + top_level_->AddObserver(this);
|
| }
|
|
|
| virtual void OnWindowBoundsChanged(aura::Window* window,
|
| @@ -686,12 +691,12 @@ class WebContentsViewAura::WindowObserver
|
| }
|
|
|
| virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE {
|
| - if (window != parent_)
|
| + if (window != top_level_)
|
| window->GetDispatcher()->AddRootWindowObserver(this);
|
| }
|
|
|
| virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE {
|
| - if (window != parent_)
|
| + if (window != top_level_)
|
| window->GetDispatcher()->RemoveRootWindowObserver(this);
|
| }
|
|
|
| @@ -710,9 +715,9 @@ class WebContentsViewAura::WindowObserver
|
|
|
| WebContentsViewAura* view_;
|
|
|
| - // We cache the old parent so that we can unregister when it's not the parent
|
| - // anymore.
|
| - aura::Window* parent_;
|
| + // We cache the old value so that we can unregister the observer when it
|
| + // changes. This also allows for filtering the events seen by the observer.
|
| + aura::Window* top_level_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(WindowObserver);
|
| };
|
|
|