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