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 2b29df7cb821681df6c78a4951c2c92373e90803..ab1bfab65862550669eaf96d56fe0d0f1c169ebc 100644 |
--- a/content/browser/web_contents/web_contents_view_aura.cc |
+++ b/content/browser/web_contents/web_contents_view_aura.cc |
@@ -98,6 +98,17 @@ bool ShouldNavigateBack(const NavigationController& controller, |
controller.CanGoBack(); |
} |
+// Update the |web contents| to be |visible|. |
+void UpdateWebContentsVisibility(WebContentsImpl* web_contents, bool visible) { |
+ if (visible) { |
+ if (!web_contents->should_normally_be_visible()) |
+ web_contents->WasShown(); |
+ } else { |
+ if (web_contents->should_normally_be_visible()) |
+ web_contents->WasHidden(); |
+ } |
+} |
+ |
RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( |
RenderWidgetHostView* view) { |
if (!view || RenderViewHostFactory::has_factory()) |
@@ -718,6 +729,7 @@ WebContentsViewAura::~WebContentsViewAura() { |
return; |
window_observer_.reset(); |
+ window_->RemoveObserver(this); |
// Window needs a valid delegate during its destructor, so we explicitly |
// delete it here. |
@@ -1045,6 +1057,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 |
@@ -1427,10 +1440,6 @@ void WebContentsViewAura::OnWindowDestroyed(aura::Window* window) { |
} |
void WebContentsViewAura::OnWindowTargetVisibilityChanged(bool visible) { |
- if (visible) |
- web_contents_->WasShown(); |
- else |
- web_contents_->WasHidden(); |
} |
bool WebContentsViewAura::HasHitTestMask() const { |
@@ -1553,4 +1562,22 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
return ConvertFromWeb(current_drag_op_); |
} |
+void WebContentsViewAura::OnWindowParentChanged(aura::Window* window, |
+ aura::Window* parent) { |
+ // On Windows we will get called with a parent of NULL as part of the shut |
+ // down process. As such we do only change the visibility when a parent gets |
+ // set. |
+ if (parent) |
+ UpdateWebContentsVisibility(web_contents_, window->IsVisible()); |
+} |
+ |
+void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
+ bool visible) { |
+ // Ignore any visibility changes in the hierarchy below. |
+ if (window != window_.get() && window_->Contains(window)) |
+ return; |
+ |
+ UpdateWebContentsVisibility(web_contents_, visible); |
+} |
+ |
} // namespace content |