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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 #include "content/child/v8_value_converter_impl.h" | 45 #include "content/child/v8_value_converter_impl.h" |
46 #include "content/child/webmessageportchannel_impl.h" | 46 #include "content/child/webmessageportchannel_impl.h" |
47 #include "content/common/content_constants_internal.h" | 47 #include "content/common/content_constants_internal.h" |
48 #include "content/common/content_switches_internal.h" | 48 #include "content/common/content_switches_internal.h" |
49 #include "content/common/dom_storage/dom_storage_types.h" | 49 #include "content/common/dom_storage/dom_storage_types.h" |
50 #include "content/common/drag_messages.h" | 50 #include "content/common/drag_messages.h" |
51 #include "content/common/frame_messages.h" | 51 #include "content/common/frame_messages.h" |
52 #include "content/common/frame_replication_state.h" | 52 #include "content/common/frame_replication_state.h" |
53 #include "content/common/input_messages.h" | 53 #include "content/common/input_messages.h" |
54 #include "content/common/page_messages.h" | 54 #include "content/common/page_messages.h" |
| 55 #include "content/common/render_message_filter.mojom.h" |
55 #include "content/common/site_isolation_policy.h" | 56 #include "content/common/site_isolation_policy.h" |
56 #include "content/common/view_messages.h" | 57 #include "content/common/view_messages.h" |
57 #include "content/public/common/bindings_policy.h" | 58 #include "content/public/common/bindings_policy.h" |
58 #include "content/public/common/browser_side_navigation_policy.h" | 59 #include "content/public/common/browser_side_navigation_policy.h" |
59 #include "content/public/common/content_client.h" | 60 #include "content/public/common/content_client.h" |
60 #include "content/public/common/content_constants.h" | 61 #include "content/public/common/content_constants.h" |
61 #include "content/public/common/content_switches.h" | 62 #include "content/public/common/content_switches.h" |
62 #include "content/public/common/drop_data.h" | 63 #include "content/public/common/drop_data.h" |
63 #include "content/public/common/favicon_url.h" | 64 #include "content/public/common/favicon_url.h" |
64 #include "content/public/common/page_importance_signals.h" | 65 #include "content/public/common/page_importance_signals.h" |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 } | 1497 } |
1497 | 1498 |
1498 // blink::WebViewClient ------------------------------------------------------ | 1499 // blink::WebViewClient ------------------------------------------------------ |
1499 | 1500 |
1500 WebView* RenderViewImpl::createView(WebLocalFrame* creator, | 1501 WebView* RenderViewImpl::createView(WebLocalFrame* creator, |
1501 const WebURLRequest& request, | 1502 const WebURLRequest& request, |
1502 const WebWindowFeatures& features, | 1503 const WebWindowFeatures& features, |
1503 const WebString& frame_name, | 1504 const WebString& frame_name, |
1504 WebNavigationPolicy policy, | 1505 WebNavigationPolicy policy, |
1505 bool suppress_opener) { | 1506 bool suppress_opener) { |
1506 ViewHostMsg_CreateWindow_Params params; | 1507 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); |
1507 params.opener_id = GetRoutingID(); | 1508 params->opener_id = GetRoutingID(); |
1508 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 1509 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
1509 if (GetContentClient()->renderer()->AllowPopup()) | 1510 if (GetContentClient()->renderer()->AllowPopup()) |
1510 params.user_gesture = true; | 1511 params->user_gesture = true; |
1511 params.window_container_type = WindowFeaturesToContainerType(features); | 1512 params->window_container_type = WindowFeaturesToContainerType(features); |
1512 params.session_storage_namespace_id = session_storage_namespace_id_; | 1513 params->session_storage_namespace_id = session_storage_namespace_id_; |
1513 if (frame_name != "_blank") | 1514 if (frame_name != "_blank") |
1514 params.frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); | 1515 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); |
1515 params.opener_render_frame_id = | 1516 params->opener_render_frame_id = |
1516 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID(); | 1517 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID(); |
1517 params.opener_url = creator->document().url(); | 1518 params->opener_url = creator->document().url(); |
1518 | 1519 |
1519 // The browser process uses the top frame's URL for a content settings check | 1520 // The browser process uses the top frame's URL for a content settings check |
1520 // to determine whether the popup is allowed. If the top frame is remote, | 1521 // to determine whether the popup is allowed. If the top frame is remote, |
1521 // its URL is not available, so use its replicated origin instead. | 1522 // its URL is not available, so use its replicated origin instead. |
1522 // | 1523 // |
1523 // TODO(alexmos): This works fine for regular origins but may break path | 1524 // TODO(alexmos): This works fine for regular origins but may break path |
1524 // matching for file URLs with OOP subframes that open popups. This should | 1525 // matching for file URLs with OOP subframes that open popups. This should |
1525 // be fixed by either moving this lookup to the browser process or removing | 1526 // be fixed by either moving this lookup to the browser process or removing |
1526 // path-based matching for file URLs from content settings. See | 1527 // path-based matching for file URLs from content settings. See |
1527 // https://crbug.com/466297. | 1528 // https://crbug.com/466297. |
1528 if (creator->top()->isWebLocalFrame()) { | 1529 if (creator->top()->isWebLocalFrame()) { |
1529 params.opener_top_level_frame_url = creator->top()->document().url(); | 1530 params->opener_top_level_frame_url = creator->top()->document().url(); |
1530 } else { | 1531 } else { |
1531 params.opener_top_level_frame_url = | 1532 params->opener_top_level_frame_url = |
1532 blink::WebStringToGURL(creator->top()->getSecurityOrigin().toString()); | 1533 blink::WebStringToGURL(creator->top()->getSecurityOrigin().toString()); |
1533 } | 1534 } |
1534 | 1535 |
1535 GURL security_url(blink::WebStringToGURL( | 1536 GURL security_url(blink::WebStringToGURL( |
1536 creator->document().getSecurityOrigin().toString())); | 1537 creator->document().getSecurityOrigin().toString())); |
1537 if (!security_url.is_valid()) | 1538 if (!security_url.is_valid()) |
1538 security_url = GURL(); | 1539 security_url = GURL(); |
1539 params.opener_security_origin = security_url; | 1540 params->opener_security_origin = security_url; |
1540 params.opener_suppressed = suppress_opener; | 1541 params->opener_suppressed = suppress_opener; |
1541 params.disposition = NavigationPolicyToDisposition(policy); | 1542 params->disposition = NavigationPolicyToDisposition(policy); |
1542 if (!request.isNull()) { | 1543 if (!request.isNull()) { |
1543 params.target_url = request.url(); | 1544 params->target_url = request.url(); |
1544 params.referrer = GetReferrerFromRequest(creator, request); | 1545 params->referrer = GetReferrerFromRequest(creator, request); |
1545 } | 1546 } |
1546 params.features = features; | 1547 params->features = features; |
1547 | 1548 |
1548 for (size_t i = 0; i < features.additionalFeatures.size(); ++i) | 1549 // We preserve this information before sending the message since |params| is |
1549 params.additional_features.push_back(features.additionalFeatures[i]); | 1550 // moved on send. |
| 1551 bool is_background_tab = |
| 1552 params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB; |
| 1553 bool opened_by_user_gesture = params->user_gesture; |
1550 | 1554 |
1551 ViewHostMsg_CreateWindow_Reply reply; | 1555 mojom::CreateNewWindowReplyPtr reply; |
1552 RenderThread::Get()->Send(new ViewHostMsg_CreateWindow(params, &reply)); | 1556 RenderThreadImpl::current_render_message_filter()->CreateNewWindow( |
1553 if (reply.route_id == MSG_ROUTING_NONE) | 1557 std::move(params), &reply); |
1554 return NULL; | 1558 if (reply->route_id == MSG_ROUTING_NONE) |
| 1559 return nullptr; |
1555 | 1560 |
1556 WebUserGestureIndicator::consumeUserGesture(); | 1561 WebUserGestureIndicator::consumeUserGesture(); |
1557 | 1562 |
1558 // While this view may be a background extension page, it can spawn a visible | 1563 // While this view may be a background extension page, it can spawn a visible |
1559 // render view. So we just assume that the new one is not another background | 1564 // render view. So we just assume that the new one is not another background |
1560 // page instead of passing on our own value. | 1565 // page instead of passing on our own value. |
1561 // TODO(vangelis): Can we tell if the new view will be a background page? | 1566 // TODO(vangelis): Can we tell if the new view will be a background page? |
1562 bool never_visible = false; | 1567 bool never_visible = false; |
1563 | 1568 |
1564 ResizeParams initial_size = ResizeParams(); | 1569 ResizeParams initial_size = ResizeParams(); |
1565 initial_size.screen_info = screen_info_; | 1570 initial_size.screen_info = screen_info_; |
1566 | 1571 |
1567 // 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 |
1568 // 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 |
1569 // 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 |
1570 // 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 |
1571 // disagrees. | 1576 // disagrees. |
1572 ViewMsg_New_Params view_params; | 1577 ViewMsg_New_Params view_params; |
1573 | 1578 |
1574 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); | 1579 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
1575 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); | 1580 view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
1576 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); | 1581 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); |
1577 | 1582 |
1578 view_params.window_was_created_with_opener = true; | 1583 view_params.window_was_created_with_opener = true; |
1579 view_params.renderer_preferences = renderer_preferences_; | 1584 view_params.renderer_preferences = renderer_preferences_; |
1580 view_params.web_preferences = webkit_preferences_; | 1585 view_params.web_preferences = webkit_preferences_; |
1581 view_params.view_id = reply.route_id; | 1586 view_params.view_id = reply->route_id; |
1582 view_params.main_frame_routing_id = reply.main_frame_route_id; | 1587 view_params.main_frame_routing_id = reply->main_frame_route_id; |
1583 view_params.main_frame_widget_routing_id = reply.main_frame_widget_route_id; | 1588 view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id; |
1584 view_params.session_storage_namespace_id = | 1589 view_params.session_storage_namespace_id = |
1585 reply.cloned_session_storage_namespace_id; | 1590 reply->cloned_session_storage_namespace_id; |
1586 view_params.swapped_out = false; | 1591 view_params.swapped_out = false; |
1587 // WebCore will take care of setting the correct name. | 1592 // WebCore will take care of setting the correct name. |
1588 view_params.replicated_frame_state = FrameReplicationState(); | 1593 view_params.replicated_frame_state = FrameReplicationState(); |
1589 view_params.hidden = | 1594 view_params.hidden = is_background_tab; |
1590 (params.disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB); | |
1591 view_params.never_visible = never_visible; | 1595 view_params.never_visible = never_visible; |
1592 view_params.next_page_id = 1; | 1596 view_params.next_page_id = 1; |
1593 view_params.initial_size = initial_size; | 1597 view_params.initial_size = initial_size; |
1594 view_params.enable_auto_resize = false; | 1598 view_params.enable_auto_resize = false; |
1595 view_params.min_size = gfx::Size(); | 1599 view_params.min_size = gfx::Size(); |
1596 view_params.max_size = gfx::Size(); | 1600 view_params.max_size = gfx::Size(); |
1597 view_params.page_zoom_level = page_zoom_level_; | 1601 view_params.page_zoom_level = page_zoom_level_; |
1598 | 1602 |
1599 RenderViewImpl* view = | 1603 RenderViewImpl* view = |
1600 RenderViewImpl::Create(compositor_deps_, view_params, true); | 1604 RenderViewImpl::Create(compositor_deps_, view_params, true); |
1601 view->opened_by_user_gesture_ = params.user_gesture; | 1605 view->opened_by_user_gesture_ = opened_by_user_gesture; |
1602 | 1606 |
1603 return view->webview(); | 1607 return view->webview(); |
1604 } | 1608 } |
1605 | 1609 |
1606 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { | 1610 WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
1607 RenderWidget* widget = RenderWidget::Create(GetRoutingID(), compositor_deps_, | 1611 RenderWidget* widget = RenderWidget::Create(GetRoutingID(), compositor_deps_, |
1608 popup_type, screen_info_); | 1612 popup_type, screen_info_); |
1609 if (!widget) | 1613 if (!widget) |
1610 return NULL; | 1614 return NULL; |
1611 if (screen_metrics_emulator_) { | 1615 if (screen_metrics_emulator_) { |
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3013 if (IsUseZoomForDSFEnabled()) { | 3017 if (IsUseZoomForDSFEnabled()) { |
3014 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3018 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
3015 } else { | 3019 } else { |
3016 webview()->setDeviceScaleFactor(device_scale_factor_); | 3020 webview()->setDeviceScaleFactor(device_scale_factor_); |
3017 } | 3021 } |
3018 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3022 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3019 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3023 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
3020 } | 3024 } |
3021 | 3025 |
3022 } // namespace content | 3026 } // namespace content |
OLD | NEW |