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

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

Powered by Google App Engine
This is Rietveld 408576698