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