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 f134da3b24a005846f9d5709db22112628a86698..a7d5116d0a4eb7e0cd776456eaeb3c61544f4c76 100644 |
| --- a/content/browser/web_contents/web_contents_view_aura.cc |
| +++ b/content/browser/web_contents/web_contents_view_aura.cc |
| @@ -98,6 +98,28 @@ bool ShouldNavigateBack(const NavigationController& controller, |
| controller.CanGoBack(); |
| } |
| +// Check if a given |child_window| is below a given |window| in the hierarchy. |
| +bool IsInHierarchyBelow(aura::Window* child_window, aura::Window* window) { |
| + aura::Window* childs_parent = child_window->parent(); |
| + if (!childs_parent) |
| + return false; |
| + if (childs_parent == window) |
| + return true; |
| + return IsInHierarchyBelow(childs_parent, window); |
| +} |
| + |
| +// Update the |visibility| of the |web contents|. |
| +void UpdateWebContentsVisibility(WebContentsImpl* web_contents, |
| + bool visibility) { |
| + if (visibility) { |
| + 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()) |
| @@ -721,6 +743,7 @@ WebContentsViewAura::~WebContentsViewAura() { |
| // Window needs a valid delegate during its destructor, so we explicitly |
| // delete it here. |
| + window_->RemoveObserver(this); |
| window_.reset(); |
| } |
| @@ -1045,6 +1068,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 |
| @@ -1429,10 +1453,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 { |
| @@ -1555,4 +1575,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 (IsInHierarchyBelow(window, window_.get())) |
|
sky
2014/05/20 19:46:27
Isn't this the same as window_->Contains(window) &
Mr4D (OOO till 08-26)
2014/05/20 21:26:56
Done.
|
| + return; |
| + |
| + UpdateWebContentsVisibility(web_contents_, visible); |
| +} |
| + |
| } // namespace content |