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 3f520db8d6efc07e5558fa6a1d2e21adfa794c28..b0beaa2864e4021cd95ecbcb9c83b78a138ec17c 100644 |
--- a/content/browser/web_contents/web_contents_view_aura.cc |
+++ b/content/browser/web_contents/web_contents_view_aura.cc |
@@ -43,9 +43,7 @@ |
#include "ui/aura/client/window_tree_client.h" |
#include "ui/aura/env.h" |
#include "ui/aura/root_window.h" |
-#include "ui/aura/root_window_observer.h" |
#include "ui/aura/window.h" |
-#include "ui/aura/window_observer.h" |
#include "ui/base/clipboard/clipboard.h" |
#include "ui/base/clipboard/custom_data_helper.h" |
#include "ui/base/dragdrop/drag_drop_types.h" |
@@ -648,75 +646,6 @@ class OverscrollNavigationOverlay : |
DISALLOW_COPY_AND_ASSIGN(OverscrollNavigationOverlay); |
}; |
-class WebContentsViewAura::WindowObserver |
- : public aura::WindowObserver, public aura::RootWindowObserver { |
- public: |
- explicit WindowObserver(WebContentsViewAura* view) |
- : view_(view), |
- parent_(NULL) { |
- view_->window_->AddObserver(this); |
- } |
- |
- virtual ~WindowObserver() { |
- view_->window_->RemoveObserver(this); |
- if (view_->window_->GetDispatcher()) |
- view_->window_->GetDispatcher()->RemoveRootWindowObserver(this); |
- if (parent_) |
- parent_->RemoveObserver(this); |
- } |
- |
- // Overridden from aura::WindowObserver: |
- virtual void OnWindowParentChanged(aura::Window* window, |
- aura::Window* parent) OVERRIDE { |
- if (window == parent_) |
- return; |
- if (parent_) |
- parent_->RemoveObserver(this); |
- parent_ = parent; |
- if (parent) |
- parent->AddObserver(this); |
- } |
- |
- virtual void OnWindowBoundsChanged(aura::Window* window, |
- const gfx::Rect& old_bounds, |
- const gfx::Rect& new_bounds) OVERRIDE { |
- SendScreenRects(); |
- if (view_->touch_editable_) |
- view_->touch_editable_->UpdateEditingController(); |
- } |
- |
- virtual void OnWindowAddedToRootWindow(aura::Window* window) OVERRIDE { |
- if (window != parent_) |
- window->GetDispatcher()->AddRootWindowObserver(this); |
- } |
- |
- virtual void OnWindowRemovingFromRootWindow(aura::Window* window) OVERRIDE { |
- if (window != parent_) |
- window->GetDispatcher()->RemoveRootWindowObserver(this); |
- } |
- |
- // Overridden RootWindowObserver: |
- virtual void OnRootWindowHostMoved(const aura::RootWindow* root, |
- const gfx::Point& new_origin) OVERRIDE { |
- // This is for the desktop case (i.e. Aura desktop). |
- SendScreenRects(); |
- } |
- |
- private: |
- void SendScreenRects() { |
- RenderWidgetHostImpl::From(view_->web_contents_->GetRenderViewHost())-> |
- SendScreenRects(); |
- } |
- |
- WebContentsViewAura* view_; |
- |
- // We cache the old parent so that we can unregister when it's not the parent |
- // anymore. |
- aura::Window* parent_; |
- |
- DISALLOW_COPY_AND_ASSIGN(WindowObserver); |
-}; |
- |
#if defined(OS_WIN) |
// Constrained windows are added as children of the WebContent's view which may |
// overlap with windowed NPAPI plugins. In that case, tell the RWHV so that it |
@@ -831,7 +760,7 @@ WebContentsViewAura::~WebContentsViewAura() { |
if (!window_) |
return; |
- window_observer_.reset(); |
+ bounds_observer_.reset(); |
#if defined(OS_WIN) |
child_window_observer_.reset(); |
#endif |
@@ -1164,7 +1093,8 @@ void WebContentsViewAura::CreateView( |
window_->layer()->SetMasksToBounds(true); |
window_->SetName("WebContentsViewAura"); |
- window_observer_.reset(new WindowObserver(this)); |
+ bounds_observer_.reset(new NativeViewScreenBoundsObserver()); |
+ bounds_observer_->Init(this); |
#if defined(OS_WIN) |
child_window_observer_.reset(new ChildWindowObserver(this)); |
#endif |
@@ -1652,4 +1582,45 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
return current_drag_op_; |
} |
+//////////////////////////////////////////////////////////////////////////////// |
+// WebContentsViewAura, WebContentsViewAuraWindowObserverDelgate implementation: |
+ |
+aura::Window* WebContentsViewAura::GetDelegateWindow() { |
+ return window_.get(); |
+} |
+ |
+void WebContentsViewAura::AddDelegateWindowObserver( |
+ aura::WindowObserver* observer) { |
+ window_->AddObserver(observer); |
+} |
+ |
+void WebContentsViewAura::RemoveDelegateWindowObserver( |
+ aura::WindowObserver* observer) { |
+ window_->RemoveObserver(observer); |
+} |
+ |
+void WebContentsViewAura::RemoveRootWindowObserver( |
+ aura::RootWindowObserver* observer) { |
+ if (window_->GetDispatcher()) |
+ window_->GetDispatcher()->RemoveRootWindowObserver(observer); |
+} |
+ |
+void WebContentsViewAura::AddRootWindowObserver( |
+ aura::RootWindowObserver* observer) { |
+ if (window_->GetDispatcher()) |
+ window_->GetDispatcher()->AddRootWindowObserver(observer); |
+} |
+ |
+void WebContentsViewAura::OnScreenPositionChanged() { |
+ RenderWidgetHostImpl::From(web_contents_->GetRenderViewHost())-> |
+ SendScreenRects(); |
+} |
+ |
+void WebContentsViewAura::OnScreenBoundsChanged() { |
+ RenderWidgetHostImpl::From(web_contents_->GetRenderViewHost())-> |
+ SendScreenRects(); |
+ if (touch_editable_) |
+ touch_editable_->UpdateEditingController(); |
+} |
+ |
} // namespace content |