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

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

Issue 12179007: While screencasting a tab, do not disable rendering updates while hidden. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment for WebContents::SetCapturingContents() mentions counting. Created 7 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 | Annotate | Revision Log
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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 opener_(opener), 302 opener_(opener),
303 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)), 303 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)),
304 is_loading_(false), 304 is_loading_(false),
305 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), 305 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
306 crashed_error_code_(0), 306 crashed_error_code_(0),
307 waiting_for_response_(false), 307 waiting_for_response_(false),
308 load_state_(net::LOAD_STATE_IDLE, string16()), 308 load_state_(net::LOAD_STATE_IDLE, string16()),
309 upload_size_(0), 309 upload_size_(0),
310 upload_position_(0), 310 upload_position_(0),
311 displayed_insecure_content_(false), 311 displayed_insecure_content_(false),
312 capturing_contents_(false), 312 capturing_count_(0),
313 is_being_destroyed_(false), 313 is_being_destroyed_(false),
314 notify_disconnection_(false), 314 notify_disconnection_(false),
315 dialog_manager_(NULL), 315 dialog_manager_(NULL),
316 is_showing_before_unload_dialog_(false), 316 is_showing_before_unload_dialog_(false),
317 opener_web_ui_type_(WebUI::kNoWebUI), 317 opener_web_ui_type_(WebUI::kNoWebUI),
318 closed_by_user_gesture_(false), 318 closed_by_user_gesture_(false),
319 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)), 319 minimum_zoom_percent_(static_cast<int>(kMinimumZoomFactor * 100)),
320 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)), 320 maximum_zoom_percent_(static_cast<int>(kMaximumZoomFactor * 100)),
321 temporary_zoom_settings_(false), 321 temporary_zoom_settings_(false),
322 content_restrictions_(0), 322 content_restrictions_(0),
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 } 1001 }
1002 1002
1003 const std::string& WebContentsImpl::GetEncoding() const { 1003 const std::string& WebContentsImpl::GetEncoding() const {
1004 return encoding_; 1004 return encoding_;
1005 } 1005 }
1006 1006
1007 bool WebContentsImpl::DisplayedInsecureContent() const { 1007 bool WebContentsImpl::DisplayedInsecureContent() const {
1008 return displayed_insecure_content_; 1008 return displayed_insecure_content_;
1009 } 1009 }
1010 1010
1011 void WebContentsImpl::SetCapturingContents(bool cap) { 1011 void WebContentsImpl::SetCapturingContents(bool cap) {
ncarter (slow) 2013/02/04 22:13:43 It seems a little risky to have a method named Set
1012 capturing_contents_ = cap; 1012 capturing_count_ += cap ? +1 : -1;
1013 DVLOG(1) << "There are now " << capturing_count_
1014 << " capturing(s) of WebContentsImpl@" << this;
1015 DCHECK_LE(0, capturing_count_);
1013 } 1016 }
1014 1017
1015 bool WebContentsImpl::IsCrashed() const { 1018 bool WebContentsImpl::IsCrashed() const {
1016 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || 1019 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED ||
1017 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || 1020 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION ||
1018 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); 1021 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
1019 } 1022 }
1020 1023
1021 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, 1024 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status,
1022 int error_code) { 1025 int error_code) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 } 1072 }
1070 1073
1071 bool is_visible = true; 1074 bool is_visible = true;
1072 NotificationService::current()->Notify( 1075 NotificationService::current()->Notify(
1073 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, 1076 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
1074 Source<WebContents>(this), 1077 Source<WebContents>(this),
1075 Details<bool>(&is_visible)); 1078 Details<bool>(&is_visible));
1076 } 1079 }
1077 1080
1078 void WebContentsImpl::WasHidden() { 1081 void WebContentsImpl::WasHidden() {
1079 if (!capturing_contents_) { 1082 // If there are entities capturing screenshots or video (e.g., mirroring),
1083 // don't activate the "disable rendering" optimization.
1084 if (capturing_count_ == 0) {
1080 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to 1085 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to
1081 // open a tab in then background, then closes the tab before selecting it. 1086 // open a tab in the background, then closes the tab before selecting it.
1082 // This is because closing the tab calls WebContentsImpl::Destroy(), which 1087 // This is because closing the tab calls WebContentsImpl::Destroy(), which
1083 // removes the |GetRenderViewHost()|; then when we actually destroy the 1088 // removes the |GetRenderViewHost()|; then when we actually destroy the
1084 // window, OnWindowPosChanged() notices and calls WasHidden() (which 1089 // window, OnWindowPosChanged() notices and calls WasHidden() (which
1085 // calls us). 1090 // calls us).
1086 RenderWidgetHostViewPort* rwhv = 1091 RenderWidgetHostViewPort* rwhv =
1087 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); 1092 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView());
1088 if (rwhv) 1093 if (rwhv)
1089 rwhv->WasHidden(); 1094 rwhv->WasHidden();
1090 } 1095 }
1091 1096
(...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after
3450 3455
3451 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { 3456 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() {
3452 return browser_plugin_guest_.get(); 3457 return browser_plugin_guest_.get();
3453 } 3458 }
3454 3459
3455 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { 3460 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() {
3456 return browser_plugin_embedder_.get(); 3461 return browser_plugin_embedder_.get();
3457 } 3462 }
3458 3463
3459 } // namespace content 3464 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698