| 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 const int kDelaySecondsForContentStateSync = 1; | 286 const int kDelaySecondsForContentStateSync = 1; |
| 287 | 287 |
| 288 #if defined(OS_ANDROID) | 288 #if defined(OS_ANDROID) |
| 289 // Delay between tapping in content and launching the associated android intent. | 289 // Delay between tapping in content and launching the associated android intent. |
| 290 // Used to allow users see what has been recognized as content. | 290 // Used to allow users see what has been recognized as content. |
| 291 const size_t kContentIntentDelayMilliseconds = 700; | 291 const size_t kContentIntentDelayMilliseconds = 700; |
| 292 #endif | 292 #endif |
| 293 | 293 |
| 294 static RenderViewImpl* (*g_create_render_view_impl)( | 294 static RenderViewImpl* (*g_create_render_view_impl)( |
| 295 CompositorDependencies* compositor_deps, | 295 CompositorDependencies* compositor_deps, |
| 296 const ViewMsg_New_Params&) = nullptr; | 296 const mojom::CreateViewParams&) = nullptr; |
| 297 | 297 |
| 298 // static | 298 // static |
| 299 Referrer RenderViewImpl::GetReferrerFromRequest( | 299 Referrer RenderViewImpl::GetReferrerFromRequest( |
| 300 WebFrame* frame, | 300 WebFrame* frame, |
| 301 const WebURLRequest& request) { | 301 const WebURLRequest& request) { |
| 302 return Referrer( | 302 return Referrer( |
| 303 blink::WebStringToGURL(request.httpHeaderField( | 303 blink::WebStringToGURL(request.httpHeaderField( |
| 304 WebString::fromUTF8("Referer"))), | 304 WebString::fromUTF8("Referer"))), |
| 305 request.referrerPolicy()); | 305 request.referrerPolicy()); |
| 306 } | 306 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 653 |
| 654 int64_t TraceId() const override { return latency_info_.trace_id(); } | 654 int64_t TraceId() const override { return latency_info_.trace_id(); } |
| 655 | 655 |
| 656 private: | 656 private: |
| 657 ui::LatencyInfo latency_info_; | 657 ui::LatencyInfo latency_info_; |
| 658 }; | 658 }; |
| 659 | 659 |
| 660 } // namespace | 660 } // namespace |
| 661 | 661 |
| 662 RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, | 662 RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, |
| 663 const ViewMsg_New_Params& params) | 663 const mojom::CreateViewParams& params) |
| 664 : RenderWidget(compositor_deps, | 664 : RenderWidget(compositor_deps, |
| 665 blink::WebPopupTypeNone, | 665 blink::WebPopupTypeNone, |
| 666 params.initial_size.screen_info, | 666 params.initial_size.screen_info, |
| 667 params.swapped_out, | 667 params.swapped_out, |
| 668 params.hidden, | 668 params.hidden, |
| 669 params.never_visible), | 669 params.never_visible), |
| 670 webkit_preferences_(params.web_preferences), | 670 webkit_preferences_(params.web_preferences), |
| 671 send_content_state_immediately_(false), | 671 send_content_state_immediately_(false), |
| 672 enabled_bindings_(0), | 672 enabled_bindings_(0), |
| 673 send_preferred_size_changes_(false), | 673 send_preferred_size_changes_(false), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 693 speech_recognition_dispatcher_(NULL), | 693 speech_recognition_dispatcher_(NULL), |
| 694 #if defined(OS_ANDROID) | 694 #if defined(OS_ANDROID) |
| 695 expected_content_intent_id_(0), | 695 expected_content_intent_id_(0), |
| 696 #endif | 696 #endif |
| 697 enumeration_completion_id_(0), | 697 enumeration_completion_id_(0), |
| 698 session_storage_namespace_id_(params.session_storage_namespace_id), | 698 session_storage_namespace_id_(params.session_storage_namespace_id), |
| 699 has_added_input_handler_(false) { | 699 has_added_input_handler_(false) { |
| 700 GetWidget()->set_owner_delegate(this); | 700 GetWidget()->set_owner_delegate(this); |
| 701 } | 701 } |
| 702 | 702 |
| 703 void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, | 703 void RenderViewImpl::Initialize(const mojom::CreateViewParams& params, |
| 704 bool was_created_by_renderer) { | 704 bool was_created_by_renderer) { |
| 705 SetRoutingID(params.view_id); | 705 SetRoutingID(params.view_id); |
| 706 | 706 |
| 707 int opener_view_routing_id; | 707 int opener_view_routing_id; |
| 708 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( | 708 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( |
| 709 params.opener_frame_route_id, &opener_view_routing_id); | 709 params.opener_frame_route_id, &opener_view_routing_id); |
| 710 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) | 710 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) |
| 711 opener_id_ = opener_view_routing_id; | 711 opener_id_ = opener_view_routing_id; |
| 712 | 712 |
| 713 display_mode_ = params.initial_size.display_mode; | 713 display_mode_ = params.initial_size.display_mode; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 web_view->setMaximumLegibleScale(prefs.default_maximum_page_scale_factor); | 1182 web_view->setMaximumLegibleScale(prefs.default_maximum_page_scale_factor); |
| 1183 #endif | 1183 #endif |
| 1184 | 1184 |
| 1185 #if defined(OS_WIN) | 1185 #if defined(OS_WIN) |
| 1186 WebRuntimeFeatures::enableMiddleClickAutoscroll(true); | 1186 WebRuntimeFeatures::enableMiddleClickAutoscroll(true); |
| 1187 #endif | 1187 #endif |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 /*static*/ | 1190 /*static*/ |
| 1191 RenderViewImpl* RenderViewImpl::Create(CompositorDependencies* compositor_deps, | 1191 RenderViewImpl* RenderViewImpl::Create(CompositorDependencies* compositor_deps, |
| 1192 const ViewMsg_New_Params& params, | 1192 const mojom::CreateViewParams& params, |
| 1193 bool was_created_by_renderer) { | 1193 bool was_created_by_renderer) { |
| 1194 DCHECK(params.view_id != MSG_ROUTING_NONE); | 1194 DCHECK(params.view_id != MSG_ROUTING_NONE); |
| 1195 RenderViewImpl* render_view = NULL; | 1195 RenderViewImpl* render_view = NULL; |
| 1196 if (g_create_render_view_impl) | 1196 if (g_create_render_view_impl) |
| 1197 render_view = g_create_render_view_impl(compositor_deps, params); | 1197 render_view = g_create_render_view_impl(compositor_deps, params); |
| 1198 else | 1198 else |
| 1199 render_view = new RenderViewImpl(compositor_deps, params); | 1199 render_view = new RenderViewImpl(compositor_deps, params); |
| 1200 | 1200 |
| 1201 render_view->Initialize(params, was_created_by_renderer); | 1201 render_view->Initialize(params, was_created_by_renderer); |
| 1202 return render_view; | 1202 return render_view; |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 // static | 1205 // static |
| 1206 void RenderViewImpl::InstallCreateHook(RenderViewImpl* ( | 1206 void RenderViewImpl::InstallCreateHook(RenderViewImpl* ( |
| 1207 *create_render_view_impl)(CompositorDependencies* compositor_deps, | 1207 *create_render_view_impl)(CompositorDependencies* compositor_deps, |
| 1208 const ViewMsg_New_Params&)) { | 1208 const mojom::CreateViewParams&)) { |
| 1209 CHECK(!g_create_render_view_impl); | 1209 CHECK(!g_create_render_view_impl); |
| 1210 g_create_render_view_impl = create_render_view_impl; | 1210 g_create_render_view_impl = create_render_view_impl; |
| 1211 } | 1211 } |
| 1212 | 1212 |
| 1213 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { | 1213 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
| 1214 observers_.AddObserver(observer); | 1214 observers_.AddObserver(observer); |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { | 1217 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 1218 observer->RenderViewGone(); | 1218 observer->RenderViewGone(); |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1567 bool never_visible = false; | 1567 bool never_visible = false; |
| 1568 | 1568 |
| 1569 ResizeParams initial_size = ResizeParams(); | 1569 ResizeParams initial_size = ResizeParams(); |
| 1570 initial_size.screen_info = screen_info_; | 1570 initial_size.screen_info = screen_info_; |
| 1571 | 1571 |
| 1572 // The initial hidden state for the RenderViewImpl here has to match what the | 1572 // The initial hidden state for the RenderViewImpl here has to match what the |
| 1573 // browser will eventually decide for the given disposition. Since we have to | 1573 // browser will eventually decide for the given disposition. Since we have to |
| 1574 // return from this call synchronously, we just have to make our best guess | 1574 // return from this call synchronously, we just have to make our best guess |
| 1575 // and rely on the browser sending a WasHidden / WasShown message if it | 1575 // and rely on the browser sending a WasHidden / WasShown message if it |
| 1576 // disagrees. | 1576 // disagrees. |
| 1577 ViewMsg_New_Params view_params; | 1577 mojom::CreateViewParams view_params; |
| 1578 | 1578 |
| 1579 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); | 1579 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
| 1580 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); | 1580 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
| 1581 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); | 1581 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); |
| 1582 | 1582 |
| 1583 view_params.window_was_created_with_opener = true; | 1583 view_params.window_was_created_with_opener = true; |
| 1584 view_params.renderer_preferences = renderer_preferences_; | 1584 view_params.renderer_preferences = renderer_preferences_; |
| 1585 view_params.web_preferences = webkit_preferences_; | 1585 view_params.web_preferences = webkit_preferences_; |
| 1586 view_params.view_id = reply->route_id; | 1586 view_params.view_id = reply->route_id; |
| 1587 view_params.main_frame_routing_id = reply->main_frame_route_id; | 1587 view_params.main_frame_routing_id = reply->main_frame_route_id; |
| (...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3018 if (IsUseZoomForDSFEnabled()) { | 3018 if (IsUseZoomForDSFEnabled()) { |
| 3019 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3019 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
| 3020 } else { | 3020 } else { |
| 3021 webview()->setDeviceScaleFactor(device_scale_factor_); | 3021 webview()->setDeviceScaleFactor(device_scale_factor_); |
| 3022 } | 3022 } |
| 3023 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3023 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 3024 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3024 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
| 3025 } | 3025 } |
| 3026 | 3026 |
| 3027 } // namespace content | 3027 } // namespace content |
| OLD | NEW |