OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 DCHECK(client); | 1551 DCHECK(client); |
1552 WebLocalFrameImpl* web_frame = new WebLocalFrameImpl( | 1552 WebLocalFrameImpl* web_frame = new WebLocalFrameImpl( |
1553 old_web_frame, client, interface_provider, interface_registry); | 1553 old_web_frame, client, interface_provider, interface_registry); |
1554 Frame* old_frame = ToWebRemoteFrameImpl(old_web_frame)->GetFrame(); | 1554 Frame* old_frame = ToWebRemoteFrameImpl(old_web_frame)->GetFrame(); |
1555 web_frame->SetParent(old_web_frame->Parent()); | 1555 web_frame->SetParent(old_web_frame->Parent()); |
1556 web_frame->SetOpener(old_web_frame->Opener()); | 1556 web_frame->SetOpener(old_web_frame->Opener()); |
1557 // Note: this *always* temporarily sets a frame owner, even for main frames! | 1557 // Note: this *always* temporarily sets a frame owner, even for main frames! |
1558 // When a core Frame is created with no owner, it attempts to set itself as | 1558 // When a core Frame is created with no owner, it attempts to set itself as |
1559 // the main frame of the Page. However, this is a provisional frame, and may | 1559 // the main frame of the Page. However, this is a provisional frame, and may |
1560 // disappear, so Page::m_mainFrame can't be updated just yet. | 1560 // disappear, so Page::m_mainFrame can't be updated just yet. |
1561 FrameOwner* temp_owner = DummyFrameOwner::Create(); | 1561 // Note 2: Becuase the dummy owner is still the owner when the initial empty |
1562 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to | 1562 // document is created, the initial empty document will not inherit the |
1563 // reuse it here. | 1563 // correct sandbox flags. However, since the provisional frame is inivisible |
1564 LocalFrame* frame = LocalFrame::Create( | 1564 // to the rest of the page, the initial document is also invisible and |
1565 web_frame->local_frame_client_impl_.Get(), *old_frame->GetPage(), | 1565 // unscriptable. Once the provisional frame gets properly attached and is |
1566 temp_owner, interface_provider, interface_registry); | 1566 // observable, it will have the real FrameOwner, and any subsequent real |
1567 frame->Tree().SetName( | 1567 // documents will correctly inherit sandbox flags from the owner. |
1568 ToWebRemoteFrameImpl(old_web_frame)->GetFrame()->Tree().GetName()); | 1568 web_frame->InitializeCoreFrame(*old_frame->GetPage(), |
1569 web_frame->SetCoreFrame(frame); | 1569 DummyFrameOwner::Create(), |
| 1570 old_frame->Tree().GetName()); |
1570 | 1571 |
1571 frame->SetOwner(old_frame->Owner()); | 1572 LocalFrame* new_frame = web_frame->GetFrame(); |
1572 | 1573 new_frame->SetOwner(old_frame->Owner()); |
1573 if (frame->Owner() && frame->Owner()->IsRemote()) | 1574 if (new_frame->Owner() && new_frame->Owner()->IsRemote()) { |
1574 ToRemoteFrameOwner(frame->Owner()) | 1575 ToRemoteFrameOwner(new_frame->Owner()) |
1575 ->SetSandboxFlags(static_cast<SandboxFlags>(flags)); | 1576 ->SetSandboxFlags(static_cast<SandboxFlags>(flags)); |
1576 | 1577 } |
1577 // We must call init() after m_frame is assigned because it is referenced | |
1578 // during init(). Note that this may dispatch JS events; the frame may be | |
1579 // detached after init() returns. | |
1580 frame->Init(); | |
1581 return web_frame; | 1578 return web_frame; |
1582 } | 1579 } |
1583 | 1580 |
1584 WebLocalFrameImpl::WebLocalFrameImpl( | 1581 WebLocalFrameImpl::WebLocalFrameImpl( |
1585 WebTreeScopeType scope, | 1582 WebTreeScopeType scope, |
1586 WebFrameClient* client, | 1583 WebFrameClient* client, |
1587 blink::InterfaceProvider* interface_provider, | 1584 blink::InterfaceProvider* interface_provider, |
1588 blink::InterfaceRegistry* interface_registry) | 1585 blink::InterfaceRegistry* interface_registry) |
1589 : WebLocalFrameBase(scope), | 1586 : WebLocalFrameBase(scope), |
1590 local_frame_client_impl_(LocalFrameClientImpl::Create(this)), | 1587 local_frame_client_impl_(LocalFrameClientImpl::Create(this)), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 | 1632 |
1636 void WebLocalFrameImpl::SetCoreFrame(LocalFrame* frame) { | 1633 void WebLocalFrameImpl::SetCoreFrame(LocalFrame* frame) { |
1637 frame_ = frame; | 1634 frame_ = frame; |
1638 } | 1635 } |
1639 | 1636 |
1640 void WebLocalFrameImpl::InitializeCoreFrame(Page& page, | 1637 void WebLocalFrameImpl::InitializeCoreFrame(Page& page, |
1641 FrameOwner* owner, | 1638 FrameOwner* owner, |
1642 const AtomicString& name) { | 1639 const AtomicString& name) { |
1643 SetCoreFrame(LocalFrame::Create(local_frame_client_impl_.Get(), page, owner, | 1640 SetCoreFrame(LocalFrame::Create(local_frame_client_impl_.Get(), page, owner, |
1644 interface_provider_, interface_registry_)); | 1641 interface_provider_, interface_registry_)); |
1645 GetFrame()->Tree().SetName(name); | 1642 frame_->Tree().SetName(name); |
1646 // We must call init() after m_frame is assigned because it is referenced | 1643 // We must call init() after frame_ is assigned because it is referenced |
1647 // during init(). Note that this may dispatch JS events; the frame may be | 1644 // during init(). |
1648 // detached after init() returns. | 1645 frame_->Init(); |
1649 GetFrame()->Init(); | 1646 CHECK(frame_); |
1650 if (GetFrame()) { | 1647 CHECK(frame_->Loader().StateMachine()->IsDisplayingInitialEmptyDocument()); |
1651 if (GetFrame() | 1648 if (!Parent() && !Opener() && |
1652 ->Loader() | 1649 frame_->GetSettings()->GetShouldReuseGlobalForUnownedMainFrame()) { |
1653 .StateMachine() | 1650 frame_->GetDocument()->GetSecurityOrigin()->GrantUniversalAccess(); |
1654 ->IsDisplayingInitialEmptyDocument() && | 1651 } |
1655 !Parent() && !Opener() && | |
1656 GetFrame()->GetSettings()->GetShouldReuseGlobalForUnownedMainFrame()) { | |
1657 GetFrame()->GetDocument()->GetSecurityOrigin()->GrantUniversalAccess(); | |
1658 } | |
1659 | 1652 |
1660 if (!owner) { | 1653 if (!owner) { |
1661 // This trace event is needed to detect the main frame of the | 1654 // This trace event is needed to detect the main frame of the |
1662 // renderer in telemetry metrics. See crbug.com/692112#c11. | 1655 // renderer in telemetry metrics. See crbug.com/692112#c11. |
1663 TRACE_EVENT_INSTANT1("loading", "markAsMainFrame", | 1656 TRACE_EVENT_INSTANT1("loading", "markAsMainFrame", TRACE_EVENT_SCOPE_THREAD, |
1664 TRACE_EVENT_SCOPE_THREAD, "frame", GetFrame()); | 1657 "frame", frame_); |
1665 } | |
1666 } | 1658 } |
1667 } | 1659 } |
1668 | 1660 |
1669 LocalFrame* WebLocalFrameImpl::CreateChildFrame( | 1661 LocalFrame* WebLocalFrameImpl::CreateChildFrame( |
1670 const FrameLoadRequest& request, | 1662 const FrameLoadRequest& request, |
1671 const AtomicString& name, | 1663 const AtomicString& name, |
1672 HTMLFrameOwnerElement* owner_element) { | 1664 HTMLFrameOwnerElement* owner_element) { |
1673 DCHECK(client_); | 1665 DCHECK(client_); |
1674 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe"); | 1666 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe"); |
1675 WebTreeScopeType scope = | 1667 WebTreeScopeType scope = |
(...skipping 15 matching lines...) Expand all Loading... |
1691 this, scope, name, | 1683 this, scope, name, |
1692 owner_element->getAttribute( | 1684 owner_element->getAttribute( |
1693 owner_element->SubResourceAttributeName()), | 1685 owner_element->SubResourceAttributeName()), |
1694 static_cast<WebSandboxFlags>(owner_element->GetSandboxFlags()), | 1686 static_cast<WebSandboxFlags>(owner_element->GetSandboxFlags()), |
1695 owner_element->ContainerPolicy(), owner_properties)); | 1687 owner_element->ContainerPolicy(), owner_properties)); |
1696 if (!webframe_child) | 1688 if (!webframe_child) |
1697 return nullptr; | 1689 return nullptr; |
1698 | 1690 |
1699 webframe_child->InitializeCoreFrame(*GetFrame()->GetPage(), owner_element, | 1691 webframe_child->InitializeCoreFrame(*GetFrame()->GetPage(), owner_element, |
1700 name); | 1692 name); |
1701 // Initializing the core frame may cause the new child to be detached, since | 1693 DCHECK(webframe_child->Parent()); |
1702 // it may dispatch a load event in the parent. | |
1703 if (!webframe_child->Parent()) | |
1704 return nullptr; | |
1705 | 1694 |
1706 FrameLoadRequest new_request = request; | 1695 FrameLoadRequest new_request = request; |
1707 FrameLoadType child_load_type = kFrameLoadTypeStandard; | 1696 FrameLoadType child_load_type = kFrameLoadTypeStandard; |
1708 HistoryItem* child_item = nullptr; | 1697 HistoryItem* child_item = nullptr; |
1709 | 1698 |
1710 if (!GetFrame()->GetDocument()->LoadEventFinished()) { | 1699 if (!GetFrame()->GetDocument()->LoadEventFinished()) { |
1711 FrameLoadType load_type = | 1700 FrameLoadType load_type = |
1712 GetFrame()->Loader().GetDocumentLoader()->LoadType(); | 1701 GetFrame()->Loader().GetDocumentLoader()->LoadType(); |
1713 switch (load_type) { | 1702 switch (load_type) { |
1714 case kFrameLoadTypeStandard: | 1703 case kFrameLoadTypeStandard: |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 TextCheckerClient& WebLocalFrameImpl::GetTextCheckerClient() const { | 2601 TextCheckerClient& WebLocalFrameImpl::GetTextCheckerClient() const { |
2613 return *text_checker_client_; | 2602 return *text_checker_client_; |
2614 } | 2603 } |
2615 | 2604 |
2616 void WebLocalFrameImpl::SetTextCheckClient( | 2605 void WebLocalFrameImpl::SetTextCheckClient( |
2617 WebTextCheckClient* text_check_client) { | 2606 WebTextCheckClient* text_check_client) { |
2618 text_check_client_ = text_check_client; | 2607 text_check_client_ = text_check_client; |
2619 } | 2608 } |
2620 | 2609 |
2621 } // namespace blink | 2610 } // namespace blink |
OLD | NEW |