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 f134da3b24a005846f9d5709db22112628a86698..351b4297dd835efee579950fffc2fe110f3c6242 100644 |
--- a/content/browser/web_contents/web_contents_view_aura.cc |
+++ b/content/browser/web_contents/web_contents_view_aura.cc |
@@ -721,6 +721,7 @@ WebContentsViewAura::~WebContentsViewAura() { |
// Window needs a valid delegate during its destructor, so we explicitly |
// delete it here. |
+ window_->RemoveObserver(this); |
window_.reset(); |
} |
@@ -1045,6 +1046,7 @@ void WebContentsViewAura::CreateView( |
window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); |
window_->SetTransparent(false); |
window_->Init(aura::WINDOW_LAYER_NOT_DRAWN); |
+ window_->AddObserver(this); |
aura::Window* root_window = context ? context->GetRootWindow() : NULL; |
if (root_window) { |
// There are places where there is no context currently because object |
@@ -1555,4 +1557,26 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
return ConvertFromWeb(current_drag_op_); |
} |
+void WebContentsViewAura::OnWindowParentChanged(aura::Window* window, |
+ aura::Window* parent) { |
+ if (!parent || parent->IsVisible()) |
sky
2014/05/16 20:14:58
I don't get why you're tracking visibility of the
|
+ web_contents_->WasShown(); |
+ else |
+ web_contents_->WasHidden(); |
+} |
+ |
+void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
+ bool visible) { |
+ aura::Window* parent = window_->parent(); |
+ if (!parent) |
+ return; |
+ |
+ // Follow the visibility of the parent window since e.g. navigation |
+ // operations could otherwise cause a flash. |
+ if (parent->IsVisible()) |
+ web_contents_->WasShown(); |
+ else |
+ web_contents_->WasHidden(); |
+} |
+ |
} // namespace content |