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

Unified Diff: content/renderer/render_view_impl.cc

Issue 1991273003: Fire visibilityChange event on out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android test+naming Created 4 years, 6 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: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index f0460eac9891599c24ac584b93181867d4f2f960..ad3dfaaee5304d6f99e3f0298e1afbd2da1b5ee0 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -682,7 +682,7 @@ void RenderViewImpl::Initialize(const ViewMsg_New_Params& params,
// Ensure we start with a valid next_page_id_ from the browser.
DCHECK_GE(next_page_id_, 0);
- webview_ = WebView::create(this);
+ webview_ = WebView::create(this, !is_hidden());
webwidget_ = webview_->widget();
webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_));
@@ -1344,6 +1344,9 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect,
OnUpdateWindowScreenRect)
IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel)
+ IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
+ IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
+
#if defined(OS_ANDROID)
IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
OnUpdateTopControlsState)
@@ -2316,10 +2319,6 @@ bool RenderViewImpl::GetContentStateImmediately() const {
return send_content_state_immediately_;
}
-blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const {
- return visibilityState();
-}
-
void RenderViewImpl::DidStartLoading() {
main_render_frame_->didStartLoading(true);
}
@@ -2783,9 +2782,7 @@ void RenderViewImpl::Close() {
RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
}
-void RenderViewImpl::OnWasHidden() {
- RenderWidget::OnWasHidden();
-
+void RenderViewImpl::OnPageWasHidden() {
#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
RenderThreadImpl::current()->video_capture_impl_manager()->
SuspendDevices(true);
@@ -2793,21 +2790,30 @@ void RenderViewImpl::OnWasHidden() {
speech_recognition_dispatcher_->AbortAllRecognitions();
#endif
- if (webview())
- webview()->setVisibilityState(visibilityState(), false);
+ if (webview()) {
+ // TODO(lfg): It's not correct to defer the page visibility to the main
+ // frame. Currently, this is done because the main frame may override the
+ // visibility of the page when prerendering. In order to fix this,
+ // prerendering must be made aware of OOPIFs. https://crbug.com/440544
Charlie Reis 2016/06/06 23:15:09 Can you post an update to that bug about this cont
lfg 2016/06/08 20:00:24 Done.
+ blink::WebPageVisibilityState visibilityState =
+ GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
+ : blink::WebPageVisibilityStateHidden;
+ webview()->setVisibilityState(visibilityState, false);
+ }
}
-void RenderViewImpl::OnWasShown(bool needs_repainting,
- const ui::LatencyInfo& latency_info) {
- RenderWidget::OnWasShown(needs_repainting, latency_info);
-
+void RenderViewImpl::OnPageWasShown() {
#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
RenderThreadImpl::current()->video_capture_impl_manager()->
SuspendDevices(false);
#endif
- if (webview())
- webview()->setVisibilityState(visibilityState(), false);
+ if (webview()) {
+ blink::WebPageVisibilityState visibilityState =
+ GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
+ : blink::WebPageVisibilityStateVisible;
+ webview()->setVisibilityState(visibilityState, false);
+ }
}
GURL RenderViewImpl::GetURLForGraphicsContext3D() {
@@ -3083,19 +3089,6 @@ double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
return ZoomFactorToZoomLevel(factor);
}
-blink::WebPageVisibilityState RenderViewImpl::visibilityState() const {
- blink::WebPageVisibilityState current_state = is_hidden() ?
- blink::WebPageVisibilityStateHidden :
- blink::WebPageVisibilityStateVisible;
- blink::WebPageVisibilityState override_state = current_state;
- // TODO(jam): move this method to WebFrameClient.
- if (GetContentClient()->renderer()->
- ShouldOverridePageVisibilityState(main_render_frame_,
- &override_state))
- return override_state;
- return current_state;
-}
-
void RenderViewImpl::draggableRegionsChanged() {
FOR_EACH_OBSERVER(
RenderViewObserver,

Powered by Google App Engine
This is Rietveld 408576698