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

Side by Side Diff: content/browser/web_contents/web_contents_impl.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, 9 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_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 // Restore power save blocker if there are active video players running. 1080 // Restore power save blocker if there are active video players running.
1081 if (!active_video_players_.empty() && !video_power_save_blocker_) 1081 if (!active_video_players_.empty() && !video_power_save_blocker_)
1082 CreateVideoPowerSaveBlocker(); 1082 CreateVideoPowerSaveBlocker();
1083 1083
1084 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); 1084 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown());
1085 1085
1086 should_normally_be_visible_ = true; 1086 should_normally_be_visible_ = true;
1087 } 1087 }
1088 1088
1089 void WebContentsImpl::WasHidden() { 1089 void WebContentsImpl::WasHidden() {
1090 WasHidden(false);
1091 }
1092
1093 void WebContentsImpl::WasHidden(bool content_visible) {
1090 // If there are entities capturing screenshots or video (e.g., mirroring), 1094 // If there are entities capturing screenshots or video (e.g., mirroring),
1091 // don't activate the "disable rendering" optimization. 1095 // don't activate the "disable rendering" optimization.
1092 if (capturer_count_ == 0) { 1096 if (capturer_count_ == 0) {
1093 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to 1097 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to
1094 // open a tab in the background, then closes the tab before selecting it. 1098 // open a tab in the background, then closes the tab before selecting it.
1095 // This is because closing the tab calls WebContentsImpl::Destroy(), which 1099 // This is because closing the tab calls WebContentsImpl::Destroy(), which
1096 // removes the |GetRenderViewHost()|; then when we actually destroy the 1100 // removes the |GetRenderViewHost()|; then when we actually destroy the
1097 // window, OnWindowPosChanged() notices and calls WasHidden() (which 1101 // window, OnWindowPosChanged() notices and calls WasHidden() (which
1098 // calls us). 1102 // calls us).
1099 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { 1103 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) {
1100 if (view) 1104 if (view)
1101 view->Hide(); 1105 view->Hide(content_visible);
1102 } 1106 }
1103 1107
1104 // Release any video power save blockers held as video is not visible. 1108 // Release any video power save blockers held as video is not visible.
1105 video_power_save_blocker_.reset(); 1109 video_power_save_blocker_.reset();
1106 } 1110 }
1107 1111
1108 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); 1112 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden());
1109 1113
1110 should_normally_be_visible_ = false; 1114 should_normally_be_visible_ = false;
1111 } 1115 }
(...skipping 3401 matching lines...) Expand 10 before | Expand all | Expand 10 after
4513 node->render_manager()->ResumeResponseDeferredAtStart(); 4517 node->render_manager()->ResumeResponseDeferredAtStart();
4514 } 4518 }
4515 4519
4516 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4520 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4517 force_disable_overscroll_content_ = force_disable; 4521 force_disable_overscroll_content_ = force_disable;
4518 if (view_) 4522 if (view_)
4519 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4523 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4520 } 4524 }
4521 4525
4522 } // namespace content 4526 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698