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

Side by Side 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: addressing comments 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 unified diff | Download patch
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/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 OnSetHistoryOffsetAndLength) 1336 OnSetHistoryOffsetAndLength)
1337 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1337 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1338 OnReleaseDisambiguationPopupBitmap) 1338 OnReleaseDisambiguationPopupBitmap)
1339 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1339 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1340 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1340 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1341 1341
1342 // Page messages. 1342 // Page messages.
1343 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, 1343 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect,
1344 OnUpdateWindowScreenRect) 1344 OnUpdateWindowScreenRect)
1345 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) 1345 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel)
1346 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
1347 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
1348
1346 #if defined(OS_ANDROID) 1349 #if defined(OS_ANDROID)
1347 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, 1350 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
1348 OnUpdateTopControlsState) 1351 OnUpdateTopControlsState)
1349 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) 1352 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
1350 #elif defined(OS_MACOSX) 1353 #elif defined(OS_MACOSX)
1351 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, 1354 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText,
1352 OnGetRenderedText) 1355 OnGetRenderedText)
1353 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 1356 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
1354 #endif 1357 #endif
1355 // Adding a new message? Add platform independent ones first, then put the 1358 // Adding a new message? Add platform independent ones first, then put the
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 } 2311 }
2309 2312
2310 int RenderViewImpl::GetEnabledBindings() const { 2313 int RenderViewImpl::GetEnabledBindings() const {
2311 return enabled_bindings_; 2314 return enabled_bindings_;
2312 } 2315 }
2313 2316
2314 bool RenderViewImpl::GetContentStateImmediately() const { 2317 bool RenderViewImpl::GetContentStateImmediately() const {
2315 return send_content_state_immediately_; 2318 return send_content_state_immediately_;
2316 } 2319 }
2317 2320
2318 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const {
2319 return visibilityState();
2320 }
2321
2322 void RenderViewImpl::DidStartLoading() { 2321 void RenderViewImpl::DidStartLoading() {
2323 main_render_frame_->didStartLoading(true); 2322 main_render_frame_->didStartLoading(true);
2324 } 2323 }
2325 2324
2326 void RenderViewImpl::DidStopLoading() { 2325 void RenderViewImpl::DidStopLoading() {
2327 main_render_frame_->didStopLoading(); 2326 main_render_frame_->didStopLoading();
2328 } 2327 }
2329 2328
2330 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { 2329 void RenderViewImpl::OnSetPageScale(float page_scale_factor) {
2331 if (!webview()) 2330 if (!webview())
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 void RenderViewImpl::Close() { 2774 void RenderViewImpl::Close() {
2776 // We need to grab a pointer to the doomed WebView before we destroy it. 2775 // We need to grab a pointer to the doomed WebView before we destroy it.
2777 WebView* doomed = webview_; 2776 WebView* doomed = webview_;
2778 RenderWidget::Close(); 2777 RenderWidget::Close();
2779 webview_ = nullptr; 2778 webview_ = nullptr;
2780 g_view_map.Get().erase(doomed); 2779 g_view_map.Get().erase(doomed);
2781 g_routing_id_view_map.Get().erase(GetRoutingID()); 2780 g_routing_id_view_map.Get().erase(GetRoutingID());
2782 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); 2781 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
2783 } 2782 }
2784 2783
2785 void RenderViewImpl::OnWasHidden() { 2784 void RenderViewImpl::OnPageWasHidden() {
2786 RenderWidget::OnWasHidden();
2787
2788 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 2785 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2789 RenderThreadImpl::current()->video_capture_impl_manager()-> 2786 RenderThreadImpl::current()->video_capture_impl_manager()->
2790 SuspendDevices(true); 2787 SuspendDevices(true);
2791 if (speech_recognition_dispatcher_) 2788 if (speech_recognition_dispatcher_)
2792 speech_recognition_dispatcher_->AbortAllRecognitions(); 2789 speech_recognition_dispatcher_->AbortAllRecognitions();
2793 #endif 2790 #endif
2794 2791
2795 if (webview()) 2792 if (webview()) {
2796 webview()->setVisibilityState(visibilityState(), false); 2793 // TODO(lfg): It's not correct to defer the page visibility to the main
2794 // frame. Currently, this is done because the main frame may override the
2795 // visibility of the page when prerendering. In order to fix this,
2796 // prerendering must be made aware of OOPIFs. https://crbug.com/440544
2797 blink::WebPageVisibilityState visibilityState =
2798 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2799 : blink::WebPageVisibilityStateHidden;
2800 webview()->setVisibilityState(visibilityState, false);
2801 }
2797 } 2802 }
2798 2803
2799 void RenderViewImpl::OnWasShown(bool needs_repainting, 2804 void RenderViewImpl::OnPageWasShown() {
2800 const ui::LatencyInfo& latency_info) {
2801 RenderWidget::OnWasShown(needs_repainting, latency_info);
2802
2803 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 2805 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2804 RenderThreadImpl::current()->video_capture_impl_manager()-> 2806 RenderThreadImpl::current()->video_capture_impl_manager()->
2805 SuspendDevices(false); 2807 SuspendDevices(false);
2806 #endif 2808 #endif
2807 2809
2808 if (webview()) 2810 if (webview()) {
2809 webview()->setVisibilityState(visibilityState(), false); 2811 blink::WebPageVisibilityState visibilityState =
2812 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2813 : blink::WebPageVisibilityStateVisible;
2814 webview()->setVisibilityState(visibilityState, false);
2815 }
2810 } 2816 }
2811 2817
2812 GURL RenderViewImpl::GetURLForGraphicsContext3D() { 2818 GURL RenderViewImpl::GetURLForGraphicsContext3D() {
2813 DCHECK(webview()); 2819 DCHECK(webview());
2814 if (webview()->mainFrame()->isWebLocalFrame()) 2820 if (webview()->mainFrame()->isWebLocalFrame())
2815 return GURL(webview()->mainFrame()->document().url()); 2821 return GURL(webview()->mainFrame()->document().url());
2816 else 2822 else
2817 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); 2823 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D");
2818 } 2824 }
2819 2825
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3076 3082
3077 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 3083 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
3078 return ZoomLevelToZoomFactor(zoom_level); 3084 return ZoomLevelToZoomFactor(zoom_level);
3079 } 3085 }
3080 3086
3081 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { 3087 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
3082 return ZoomFactorToZoomLevel(factor); 3088 return ZoomFactorToZoomLevel(factor);
3083 } 3089 }
3084 3090
3085 blink::WebPageVisibilityState RenderViewImpl::visibilityState() const { 3091 blink::WebPageVisibilityState RenderViewImpl::visibilityState() const {
3086 blink::WebPageVisibilityState current_state = is_hidden() ? 3092 // This method should only be used to determine initial visibility.
3087 blink::WebPageVisibilityStateHidden : 3093 DCHECK(!main_render_frame_);
3088 blink::WebPageVisibilityStateVisible; 3094 return is_hidden() ? blink::WebPageVisibilityStateHidden
3089 blink::WebPageVisibilityState override_state = current_state; 3095 : blink::WebPageVisibilityStateVisible;
3090 // TODO(jam): move this method to WebFrameClient.
3091 if (GetContentClient()->renderer()->
3092 ShouldOverridePageVisibilityState(main_render_frame_,
3093 &override_state))
3094 return override_state;
3095 return current_state;
3096 } 3096 }
3097 3097
3098 void RenderViewImpl::draggableRegionsChanged() { 3098 void RenderViewImpl::draggableRegionsChanged() {
3099 FOR_EACH_OBSERVER( 3099 FOR_EACH_OBSERVER(
3100 RenderViewObserver, 3100 RenderViewObserver,
3101 observers_, 3101 observers_,
3102 DraggableRegionsChanged(webview()->mainFrame())); 3102 DraggableRegionsChanged(webview()->mainFrame()));
3103 } 3103 }
3104 3104
3105 void RenderViewImpl::pageImportanceSignalsChanged() { 3105 void RenderViewImpl::pageImportanceSignalsChanged() {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3391 return render_frame->focused_pepper_plugin(); 3391 return render_frame->focused_pepper_plugin();
3392 } 3392 }
3393 frame = frame->traverseNext(false); 3393 frame = frame->traverseNext(false);
3394 } 3394 }
3395 3395
3396 return nullptr; 3396 return nullptr;
3397 } 3397 }
3398 #endif 3398 #endif
3399 3399
3400 } // namespace content 3400 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698