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

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: remove the VisibilityNotify event handler 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 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 event.location(), 1603 event.location(),
1604 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), 1604 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
1605 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 1605 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
1606 if (drag_dest_delegate_) 1606 if (drag_dest_delegate_)
1607 drag_dest_delegate_->OnDrop(); 1607 drag_dest_delegate_->OnDrop();
1608 current_drop_data_.reset(); 1608 current_drop_data_.reset();
1609 return ConvertFromWeb(current_drag_op_); 1609 return ConvertFromWeb(current_drag_op_);
1610 } 1610 }
1611 1611
1612 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, 1612 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window,
1613 bool visible) { 1613 bool visible,
1614 bool content_visible) {
1614 // Ignore any visibility changes in the hierarchy below. 1615 // Ignore any visibility changes in the hierarchy below.
1615 if (window != window_.get() && window_->Contains(window)) 1616 if (window != window_.get() && window_->Contains(window))
1616 return; 1617 return;
1617 1618
1618 UpdateWebContentsVisibility(visible); 1619 UpdateWebContentsVisibility(visible, content_visible);
1619 } 1620 }
1620 1621
1621 void WebContentsViewAura::UpdateWebContentsVisibility(bool visible) { 1622 void WebContentsViewAura::UpdateWebContentsVisibility(bool visible,
1623 bool content_visible) {
1622 if (!is_or_was_visible_) { 1624 if (!is_or_was_visible_) {
1623 // We should not hide the web contents before it was shown the first time, 1625 // We should not hide the web contents before it was shown the first time,
1624 // since resources would immediately be destroyed and only re-created after 1626 // since resources would immediately be destroyed and only re-created after
1625 // content got loaded. In this state the window content is undefined and can 1627 // content got loaded. In this state the window content is undefined and can
1626 // show garbage. 1628 // show garbage.
1627 // However - the page load mechanism requires an activation call through a 1629 // However - the page load mechanism requires an activation call through a
1628 // visibility call to (re)load. 1630 // visibility call to (re)load.
1629 if (visible) { 1631 if (visible) {
1630 is_or_was_visible_ = true; 1632 is_or_was_visible_ = true;
1631 web_contents_->WasShown(); 1633 web_contents_->WasShown();
1632 } 1634 }
1633 return; 1635 return;
1634 } 1636 }
1635 if (visible) { 1637 if (visible) {
1636 if (!web_contents_->should_normally_be_visible()) 1638 if (!web_contents_->should_normally_be_visible())
1637 web_contents_->WasShown(); 1639 web_contents_->WasShown();
1638 } else { 1640 } else {
1639 if (web_contents_->should_normally_be_visible()) 1641 if (web_contents_->should_normally_be_visible())
1640 web_contents_->WasHidden(); 1642 web_contents_->WasHidden(content_visible);
1641 } 1643 }
1642 } 1644 }
1643 1645
1644 } // namespace content 1646 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698