| OLD | NEW |
| 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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 // Restore power save blocker if there are active video players running. | 1084 // Restore power save blocker if there are active video players running. |
| 1085 if (!active_video_players_.empty() && !video_power_save_blocker_) | 1085 if (!active_video_players_.empty() && !video_power_save_blocker_) |
| 1086 CreateVideoPowerSaveBlocker(); | 1086 CreateVideoPowerSaveBlocker(); |
| 1087 | 1087 |
| 1088 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); | 1088 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); |
| 1089 | 1089 |
| 1090 should_normally_be_visible_ = true; | 1090 should_normally_be_visible_ = true; |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 void WebContentsImpl::WasHidden() { | 1093 void WebContentsImpl::WasHidden() { |
| 1094 WasHidden(false); |
| 1095 } |
| 1096 |
| 1097 void WebContentsImpl::WasHidden(bool content_visible) { |
| 1094 // If there are entities capturing screenshots or video (e.g., mirroring), | 1098 // If there are entities capturing screenshots or video (e.g., mirroring), |
| 1095 // don't activate the "disable rendering" optimization. | 1099 // don't activate the "disable rendering" optimization. |
| 1096 if (capturer_count_ == 0) { | 1100 if (capturer_count_ == 0) { |
| 1097 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 1101 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
| 1098 // open a tab in the background, then closes the tab before selecting it. | 1102 // open a tab in the background, then closes the tab before selecting it. |
| 1099 // This is because closing the tab calls WebContentsImpl::Destroy(), which | 1103 // This is because closing the tab calls WebContentsImpl::Destroy(), which |
| 1100 // removes the |GetRenderViewHost()|; then when we actually destroy the | 1104 // removes the |GetRenderViewHost()|; then when we actually destroy the |
| 1101 // window, OnWindowPosChanged() notices and calls WasHidden() (which | 1105 // window, OnWindowPosChanged() notices and calls WasHidden() (which |
| 1102 // calls us). | 1106 // calls us). |
| 1103 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { | 1107 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { |
| 1104 if (view) | 1108 if (view) |
| 1105 view->Hide(); | 1109 view->Hide(content_visible); |
| 1106 } | 1110 } |
| 1107 | 1111 |
| 1108 // Release any video power save blockers held as video is not visible. | 1112 // Release any video power save blockers held as video is not visible. |
| 1109 video_power_save_blocker_.reset(); | 1113 video_power_save_blocker_.reset(); |
| 1110 } | 1114 } |
| 1111 | 1115 |
| 1112 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); | 1116 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); |
| 1113 | 1117 |
| 1114 should_normally_be_visible_ = false; | 1118 should_normally_be_visible_ = false; |
| 1115 } | 1119 } |
| (...skipping 3397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |