Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 944763002: Make Page Visibility API work when the browser window is visible or not Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 event.location(), 1613 event.location(),
1614 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), 1614 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
1615 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 1615 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
1616 if (drag_dest_delegate_) 1616 if (drag_dest_delegate_)
1617 drag_dest_delegate_->OnDrop(); 1617 drag_dest_delegate_->OnDrop();
1618 current_drop_data_.reset(); 1618 current_drop_data_.reset();
1619 return ConvertFromWeb(current_drag_op_); 1619 return ConvertFromWeb(current_drag_op_);
1620 } 1620 }
1621 1621
1622 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, 1622 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window,
1623 bool visible) { 1623 bool visible,
1624 bool content_visible) {
1624 // Ignore any visibility changes in the hierarchy below. 1625 // Ignore any visibility changes in the hierarchy below.
1625 if (window != window_.get() && window_->Contains(window)) 1626 if (window != window_.get() && window_->Contains(window))
1626 return; 1627 return;
1627 1628
1628 UpdateWebContentsVisibility(visible); 1629 UpdateWebContentsVisibility(visible, content_visible);
1629 } 1630 }
1630 1631
1631 void WebContentsViewAura::UpdateWebContentsVisibility(bool visible) { 1632 void WebContentsViewAura::UpdateWebContentsVisibility(bool visible,
1633 bool content_visible) {
1632 if (!is_or_was_visible_) { 1634 if (!is_or_was_visible_) {
1633 // We should not hide the web contents before it was shown the first time, 1635 // We should not hide the web contents before it was shown the first time,
1634 // since resources would immediately be destroyed and only re-created after 1636 // since resources would immediately be destroyed and only re-created after
1635 // content got loaded. In this state the window content is undefined and can 1637 // content got loaded. In this state the window content is undefined and can
1636 // show garbage. 1638 // show garbage.
1637 // However - the page load mechanism requires an activation call through a 1639 // However - the page load mechanism requires an activation call through a
1638 // visibility call to (re)load. 1640 // visibility call to (re)load.
1639 if (visible) { 1641 if (visible) {
1640 is_or_was_visible_ = true; 1642 is_or_was_visible_ = true;
1641 web_contents_->WasShown(); 1643 web_contents_->WasShown();
1642 } 1644 }
1643 return; 1645 return;
1644 } 1646 }
1645 if (visible) { 1647 if (visible) {
1646 if (!web_contents_->should_normally_be_visible()) 1648 if (!web_contents_->should_normally_be_visible())
1647 web_contents_->WasShown(); 1649 web_contents_->WasShown();
1648 } else { 1650 } else {
1649 if (web_contents_->should_normally_be_visible()) 1651 if (web_contents_->should_normally_be_visible())
1650 web_contents_->WasHidden(); 1652 web_contents_->WasHidden(content_visible);
1651 } 1653 }
1652 } 1654 }
1653 1655
1654 } // namespace content 1656 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698