Chromium Code Reviews| 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 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1552 DCHECK(client); | 1552 DCHECK(client); |
| 1553 WebLocalFrameImpl* web_frame = new WebLocalFrameImpl( | 1553 WebLocalFrameImpl* web_frame = new WebLocalFrameImpl( |
| 1554 old_web_frame, client, interface_provider, interface_registry); | 1554 old_web_frame, client, interface_provider, interface_registry); |
| 1555 Frame* old_frame = ToWebRemoteFrameImpl(old_web_frame)->GetFrame(); | 1555 Frame* old_frame = ToWebRemoteFrameImpl(old_web_frame)->GetFrame(); |
| 1556 web_frame->SetParent(old_web_frame->Parent()); | 1556 web_frame->SetParent(old_web_frame->Parent()); |
| 1557 web_frame->SetOpener(old_web_frame->Opener()); | 1557 web_frame->SetOpener(old_web_frame->Opener()); |
| 1558 // Note: this *always* temporarily sets a frame owner, even for main frames! | 1558 // Note: this *always* temporarily sets a frame owner, even for main frames! |
| 1559 // When a core Frame is created with no owner, it attempts to set itself as | 1559 // When a core Frame is created with no owner, it attempts to set itself as |
| 1560 // the main frame of the Page. However, this is a provisional frame, and may | 1560 // the main frame of the Page. However, this is a provisional frame, and may |
| 1561 // disappear, so Page::m_mainFrame can't be updated just yet. | 1561 // disappear, so Page::m_mainFrame can't be updated just yet. |
| 1562 FrameOwner* temp_owner = DummyFrameOwner::Create(); | 1562 web_frame->InitializeCoreFrame(*old_frame->GetPage(), |
| 1563 // TODO(dcheng): This block is very similar to initializeCoreFrame. Try to | 1563 DummyFrameOwner::Create(), |
|
Nate Chapin
2017/05/10 16:33:20
InitializeCoreFrame() does a couple of things Crea
dcheng
2017/05/11 21:36:25
I think my main concern with structuring it this w
dcheng
2017/05/12 18:06:38
Btw, I talked with Alex about this, and I think it
Nate Chapin
2017/05/12 19:52:28
Done.
| |
| 1564 // reuse it here. | 1564 old_frame->Tree().GetName()); |
| 1565 LocalFrame* frame = LocalFrame::Create( | |
| 1566 web_frame->local_frame_client_impl_.Get(), *old_frame->GetPage(), | |
| 1567 temp_owner, interface_provider, interface_registry); | |
| 1568 frame->Tree().SetName( | |
| 1569 ToWebRemoteFrameImpl(old_web_frame)->GetFrame()->Tree().GetName()); | |
| 1570 web_frame->SetCoreFrame(frame); | |
| 1571 | 1565 |
| 1572 frame->SetOwner(old_frame->Owner()); | 1566 LocalFrame* new_frame = web_frame->GetFrame(); |
| 1573 | 1567 new_frame->SetOwner(old_frame->Owner()); |
| 1574 if (frame->Owner() && frame->Owner()->IsRemote()) | 1568 if (new_frame->Owner() && new_frame->Owner()->IsRemote()) { |
| 1575 ToRemoteFrameOwner(frame->Owner()) | 1569 ToRemoteFrameOwner(new_frame->Owner()) |
| 1576 ->SetSandboxFlags(static_cast<SandboxFlags>(flags)); | 1570 ->SetSandboxFlags(static_cast<SandboxFlags>(flags)); |
| 1577 | 1571 } |
| 1578 // We must call init() after m_frame is assigned because it is referenced | |
| 1579 // during init(). Note that this may dispatch JS events; the frame may be | |
| 1580 // detached after init() returns. | |
| 1581 frame->Init(); | |
| 1582 return web_frame; | 1572 return web_frame; |
| 1583 } | 1573 } |
| 1584 | 1574 |
| 1585 WebLocalFrameImpl::WebLocalFrameImpl( | 1575 WebLocalFrameImpl::WebLocalFrameImpl( |
| 1586 WebTreeScopeType scope, | 1576 WebTreeScopeType scope, |
| 1587 WebFrameClient* client, | 1577 WebFrameClient* client, |
| 1588 blink::InterfaceProvider* interface_provider, | 1578 blink::InterfaceProvider* interface_provider, |
| 1589 blink::InterfaceRegistry* interface_registry) | 1579 blink::InterfaceRegistry* interface_registry) |
| 1590 : WebLocalFrameBase(scope), | 1580 : WebLocalFrameBase(scope), |
| 1591 local_frame_client_impl_(LocalFrameClientImpl::Create(this)), | 1581 local_frame_client_impl_(LocalFrameClientImpl::Create(this)), |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1634 | 1624 |
| 1635 void WebLocalFrameImpl::SetCoreFrame(LocalFrame* frame) { | 1625 void WebLocalFrameImpl::SetCoreFrame(LocalFrame* frame) { |
| 1636 frame_ = frame; | 1626 frame_ = frame; |
| 1637 } | 1627 } |
| 1638 | 1628 |
| 1639 void WebLocalFrameImpl::InitializeCoreFrame(Page& page, | 1629 void WebLocalFrameImpl::InitializeCoreFrame(Page& page, |
| 1640 FrameOwner* owner, | 1630 FrameOwner* owner, |
| 1641 const AtomicString& name) { | 1631 const AtomicString& name) { |
| 1642 SetCoreFrame(LocalFrame::Create(local_frame_client_impl_.Get(), page, owner, | 1632 SetCoreFrame(LocalFrame::Create(local_frame_client_impl_.Get(), page, owner, |
| 1643 interface_provider_, interface_registry_)); | 1633 interface_provider_, interface_registry_)); |
| 1644 GetFrame()->Tree().SetName(name); | 1634 GetFrame()->Tree().SetName(name); |
|
dcheng
2017/05/11 21:36:25
frame_ here as well for consistency?
Nate Chapin
2017/05/12 19:52:28
Done.
| |
| 1645 // We must call init() after m_frame is assigned because it is referenced | 1635 // We must call init() after frame_ is assigned because it is referenced |
| 1646 // during init(). Note that this may dispatch JS events; the frame may be | 1636 // during init(). |
| 1647 // detached after init() returns. | 1637 frame_->Init(); |
| 1648 GetFrame()->Init(); | 1638 CHECK(frame_); |
| 1649 if (GetFrame()) { | 1639 CHECK(frame_->Loader().StateMachine()->IsDisplayingInitialEmptyDocument()); |
|
Nate Chapin
2017/05/10 16:33:20
CHECK might be overkill here, but given that risk
| |
| 1650 if (GetFrame() | 1640 if (!Parent() && !Opener() && |
| 1651 ->Loader() | 1641 frame_->GetSettings()->GetShouldReuseGlobalForUnownedMainFrame()) { |
| 1652 .StateMachine() | 1642 frame_->GetDocument()->GetSecurityOrigin()->GrantUniversalAccess(); |
| 1653 ->IsDisplayingInitialEmptyDocument() && | 1643 } |
| 1654 !Parent() && !Opener() && | |
| 1655 GetFrame()->GetSettings()->GetShouldReuseGlobalForUnownedMainFrame()) { | |
| 1656 GetFrame()->GetDocument()->GetSecurityOrigin()->GrantUniversalAccess(); | |
| 1657 } | |
| 1658 | 1644 |
| 1659 if (!owner) { | 1645 if (!owner) { |
| 1660 // This trace event is needed to detect the main frame of the | 1646 // This trace event is needed to detect the main frame of the |
| 1661 // renderer in telemetry metrics. See crbug.com/692112#c11. | 1647 // renderer in telemetry metrics. See crbug.com/692112#c11. |
| 1662 TRACE_EVENT_INSTANT1("loading", "markAsMainFrame", | 1648 TRACE_EVENT_INSTANT1("loading", "markAsMainFrame", TRACE_EVENT_SCOPE_THREAD, |
| 1663 TRACE_EVENT_SCOPE_THREAD, "frame", GetFrame()); | 1649 "frame", frame_); |
| 1664 } | |
| 1665 } | 1650 } |
| 1666 } | 1651 } |
| 1667 | 1652 |
| 1668 LocalFrame* WebLocalFrameImpl::CreateChildFrame( | 1653 LocalFrame* WebLocalFrameImpl::CreateChildFrame( |
| 1669 const FrameLoadRequest& request, | 1654 const FrameLoadRequest& request, |
| 1670 const AtomicString& name, | 1655 const AtomicString& name, |
| 1671 HTMLFrameOwnerElement* owner_element) { | 1656 HTMLFrameOwnerElement* owner_element) { |
| 1672 DCHECK(client_); | 1657 DCHECK(client_); |
| 1673 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe"); | 1658 TRACE_EVENT0("blink", "WebLocalFrameImpl::createChildframe"); |
| 1674 WebTreeScopeType scope = | 1659 WebTreeScopeType scope = |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1690 this, scope, name, | 1675 this, scope, name, |
| 1691 owner_element->getAttribute( | 1676 owner_element->getAttribute( |
| 1692 owner_element->SubResourceAttributeName()), | 1677 owner_element->SubResourceAttributeName()), |
| 1693 static_cast<WebSandboxFlags>(owner_element->GetSandboxFlags()), | 1678 static_cast<WebSandboxFlags>(owner_element->GetSandboxFlags()), |
| 1694 owner_element->ContainerPolicy(), owner_properties)); | 1679 owner_element->ContainerPolicy(), owner_properties)); |
| 1695 if (!webframe_child) | 1680 if (!webframe_child) |
| 1696 return nullptr; | 1681 return nullptr; |
| 1697 | 1682 |
| 1698 webframe_child->InitializeCoreFrame(*GetFrame()->GetPage(), owner_element, | 1683 webframe_child->InitializeCoreFrame(*GetFrame()->GetPage(), owner_element, |
| 1699 name); | 1684 name); |
| 1700 // Initializing the core frame may cause the new child to be detached, since | 1685 DCHECK(webframe_child->Parent()); |
| 1701 // it may dispatch a load event in the parent. | |
| 1702 if (!webframe_child->Parent()) | |
| 1703 return nullptr; | |
| 1704 | 1686 |
| 1705 // If we're moving in the back/forward list, we might want to replace the | 1687 // If we're moving in the back/forward list, we might want to replace the |
| 1706 // content of this child frame with whatever was there at that point. | 1688 // content of this child frame with whatever was there at that point. |
| 1707 HistoryItem* child_item = nullptr; | 1689 HistoryItem* child_item = nullptr; |
| 1708 if (IsBackForwardLoadType( | 1690 if (IsBackForwardLoadType( |
| 1709 GetFrame()->Loader().GetDocumentLoader()->LoadType()) && | 1691 GetFrame()->Loader().GetDocumentLoader()->LoadType()) && |
| 1710 !GetFrame()->GetDocument()->LoadEventFinished()) | 1692 !GetFrame()->GetDocument()->LoadEventFinished()) |
| 1711 child_item = webframe_child->Client()->HistoryItemForNewChildFrame(); | 1693 child_item = webframe_child->Client()->HistoryItemForNewChildFrame(); |
| 1712 | 1694 |
| 1713 FrameLoadRequest new_request = request; | 1695 FrameLoadRequest new_request = request; |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2576 TextCheckerClient& WebLocalFrameImpl::GetTextCheckerClient() const { | 2558 TextCheckerClient& WebLocalFrameImpl::GetTextCheckerClient() const { |
| 2577 return *text_checker_client_; | 2559 return *text_checker_client_; |
| 2578 } | 2560 } |
| 2579 | 2561 |
| 2580 void WebLocalFrameImpl::SetTextCheckClient( | 2562 void WebLocalFrameImpl::SetTextCheckClient( |
| 2581 WebTextCheckClient* text_check_client) { | 2563 WebTextCheckClient* text_check_client) { |
| 2582 text_check_client_ = text_check_client; | 2564 text_check_client_ = text_check_client; |
| 2583 } | 2565 } |
| 2584 | 2566 |
| 2585 } // namespace blink | 2567 } // namespace blink |
| OLD | NEW |