Chromium Code Reviews| 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..adc9958917017db2b45ef7b7a107dcae95c33b51 100644 |
| --- a/content/browser/web_contents/web_contents_view_aura.cc |
| +++ b/content/browser/web_contents/web_contents_view_aura.cc |
| @@ -98,6 +98,18 @@ bool ShouldNavigateBack(const NavigationController& controller, |
| controller.CanGoBack(); |
| } |
| +// Update the |web contents| to be |visible|. |
| +void UpdateWebContentsVisibility(WebContentsImpl* web_contents, |
| + bool visibile) { |
| + if (visibile) { |
|
ncarter (slow)
2014/05/21 21:11:03
visibile -> visible (extra i)
Mr4D (OOO till 08-26)
2014/05/21 21:25:25
Done.
|
| + 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 +730,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 +1058,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 +1441,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 +1563,18 @@ int WebContentsViewAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| return ConvertFromWeb(current_drag_op_); |
| } |
| +void WebContentsViewAura::OnWindowParentChanged(aura::Window* window, |
| + aura::Window* parent) { |
| + UpdateWebContentsVisibility(web_contents_, !parent || parent->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 |