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

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: 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 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 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 OnSetHistoryOffsetAndLength) 1329 OnSetHistoryOffsetAndLength)
1330 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1330 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1331 OnReleaseDisambiguationPopupBitmap) 1331 OnReleaseDisambiguationPopupBitmap)
1332 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1332 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1333 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1333 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1334 1334
1335 // Page messages. 1335 // Page messages.
1336 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, 1336 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect,
1337 OnUpdateWindowScreenRect) 1337 OnUpdateWindowScreenRect)
1338 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) 1338 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel)
1339 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
1340 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
1341
1339 #if defined(OS_ANDROID) 1342 #if defined(OS_ANDROID)
1340 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, 1343 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
1341 OnUpdateTopControlsState) 1344 OnUpdateTopControlsState)
1342 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) 1345 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
1343 #elif defined(OS_MACOSX) 1346 #elif defined(OS_MACOSX)
1344 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, 1347 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText,
1345 OnGetRenderedText) 1348 OnGetRenderedText)
1346 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 1349 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
1347 #endif 1350 #endif
1348 // Adding a new message? Add platform independent ones first, then put the 1351 // Adding a new message? Add platform independent ones first, then put the
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 } 2307 }
2305 2308
2306 int RenderViewImpl::GetEnabledBindings() const { 2309 int RenderViewImpl::GetEnabledBindings() const {
2307 return enabled_bindings_; 2310 return enabled_bindings_;
2308 } 2311 }
2309 2312
2310 bool RenderViewImpl::GetContentStateImmediately() const { 2313 bool RenderViewImpl::GetContentStateImmediately() const {
2311 return send_content_state_immediately_; 2314 return send_content_state_immediately_;
2312 } 2315 }
2313 2316
2314 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const {
2315 return visibilityState();
2316 }
2317
2318 void RenderViewImpl::DidStartLoading() { 2317 void RenderViewImpl::DidStartLoading() {
2319 main_render_frame_->didStartLoading(true); 2318 main_render_frame_->didStartLoading(true);
2320 } 2319 }
2321 2320
2322 void RenderViewImpl::DidStopLoading() { 2321 void RenderViewImpl::DidStopLoading() {
2323 main_render_frame_->didStopLoading(); 2322 main_render_frame_->didStopLoading();
2324 } 2323 }
2325 2324
2326 blink::WebElement RenderViewImpl::GetFocusedElement() const { 2325 blink::WebElement RenderViewImpl::GetFocusedElement() const {
2327 if (!webview()) 2326 if (!webview())
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2770 void RenderViewImpl::Close() { 2769 void RenderViewImpl::Close() {
2771 // We need to grab a pointer to the doomed WebView before we destroy it. 2770 // We need to grab a pointer to the doomed WebView before we destroy it.
2772 WebView* doomed = webview_; 2771 WebView* doomed = webview_;
2773 RenderWidget::Close(); 2772 RenderWidget::Close();
2774 webview_ = nullptr; 2773 webview_ = nullptr;
2775 g_view_map.Get().erase(doomed); 2774 g_view_map.Get().erase(doomed);
2776 g_routing_id_view_map.Get().erase(GetRoutingID()); 2775 g_routing_id_view_map.Get().erase(GetRoutingID());
2777 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); 2776 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
2778 } 2777 }
2779 2778
2780 void RenderViewImpl::OnWasHidden() { 2779 void RenderViewImpl::OnPageWasHidden() {
2781 RenderWidget::OnWasHidden();
2782
2783 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 2780 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2784 RenderThreadImpl::current()->video_capture_impl_manager()-> 2781 RenderThreadImpl::current()->video_capture_impl_manager()->
2785 SuspendDevices(true); 2782 SuspendDevices(true);
2786 if (speech_recognition_dispatcher_) 2783 if (speech_recognition_dispatcher_)
2787 speech_recognition_dispatcher_->AbortAllRecognitions(); 2784 speech_recognition_dispatcher_->AbortAllRecognitions();
2788 #endif 2785 #endif
2789 2786
2790 if (webview()) 2787 if (webview()) {
2791 webview()->setVisibilityState(visibilityState(), false); 2788 blink::WebPageVisibilityState visibilityState =
2789 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
2790 : blink::WebPageVisibilityStateHidden;
2791 webview()->setVisibilityState(visibilityState, false);
2792 }
2792 } 2793 }
2793 2794
2794 void RenderViewImpl::OnWasShown(bool needs_repainting, 2795 void RenderViewImpl::OnPageWasShown() {
2795 const ui::LatencyInfo& latency_info) {
2796 RenderWidget::OnWasShown(needs_repainting, latency_info);
2797
2798 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 2796 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2799 RenderThreadImpl::current()->video_capture_impl_manager()-> 2797 RenderThreadImpl::current()->video_capture_impl_manager()->
2800 SuspendDevices(false); 2798 SuspendDevices(false);
2801 #endif 2799 #endif
2802 2800
2803 if (webview()) 2801 if (webview()) {
2804 webview()->setVisibilityState(visibilityState(), false); 2802 blink::WebPageVisibilityState visibilityState =
2803 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2804 : blink::WebPageVisibilityStateVisible;
2805 webview()->setVisibilityState(visibilityState, false);
2806 }
2805 } 2807 }
2806 2808
2807 GURL RenderViewImpl::GetURLForGraphicsContext3D() { 2809 GURL RenderViewImpl::GetURLForGraphicsContext3D() {
2808 DCHECK(webview()); 2810 DCHECK(webview());
2809 if (webview()->mainFrame()->isWebLocalFrame()) 2811 if (webview()->mainFrame()->isWebLocalFrame())
2810 return GURL(webview()->mainFrame()->document().url()); 2812 return GURL(webview()->mainFrame()->document().url());
2811 else 2813 else
2812 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); 2814 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D");
2813 } 2815 }
2814 2816
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 3073
3072 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 3074 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
3073 return ZoomLevelToZoomFactor(zoom_level); 3075 return ZoomLevelToZoomFactor(zoom_level);
3074 } 3076 }
3075 3077
3076 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { 3078 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
3077 return ZoomFactorToZoomLevel(factor); 3079 return ZoomFactorToZoomLevel(factor);
3078 } 3080 }
3079 3081
3080 blink::WebPageVisibilityState RenderViewImpl::visibilityState() const { 3082 blink::WebPageVisibilityState RenderViewImpl::visibilityState() const {
3081 blink::WebPageVisibilityState current_state = is_hidden() ? 3083 // 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()
3082 blink::WebPageVisibilityStateHidden : 3084 DCHECK(!main_render_frame_);
3083 blink::WebPageVisibilityStateVisible; 3085 return is_hidden() ? blink::WebPageVisibilityStateHidden
3084 blink::WebPageVisibilityState override_state = current_state; 3086 : blink::WebPageVisibilityStateVisible;
3085 // TODO(jam): move this method to WebFrameClient.
3086 if (GetContentClient()->renderer()->
3087 ShouldOverridePageVisibilityState(main_render_frame_,
3088 &override_state))
3089 return override_state;
3090 return current_state;
3091 } 3087 }
3092 3088
3093 void RenderViewImpl::draggableRegionsChanged() { 3089 void RenderViewImpl::draggableRegionsChanged() {
3094 FOR_EACH_OBSERVER( 3090 FOR_EACH_OBSERVER(
3095 RenderViewObserver, 3091 RenderViewObserver,
3096 observers_, 3092 observers_,
3097 DraggableRegionsChanged(webview()->mainFrame())); 3093 DraggableRegionsChanged(webview()->mainFrame()));
3098 } 3094 }
3099 3095
3100 void RenderViewImpl::pageImportanceSignalsChanged() { 3096 void RenderViewImpl::pageImportanceSignalsChanged() {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
3386 return render_frame->focused_pepper_plugin(); 3382 return render_frame->focused_pepper_plugin();
3387 } 3383 }
3388 frame = frame->traverseNext(false); 3384 frame = frame->traverseNext(false);
3389 } 3385 }
3390 3386
3391 return nullptr; 3387 return nullptr;
3392 } 3388 }
3393 #endif 3389 #endif
3394 3390
3395 } // namespace content 3391 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698