Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 675 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( | 675 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( |
| 676 params.opener_frame_route_id, &opener_view_routing_id); | 676 params.opener_frame_route_id, &opener_view_routing_id); |
| 677 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) | 677 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) |
| 678 opener_id_ = opener_view_routing_id; | 678 opener_id_ = opener_view_routing_id; |
| 679 | 679 |
| 680 display_mode_ = params.initial_size.display_mode; | 680 display_mode_ = params.initial_size.display_mode; |
| 681 | 681 |
| 682 // Ensure we start with a valid next_page_id_ from the browser. | 682 // Ensure we start with a valid next_page_id_ from the browser. |
| 683 DCHECK_GE(next_page_id_, 0); | 683 DCHECK_GE(next_page_id_, 0); |
| 684 | 684 |
| 685 webview_ = WebView::create(this); | 685 webview_ = WebView::create(this, !is_hidden()); |
| 686 webwidget_ = webview_->widget(); | 686 webwidget_ = webview_->widget(); |
| 687 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); | 687 webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); |
| 688 | 688 |
| 689 g_view_map.Get().insert(std::make_pair(webview(), this)); | 689 g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 690 g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this)); | 690 g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this)); |
| 691 | 691 |
| 692 const base::CommandLine& command_line = | 692 const base::CommandLine& command_line = |
| 693 *base::CommandLine::ForCurrentProcess(); | 693 *base::CommandLine::ForCurrentProcess(); |
| 694 | 694 |
| 695 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 695 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1337 OnSetHistoryOffsetAndLength) | 1337 OnSetHistoryOffsetAndLength) |
| 1338 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, | 1338 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
| 1339 OnReleaseDisambiguationPopupBitmap) | 1339 OnReleaseDisambiguationPopupBitmap) |
| 1340 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) | 1340 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
| 1341 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) | 1341 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
| 1342 | 1342 |
| 1343 // Page messages. | 1343 // Page messages. |
| 1344 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, | 1344 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, |
| 1345 OnUpdateWindowScreenRect) | 1345 OnUpdateWindowScreenRect) |
| 1346 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) | 1346 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) |
| 1347 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) | |
| 1348 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) | |
| 1349 | |
| 1347 #if defined(OS_ANDROID) | 1350 #if defined(OS_ANDROID) |
| 1348 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, | 1351 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
| 1349 OnUpdateTopControlsState) | 1352 OnUpdateTopControlsState) |
| 1350 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) | 1353 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
| 1351 #elif defined(OS_MACOSX) | 1354 #elif defined(OS_MACOSX) |
| 1352 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, | 1355 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
| 1353 OnGetRenderedText) | 1356 OnGetRenderedText) |
| 1354 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 1357 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 1355 #endif | 1358 #endif |
| 1356 // Adding a new message? Add platform independent ones first, then put the | 1359 // Adding a new message? Add platform independent ones first, then put the |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2309 } | 2312 } |
| 2310 | 2313 |
| 2311 int RenderViewImpl::GetEnabledBindings() const { | 2314 int RenderViewImpl::GetEnabledBindings() const { |
| 2312 return enabled_bindings_; | 2315 return enabled_bindings_; |
| 2313 } | 2316 } |
| 2314 | 2317 |
| 2315 bool RenderViewImpl::GetContentStateImmediately() const { | 2318 bool RenderViewImpl::GetContentStateImmediately() const { |
| 2316 return send_content_state_immediately_; | 2319 return send_content_state_immediately_; |
| 2317 } | 2320 } |
| 2318 | 2321 |
| 2319 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { | |
| 2320 return visibilityState(); | |
| 2321 } | |
| 2322 | |
| 2323 void RenderViewImpl::DidStartLoading() { | 2322 void RenderViewImpl::DidStartLoading() { |
| 2324 main_render_frame_->didStartLoading(true); | 2323 main_render_frame_->didStartLoading(true); |
| 2325 } | 2324 } |
| 2326 | 2325 |
| 2327 void RenderViewImpl::DidStopLoading() { | 2326 void RenderViewImpl::DidStopLoading() { |
| 2328 main_render_frame_->didStopLoading(); | 2327 main_render_frame_->didStopLoading(); |
| 2329 } | 2328 } |
| 2330 | 2329 |
| 2331 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { | 2330 void RenderViewImpl::OnSetPageScale(float page_scale_factor) { |
| 2332 if (!webview()) | 2331 if (!webview()) |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2776 void RenderViewImpl::Close() { | 2775 void RenderViewImpl::Close() { |
| 2777 // We need to grab a pointer to the doomed WebView before we destroy it. | 2776 // We need to grab a pointer to the doomed WebView before we destroy it. |
| 2778 WebView* doomed = webview_; | 2777 WebView* doomed = webview_; |
| 2779 RenderWidget::Close(); | 2778 RenderWidget::Close(); |
| 2780 webview_ = nullptr; | 2779 webview_ = nullptr; |
| 2781 g_view_map.Get().erase(doomed); | 2780 g_view_map.Get().erase(doomed); |
| 2782 g_routing_id_view_map.Get().erase(GetRoutingID()); | 2781 g_routing_id_view_map.Get().erase(GetRoutingID()); |
| 2783 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); | 2782 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); |
| 2784 } | 2783 } |
| 2785 | 2784 |
| 2786 void RenderViewImpl::OnWasHidden() { | 2785 void RenderViewImpl::OnPageWasHidden() { |
| 2787 RenderWidget::OnWasHidden(); | |
| 2788 | |
| 2789 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 2786 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 2790 RenderThreadImpl::current()->video_capture_impl_manager()-> | 2787 RenderThreadImpl::current()->video_capture_impl_manager()-> |
| 2791 SuspendDevices(true); | 2788 SuspendDevices(true); |
| 2792 if (speech_recognition_dispatcher_) | 2789 if (speech_recognition_dispatcher_) |
| 2793 speech_recognition_dispatcher_->AbortAllRecognitions(); | 2790 speech_recognition_dispatcher_->AbortAllRecognitions(); |
| 2794 #endif | 2791 #endif |
| 2795 | 2792 |
| 2796 if (webview()) | 2793 if (webview()) { |
| 2797 webview()->setVisibilityState(visibilityState(), false); | 2794 // TODO(lfg): It's not correct to defer the page visibility to the main |
| 2795 // frame. Currently, this is done because the main frame may override the | |
| 2796 // visibility of the page when prerendering. In order to fix this, | |
| 2797 // prerendering must be made aware of OOPIFs. https://crbug.com/440544 | |
|
Charlie Reis
2016/06/06 23:15:09
Can you post an update to that bug about this cont
lfg
2016/06/08 20:00:24
Done.
| |
| 2798 blink::WebPageVisibilityState visibilityState = | |
| 2799 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() | |
| 2800 : blink::WebPageVisibilityStateHidden; | |
| 2801 webview()->setVisibilityState(visibilityState, false); | |
| 2802 } | |
| 2798 } | 2803 } |
| 2799 | 2804 |
| 2800 void RenderViewImpl::OnWasShown(bool needs_repainting, | 2805 void RenderViewImpl::OnPageWasShown() { |
| 2801 const ui::LatencyInfo& latency_info) { | |
| 2802 RenderWidget::OnWasShown(needs_repainting, latency_info); | |
| 2803 | |
| 2804 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 2806 #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 2805 RenderThreadImpl::current()->video_capture_impl_manager()-> | 2807 RenderThreadImpl::current()->video_capture_impl_manager()-> |
| 2806 SuspendDevices(false); | 2808 SuspendDevices(false); |
| 2807 #endif | 2809 #endif |
| 2808 | 2810 |
| 2809 if (webview()) | 2811 if (webview()) { |
| 2810 webview()->setVisibilityState(visibilityState(), false); | 2812 blink::WebPageVisibilityState visibilityState = |
| 2813 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() | |
| 2814 : blink::WebPageVisibilityStateVisible; | |
| 2815 webview()->setVisibilityState(visibilityState, false); | |
| 2816 } | |
| 2811 } | 2817 } |
| 2812 | 2818 |
| 2813 GURL RenderViewImpl::GetURLForGraphicsContext3D() { | 2819 GURL RenderViewImpl::GetURLForGraphicsContext3D() { |
| 2814 DCHECK(webview()); | 2820 DCHECK(webview()); |
| 2815 if (webview()->mainFrame()->isWebLocalFrame()) | 2821 if (webview()->mainFrame()->isWebLocalFrame()) |
| 2816 return GURL(webview()->mainFrame()->document().url()); | 2822 return GURL(webview()->mainFrame()->document().url()); |
| 2817 else | 2823 else |
| 2818 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); | 2824 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); |
| 2819 } | 2825 } |
| 2820 | 2826 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3076 } | 3082 } |
| 3077 | 3083 |
| 3078 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { | 3084 double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
| 3079 return ZoomLevelToZoomFactor(zoom_level); | 3085 return ZoomLevelToZoomFactor(zoom_level); |
| 3080 } | 3086 } |
| 3081 | 3087 |
| 3082 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { | 3088 double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
| 3083 return ZoomFactorToZoomLevel(factor); | 3089 return ZoomFactorToZoomLevel(factor); |
| 3084 } | 3090 } |
| 3085 | 3091 |
| 3086 blink::WebPageVisibilityState RenderViewImpl::visibilityState() const { | |
| 3087 blink::WebPageVisibilityState current_state = is_hidden() ? | |
| 3088 blink::WebPageVisibilityStateHidden : | |
| 3089 blink::WebPageVisibilityStateVisible; | |
| 3090 blink::WebPageVisibilityState override_state = current_state; | |
| 3091 // TODO(jam): move this method to WebFrameClient. | |
| 3092 if (GetContentClient()->renderer()-> | |
| 3093 ShouldOverridePageVisibilityState(main_render_frame_, | |
| 3094 &override_state)) | |
| 3095 return override_state; | |
| 3096 return current_state; | |
| 3097 } | |
| 3098 | |
| 3099 void RenderViewImpl::draggableRegionsChanged() { | 3092 void RenderViewImpl::draggableRegionsChanged() { |
| 3100 FOR_EACH_OBSERVER( | 3093 FOR_EACH_OBSERVER( |
| 3101 RenderViewObserver, | 3094 RenderViewObserver, |
| 3102 observers_, | 3095 observers_, |
| 3103 DraggableRegionsChanged(webview()->mainFrame())); | 3096 DraggableRegionsChanged(webview()->mainFrame())); |
| 3104 } | 3097 } |
| 3105 | 3098 |
| 3106 void RenderViewImpl::pageImportanceSignalsChanged() { | 3099 void RenderViewImpl::pageImportanceSignalsChanged() { |
| 3107 if (!webview() || !main_render_frame_) | 3100 if (!webview() || !main_render_frame_) |
| 3108 return; | 3101 return; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3392 return render_frame->focused_pepper_plugin(); | 3385 return render_frame->focused_pepper_plugin(); |
| 3393 } | 3386 } |
| 3394 frame = frame->traverseNext(false); | 3387 frame = frame->traverseNext(false); |
| 3395 } | 3388 } |
| 3396 | 3389 |
| 3397 return nullptr; | 3390 return nullptr; |
| 3398 } | 3391 } |
| 3399 #endif | 3392 #endif |
| 3400 | 3393 |
| 3401 } // namespace content | 3394 } // namespace content |
| OLD | NEW |