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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 capturer_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 Loading... | |
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::IncrementCapturerCount() { |
1012 capturing_contents_ = cap; | 1012 ++capturer_count_; |
1013 DVLOG(1) << "There are now " << capturer_count_ | |
1014 << " capturing(s) of WebContentsImpl@" << this; | |
1015 } | |
1016 | |
1017 void WebContentsImpl::DecrementCapturerCount() { | |
1018 --capturer_count_; | |
1019 DVLOG(1) << "There are now " << capturer_count_ | |
1020 << " capturing(s) of WebContentsImpl@" << this; | |
1021 DCHECK_LE(0, capturer_count_); | |
1013 } | 1022 } |
1014 | 1023 |
1015 bool WebContentsImpl::IsCrashed() const { | 1024 bool WebContentsImpl::IsCrashed() const { |
1016 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || | 1025 return (crashed_status_ == base::TERMINATION_STATUS_PROCESS_CRASHED || |
1017 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || | 1026 crashed_status_ == base::TERMINATION_STATUS_ABNORMAL_TERMINATION || |
1018 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); | 1027 crashed_status_ == base::TERMINATION_STATUS_PROCESS_WAS_KILLED); |
1019 } | 1028 } |
1020 | 1029 |
1021 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, | 1030 void WebContentsImpl::SetIsCrashed(base::TerminationStatus status, |
1022 int error_code) { | 1031 int error_code) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1069 } | 1078 } |
1070 | 1079 |
1071 bool is_visible = true; | 1080 bool is_visible = true; |
1072 NotificationService::current()->Notify( | 1081 NotificationService::current()->Notify( |
1073 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 1082 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
1074 Source<WebContents>(this), | 1083 Source<WebContents>(this), |
1075 Details<bool>(&is_visible)); | 1084 Details<bool>(&is_visible)); |
1076 } | 1085 } |
1077 | 1086 |
1078 void WebContentsImpl::WasHidden() { | 1087 void WebContentsImpl::WasHidden() { |
1079 if (!capturing_contents_) { | 1088 // If there are entities capturing screenshots or video (e.g., mirroring), |
1089 // don't activate the "disable rendering" optimization. | |
1090 if (capturer_count_ == 0) { | |
1080 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 1091 // |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. | 1092 // open a tab in the background, then closes the tab before selecting it. |
1082 // This is because closing the tab calls WebContentsImpl::Destroy(), which | 1093 // This is because closing the tab calls WebContentsImpl::Destroy(), which |
1083 // removes the |GetRenderViewHost()|; then when we actually destroy the | 1094 // removes the |GetRenderViewHost()|; then when we actually destroy the |
1084 // window, OnWindowPosChanged() notices and calls WasHidden() (which | 1095 // window, OnWindowPosChanged() notices and calls WasHidden() (which |
1085 // calls us). | 1096 // calls us). |
1086 RenderWidgetHostViewPort* rwhv = | 1097 RenderWidgetHostViewPort* rwhv = |
1087 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); | 1098 RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); |
1088 if (rwhv) | 1099 if (rwhv) |
1089 rwhv->WasHidden(); | 1100 rwhv->WasHidden(); |
Jói
2013/02/05 12:49:47
Should this also fire while the RWHVP is hidden, w
miu
2013/02/05 20:58:26
Good call. Done and tested.
| |
1090 } | 1101 } |
1091 | 1102 |
1092 bool is_visible = false; | 1103 bool is_visible = false; |
1093 NotificationService::current()->Notify( | 1104 NotificationService::current()->Notify( |
1094 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, | 1105 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, |
1095 Source<WebContents>(this), | 1106 Source<WebContents>(this), |
1096 Details<bool>(&is_visible)); | 1107 Details<bool>(&is_visible)); |
1097 } | 1108 } |
1098 | 1109 |
1099 bool WebContentsImpl::NeedToFireBeforeUnload() { | 1110 bool WebContentsImpl::NeedToFireBeforeUnload() { |
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3450 | 3461 |
3451 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3462 BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
3452 return browser_plugin_guest_.get(); | 3463 return browser_plugin_guest_.get(); |
3453 } | 3464 } |
3454 | 3465 |
3455 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3466 BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
3456 return browser_plugin_embedder_.get(); | 3467 return browser_plugin_embedder_.get(); |
3457 } | 3468 } |
3458 | 3469 |
3459 } // namespace content | 3470 } // namespace content |
OLD | NEW |