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

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: comments Created 4 years, 5 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') | extensions/renderer/scoped_web_frame.cc » ('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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( 687 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener(
688 params.opener_frame_route_id, &opener_view_routing_id); 688 params.opener_frame_route_id, &opener_view_routing_id);
689 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) 689 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer)
690 opener_id_ = opener_view_routing_id; 690 opener_id_ = opener_view_routing_id;
691 691
692 display_mode_ = params.initial_size.display_mode; 692 display_mode_ = params.initial_size.display_mode;
693 693
694 // Ensure we start with a valid next_page_id_ from the browser. 694 // Ensure we start with a valid next_page_id_ from the browser.
695 DCHECK_GE(next_page_id_, 0); 695 DCHECK_GE(next_page_id_, 0);
696 696
697 webview_ = WebView::create(this); 697 webview_ =
698 WebView::create(this, is_hidden() ? blink::WebPageVisibilityStateHidden
699 : blink::WebPageVisibilityStateVisible);
698 RenderWidget::DoInit(MSG_ROUTING_NONE, webview_->widget(), nullptr); 700 RenderWidget::DoInit(MSG_ROUTING_NONE, webview_->widget(), nullptr);
699 701
700 g_view_map.Get().insert(std::make_pair(webview(), this)); 702 g_view_map.Get().insert(std::make_pair(webview(), this));
701 g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this)); 703 g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this));
702 704
703 const base::CommandLine& command_line = 705 const base::CommandLine& command_line =
704 *base::CommandLine::ForCurrentProcess(); 706 *base::CommandLine::ForCurrentProcess();
705 707
706 if (command_line.HasSwitch(switches::kStatsCollectionController)) 708 if (command_line.HasSwitch(switches::kStatsCollectionController))
707 stats_collection_observer_.reset(new StatsCollectionObserver(this)); 709 stats_collection_observer_.reset(new StatsCollectionObserver(this));
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 OnSetHistoryOffsetAndLength) 1324 OnSetHistoryOffsetAndLength)
1323 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1325 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1324 OnReleaseDisambiguationPopupBitmap) 1326 OnReleaseDisambiguationPopupBitmap)
1325 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1327 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1326 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1328 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1327 1329
1328 // Page messages. 1330 // Page messages.
1329 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, 1331 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect,
1330 OnUpdateWindowScreenRect) 1332 OnUpdateWindowScreenRect)
1331 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) 1333 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel)
1334 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
1335 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
1336
1332 #if defined(OS_ANDROID) 1337 #if defined(OS_ANDROID)
1333 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, 1338 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
1334 OnUpdateTopControlsState) 1339 OnUpdateTopControlsState)
1335 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) 1340 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
1336 #elif defined(OS_MACOSX) 1341 #elif defined(OS_MACOSX)
1337 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, 1342 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText,
1338 OnGetRenderedText) 1343 OnGetRenderedText)
1339 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) 1344 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
1340 #endif 1345 #endif
1341 // Adding a new message? Add platform independent ones first, then put the 1346 // Adding a new message? Add platform independent ones first, then put the
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
2240 } 2245 }
2241 2246
2242 int RenderViewImpl::GetEnabledBindings() const { 2247 int RenderViewImpl::GetEnabledBindings() const {
2243 return enabled_bindings_; 2248 return enabled_bindings_;
2244 } 2249 }
2245 2250
2246 bool RenderViewImpl::GetContentStateImmediately() const { 2251 bool RenderViewImpl::GetContentStateImmediately() const {
2247 return send_content_state_immediately_; 2252 return send_content_state_immediately_;
2248 } 2253 }
2249 2254
2250 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const {
2251 return visibilityState();
2252 }
2253
2254 void RenderViewImpl::DidStartLoading() { 2255 void RenderViewImpl::DidStartLoading() {
2255 main_render_frame_->didStartLoading(true); 2256 main_render_frame_->didStartLoading(true);
2256 } 2257 }
2257 2258
2258 void RenderViewImpl::DidStopLoading() { 2259 void RenderViewImpl::DidStopLoading() {
2259 main_render_frame_->didStopLoading(); 2260 main_render_frame_->didStopLoading();
2260 } 2261 }
2261 2262
2262 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { 2263 void RenderViewImpl::OnSetPageScale(float page_scale_factor) {
2263 if (!webview()) 2264 if (!webview())
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 void RenderViewImpl::Close() { 2672 void RenderViewImpl::Close() {
2672 // We need to grab a pointer to the doomed WebView before we destroy it. 2673 // We need to grab a pointer to the doomed WebView before we destroy it.
2673 WebView* doomed = webview_; 2674 WebView* doomed = webview_;
2674 RenderWidget::Close(); 2675 RenderWidget::Close();
2675 webview_ = nullptr; 2676 webview_ = nullptr;
2676 g_view_map.Get().erase(doomed); 2677 g_view_map.Get().erase(doomed);
2677 g_routing_id_view_map.Get().erase(GetRoutingID()); 2678 g_routing_id_view_map.Get().erase(GetRoutingID());
2678 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); 2679 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
2679 } 2680 }
2680 2681
2681 void RenderViewImpl::OnWasHidden() { 2682 void RenderViewImpl::OnPageWasHidden() {
2682 RenderWidget::OnWasHidden();
2683
2684 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 2683 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2685 RenderThreadImpl::current()->video_capture_impl_manager()-> 2684 RenderThreadImpl::current()->video_capture_impl_manager()->
2686 SuspendDevices(true); 2685 SuspendDevices(true);
2687 if (speech_recognition_dispatcher_) 2686 if (speech_recognition_dispatcher_)
2688 speech_recognition_dispatcher_->AbortAllRecognitions(); 2687 speech_recognition_dispatcher_->AbortAllRecognitions();
2689 #endif 2688 #endif
2690 2689
2691 if (webview()) 2690 if (webview()) {
2692 webview()->setVisibilityState(visibilityState(), false); 2691 // TODO(lfg): It's not correct to defer the page visibility to the main
2692 // frame. Currently, this is done because the main frame may override the
2693 // visibility of the page when prerendering. In order to fix this,
2694 // prerendering must be made aware of OOPIFs. https://crbug.com/440544
2695 blink::WebPageVisibilityState visibilityState =
2696 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2697 : blink::WebPageVisibilityStateHidden;
2698 webview()->setVisibilityState(visibilityState, false);
2699 }
2693 } 2700 }
2694 2701
2695 void RenderViewImpl::OnWasShown(bool needs_repainting, 2702 void RenderViewImpl::OnPageWasShown() {
2696 const ui::LatencyInfo& latency_info) {
2697 RenderWidget::OnWasShown(needs_repainting, latency_info);
2698
2699 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) 2703 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2700 RenderThreadImpl::current()->video_capture_impl_manager()-> 2704 RenderThreadImpl::current()->video_capture_impl_manager()->
2701 SuspendDevices(false); 2705 SuspendDevices(false);
2702 #endif 2706 #endif
2703 2707
2704 if (webview()) 2708 if (webview()) {
2705 webview()->setVisibilityState(visibilityState(), false); 2709 blink::WebPageVisibilityState visibilityState =
2710 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2711 : blink::WebPageVisibilityStateVisible;
2712 webview()->setVisibilityState(visibilityState, false);
2713 }
2706 } 2714 }
2707 2715
2708 GURL RenderViewImpl::GetURLForGraphicsContext3D() { 2716 GURL RenderViewImpl::GetURLForGraphicsContext3D() {
2709 DCHECK(webview()); 2717 DCHECK(webview());
2710 if (webview()->mainFrame()->isWebLocalFrame()) 2718 if (webview()->mainFrame()->isWebLocalFrame())
2711 return GURL(webview()->mainFrame()->document().url()); 2719 return GURL(webview()->mainFrame()->document().url());
2712 else 2720 else
2713 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); 2721 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D");
2714 } 2722 }
2715 2723
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2946 } 2954 }
2947 2955
2948 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { 2956 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
2949 return ZoomLevelToZoomFactor(zoom_level); 2957 return ZoomLevelToZoomFactor(zoom_level);
2950 } 2958 }
2951 2959
2952 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { 2960 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
2953 return ZoomFactorToZoomLevel(factor); 2961 return ZoomFactorToZoomLevel(factor);
2954 } 2962 }
2955 2963
2956 blink::WebPageVisibilityState RenderViewImpl::visibilityState() const {
2957 blink::WebPageVisibilityState current_state = is_hidden() ?
2958 blink::WebPageVisibilityStateHidden :
2959 blink::WebPageVisibilityStateVisible;
2960 blink::WebPageVisibilityState override_state = current_state;
2961 // TODO(jam): move this method to WebFrameClient.
2962 if (GetContentClient()->renderer()->
2963 ShouldOverridePageVisibilityState(main_render_frame_,
2964 &override_state))
2965 return override_state;
2966 return current_state;
2967 }
2968
2969 void RenderViewImpl::draggableRegionsChanged() { 2964 void RenderViewImpl::draggableRegionsChanged() {
2970 FOR_EACH_OBSERVER( 2965 FOR_EACH_OBSERVER(
2971 RenderViewObserver, 2966 RenderViewObserver,
2972 observers_, 2967 observers_,
2973 DraggableRegionsChanged(webview()->mainFrame())); 2968 DraggableRegionsChanged(webview()->mainFrame()));
2974 } 2969 }
2975 2970
2976 void RenderViewImpl::pageImportanceSignalsChanged() { 2971 void RenderViewImpl::pageImportanceSignalsChanged() {
2977 if (!webview() || !main_render_frame_) 2972 if (!webview() || !main_render_frame_)
2978 return; 2973 return;
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
3262 return render_frame->focused_pepper_plugin(); 3257 return render_frame->focused_pepper_plugin();
3263 } 3258 }
3264 frame = frame->traverseNext(false); 3259 frame = frame->traverseNext(false);
3265 } 3260 }
3266 3261
3267 return nullptr; 3262 return nullptr;
3268 } 3263 }
3269 #endif 3264 #endif
3270 3265
3271 } // namespace content 3266 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | extensions/renderer/scoped_web_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698