OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/containers/hash_tables.h" | 10 #include "base/containers/hash_tables.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 OnDidAccessInitialDocument) | 543 OnDidAccessInitialDocument) |
544 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) | 544 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeOpener, OnDidChangeOpener) |
545 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName) | 545 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeName, OnDidChangeName) |
546 IPC_MESSAGE_HANDLER(FrameHostMsg_EnforceStrictMixedContentChecking, | 546 IPC_MESSAGE_HANDLER(FrameHostMsg_EnforceStrictMixedContentChecking, |
547 OnEnforceStrictMixedContentChecking) | 547 OnEnforceStrictMixedContentChecking) |
548 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId) | 548 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId) |
549 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags, | 549 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeSandboxFlags, |
550 OnDidChangeSandboxFlags) | 550 OnDidChangeSandboxFlags) |
551 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, | 551 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeFrameOwnerProperties, |
552 OnDidChangeFrameOwnerProperties) | 552 OnDidChangeFrameOwnerProperties) |
553 IPC_MESSAGE_HANDLER(FrameHostMsg_DidCancelLoadAfterXFrameOptionsOrCSPDenied, | |
554 OnDidCancelLoadAfterXFrameOptionsOrCSPDenied) | |
553 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) | 555 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) |
554 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) | 556 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) |
555 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, | 557 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, |
556 OnBeginNavigation) | 558 OnBeginNavigation) |
557 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) | 559 IPC_MESSAGE_HANDLER(FrameHostMsg_DispatchLoad, OnDispatchLoad) |
558 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, | 560 IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse, |
559 OnTextSurroundingSelectionResponse) | 561 OnTextSurroundingSelectionResponse) |
560 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | 562 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) |
561 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | 563 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
562 OnAccessibilityLocationChanges) | 564 OnAccessibilityLocationChanges) |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1509 // These properties only affect the RenderFrame and live in its parent | 1511 // These properties only affect the RenderFrame and live in its parent |
1510 // (HTMLFrameOwnerElement). Therefore, we do not need to notify this frame's | 1512 // (HTMLFrameOwnerElement). Therefore, we do not need to notify this frame's |
1511 // proxies. | 1513 // proxies. |
1512 RenderFrameHost* child_rfh = child->current_frame_host(); | 1514 RenderFrameHost* child_rfh = child->current_frame_host(); |
1513 if (child_rfh->GetSiteInstance() != GetSiteInstance()) { | 1515 if (child_rfh->GetSiteInstance() != GetSiteInstance()) { |
1514 child_rfh->Send(new FrameMsg_SetFrameOwnerProperties( | 1516 child_rfh->Send(new FrameMsg_SetFrameOwnerProperties( |
1515 child_rfh->GetRoutingID(), frame_owner_properties)); | 1517 child_rfh->GetRoutingID(), frame_owner_properties)); |
1516 } | 1518 } |
1517 } | 1519 } |
1518 | 1520 |
1521 void RenderFrameHostImpl::OnDidCancelLoadAfterXFrameOptionsOrCSPDenied() { | |
1522 // When a frame is blocked by X-Frame-Options or CSP frame-ancestors, the | |
1523 // (empty) blocked frame needs to get a unique origin, which ensures that it | |
1524 // appears as a normal cross-origin document, and is the desired behavior | |
1525 // according to spec: https://www.w3.org/TR/CSP2/#directive-frame-ancestors | |
1526 // This sets the unique origin on both the browser and renderer sides. The | |
1527 // IPC to renderer may be required when a cross-process subframe is blocked, | |
1528 // since the blocking currently occurs in the pending RenderFrame, but the | |
1529 // actual blocked (empty) frame will be left in the current RenderFrame in a | |
1530 // different process. | |
1531 // | |
1532 // TODO(mkwst, alexmos): This will probably be called directly rather than | |
1533 // from an renderer IPC once X-Frame-Options and CSP enforcement moves to the | |
1534 // browser process (https://crbug.com/555418). | |
1535 frame_tree_node_->SetCurrentOrigin(url::Origin()); | |
alexmos
2016/02/25 21:59:12
I think this matters in default Chrome even withou
Charlie Reis
2016/02/26 01:13:22
Acknowledged.
| |
1536 | |
1537 if (this == frame_tree_node_->render_manager()->pending_frame_host()) { | |
1538 RenderFrameHost* current_rfh = frame_tree_node_->current_frame_host(); | |
1539 current_rfh->Send(new FrameMsg_CancelLoadAfterXFrameOptionsOrCSPDenied( | |
1540 current_rfh->GetRoutingID())); | |
1541 } | |
1542 } | |
1543 | |
1519 void RenderFrameHostImpl::OnUpdateTitle( | 1544 void RenderFrameHostImpl::OnUpdateTitle( |
1520 const base::string16& title, | 1545 const base::string16& title, |
1521 blink::WebTextDirection title_direction) { | 1546 blink::WebTextDirection title_direction) { |
1522 // This message should only be sent for top-level frames. | 1547 // This message should only be sent for top-level frames. |
1523 if (frame_tree_node_->parent()) | 1548 if (frame_tree_node_->parent()) |
1524 return; | 1549 return; |
1525 | 1550 |
1526 if (title.length() > kMaxTitleChars) { | 1551 if (title.length() > kMaxTitleChars) { |
1527 NOTREACHED() << "Renderer sent too many characters in title."; | 1552 NOTREACHED() << "Renderer sent too many characters in title."; |
1528 return; | 1553 return; |
(...skipping 21 matching lines...) Expand all Loading... | |
1550 frame_tree_node(), validated_params, begin_params, body); | 1575 frame_tree_node(), validated_params, begin_params, body); |
1551 } | 1576 } |
1552 | 1577 |
1553 void RenderFrameHostImpl::OnDispatchLoad() { | 1578 void RenderFrameHostImpl::OnDispatchLoad() { |
1554 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 1579 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
1555 // Only frames with an out-of-process parent frame should be sending this | 1580 // Only frames with an out-of-process parent frame should be sending this |
1556 // message. | 1581 // message. |
1557 RenderFrameProxyHost* proxy = | 1582 RenderFrameProxyHost* proxy = |
1558 frame_tree_node()->render_manager()->GetProxyToParent(); | 1583 frame_tree_node()->render_manager()->GetProxyToParent(); |
1559 if (!proxy) { | 1584 if (!proxy) { |
1585 // A valid special case where the proxy won't exist occurs when a frame | |
1586 // gets blocked due to X-Frame-Options or CSP while it is still pending. | |
1587 // (The proxy in the parent isn't created until commit.) In that case, it | |
1588 // is ok to ignore this load event dispatch, since it will be done as part | |
1589 // of forwarding the blocked notification (see | |
1590 // FrameMsg_CancelLoadAfterXFrameOptionsOrCSPDenied). | |
1591 // | |
1592 // TODO(mkwst, alexmos): This won't be necessary once X-Frame-Options and | |
1593 // CSP enforcement moves to the browser process (https://crbug.com/555418). | |
1594 if (this != frame_tree_node_->current_frame_host()) | |
alexmos
2016/02/25 21:59:12
This is pretty ugly, but I tried to detect whether
Charlie Reis
2016/02/26 21:26:41
Acknowledged.
| |
1595 return; | |
1596 | |
1560 bad_message::ReceivedBadMessage(GetProcess(), | 1597 bad_message::ReceivedBadMessage(GetProcess(), |
1561 bad_message::RFH_NO_PROXY_TO_PARENT); | 1598 bad_message::RFH_NO_PROXY_TO_PARENT); |
1562 return; | 1599 return; |
1563 } | 1600 } |
1564 | |
1565 proxy->Send(new FrameMsg_DispatchLoad(proxy->GetRoutingID())); | 1601 proxy->Send(new FrameMsg_DispatchLoad(proxy->GetRoutingID())); |
1566 } | 1602 } |
1567 | 1603 |
1568 RenderWidgetHostViewBase* RenderFrameHostImpl::GetViewForAccessibility() { | 1604 RenderWidgetHostViewBase* RenderFrameHostImpl::GetViewForAccessibility() { |
1569 return static_cast<RenderWidgetHostViewBase*>( | 1605 return static_cast<RenderWidgetHostViewBase*>( |
1570 frame_tree_node_->IsMainFrame() | 1606 frame_tree_node_->IsMainFrame() |
1571 ? render_view_host_->GetWidget()->GetView() | 1607 ? render_view_host_->GetWidget()->GetView() |
1572 : frame_tree_node_->frame_tree() | 1608 : frame_tree_node_->frame_tree() |
1573 ->GetMainFrame() | 1609 ->GetMainFrame() |
1574 ->render_view_host_->GetWidget() | 1610 ->render_view_host_->GetWidget() |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2599 *dst = src; | 2635 *dst = src; |
2600 | 2636 |
2601 if (src.routing_id != -1) | 2637 if (src.routing_id != -1) |
2602 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); | 2638 dst->tree_id = RoutingIDToAXTreeID(src.routing_id); |
2603 | 2639 |
2604 if (src.parent_routing_id != -1) | 2640 if (src.parent_routing_id != -1) |
2605 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); | 2641 dst->parent_tree_id = RoutingIDToAXTreeID(src.parent_routing_id); |
2606 } | 2642 } |
2607 | 2643 |
2608 } // namespace content | 2644 } // namespace content |
OLD | NEW |