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

Unified Diff: ui/aura/window.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 side-by-side diff with in-line comments
Download patch
Index: ui/aura/window.cc
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index ab1a2da85fca8ff6911f10333006355627a5c03e..a7e40ca13845e0b59b738865391b22ba3f697c32 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -952,9 +952,15 @@ void Window::SetVisible(bool visible) {
if (delegate_)
delegate_->OnWindowTargetVisibilityChanged(visible);
- NotifyWindowVisibilityChanged(this, visible);
+ NotifyWindowVisibilityChanged(this, visible, false);
}
+#if defined(OS_LINUX)
+void Window::SetPageVisibility(bool visible) {
+ NotifyWindowVisibilityChanged(this, visible, true);
+}
+#endif
+
void Window::SchedulePaint() {
SchedulePaintInRect(gfx::Rect(0, 0, bounds().width(), bounds().height()));
}
@@ -1282,28 +1288,32 @@ void Window::NotifyWindowHierarchyChangeAtReceiver(
}
void Window::NotifyWindowVisibilityChanged(aura::Window* target,
- bool visible) {
- if (!NotifyWindowVisibilityChangedDown(target, visible)) {
+ bool visible, bool content_visible) {
+ if (!NotifyWindowVisibilityChangedDown(target, visible, content_visible)) {
return; // |this| has been deleted.
}
NotifyWindowVisibilityChangedUp(target, visible);
}
bool Window::NotifyWindowVisibilityChangedAtReceiver(aura::Window* target,
- bool visible) {
+ bool visible,
+ bool content_visible) {
// |this| may be deleted during a call to OnWindowVisibilityChanged() on one
// of the observers. We create an local observer for that. In that case we
// exit without further access to any members.
WindowTracker tracker;
tracker.Add(this);
FOR_EACH_OBSERVER(WindowObserver, observers_,
- OnWindowVisibilityChanged(target, visible));
+ OnWindowVisibilityChanged(target, visible,
+ content_visible));
return tracker.Contains(this);
}
bool Window::NotifyWindowVisibilityChangedDown(aura::Window* target,
- bool visible) {
- if (!NotifyWindowVisibilityChangedAtReceiver(target, visible))
+ bool visible,
+ bool content_visible) {
+ if (!NotifyWindowVisibilityChangedAtReceiver(target, visible,
+ content_visible))
return false; // |this| was deleted.
std::set<const Window*> child_already_processed;
bool child_destroyed = false;
@@ -1313,7 +1323,8 @@ bool Window::NotifyWindowVisibilityChangedDown(aura::Window* target,
it != children_.end(); ++it) {
if (!child_already_processed.insert(*it).second)
continue;
- if (!(*it)->NotifyWindowVisibilityChangedDown(target, visible)) {
+ if (!(*it)->NotifyWindowVisibilityChangedDown(target, visible,
+ content_visible)) {
// |*it| was deleted, |it| is invalid and |children_| has changed.
// We exit the current for-loop and enter a new one.
child_destroyed = true;
@@ -1329,7 +1340,8 @@ void Window::NotifyWindowVisibilityChangedUp(aura::Window* target,
// Start with the parent as we already notified |this|
// in NotifyWindowVisibilityChangedDown.
for (Window* window = parent(); window; window = window->parent()) {
- bool ret = window->NotifyWindowVisibilityChangedAtReceiver(target, visible);
+ bool ret = window->NotifyWindowVisibilityChangedAtReceiver(target, visible,
+ false);
DCHECK(ret);
}
}

Powered by Google App Engine
This is Rietveld 408576698