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

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: Created 4 years, 7 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 4a9410c788105f93c7c1f856a5b39f873a4c8964..13dfb6f18da6866d22da588195d86e7d6dbcaa35 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -1336,6 +1336,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)
@@ -2311,10 +2314,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);
}
@@ -2777,9 +2776,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);
@@ -2787,21 +2784,26 @@ void RenderViewImpl::OnWasHidden() {
speech_recognition_dispatcher_->AbortAllRecognitions();
#endif
- if (webview())
- webview()->setVisibilityState(visibilityState(), false);
+ if (webview()) {
+ blink::WebPageVisibilityState visibilityState =
+ GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
kenrb 2016/05/24 20:25:18 Why do we defer to the main frame's visibility sta
lfg 2016/05/24 23:33:50 This is a bit tricky to fix, it's not as simple as
kenrb 2016/05/25 20:29:14 I agree it should work fine as is, but I think thi
lfg 2016/05/31 19:54:01 I've added a TODO with a link to the prerendering
+ : 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() {
@@ -3078,16 +3080,10 @@ double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
}
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;
+ // This method should only be used to determine initial visibility.
kenrb 2016/05/24 20:25:18 This comment isn't very clear, what does 'initial
lfg 2016/05/24 23:33:51 Perhaps it should be moved. When the WebViewImpl i
kenrb 2016/05/25 20:29:14 Now, that I understand this better, I'm not sure i
lfg 2016/05/31 19:54:01 Yes, we would be able to remove visibilityState()
+ DCHECK(!main_render_frame_);
+ return is_hidden() ? blink::WebPageVisibilityStateHidden
+ : blink::WebPageVisibilityStateVisible;
}
void RenderViewImpl::draggableRegionsChanged() {

Powered by Google App Engine
This is Rietveld 408576698