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