| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "core/frame/RemoteFrame.h" | 5 #include "core/frame/RemoteFrame.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/WindowProxy.h" | 7 #include "bindings/core/v8/WindowProxy.h" |
| 8 #include "bindings/core/v8/WindowProxyManager.h" | 8 #include "bindings/core/v8/WindowProxyManager.h" |
| 9 #include "core/dom/RemoteSecurityContext.h" | 9 #include "core/dom/RemoteSecurityContext.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "platform/graphics/GraphicsLayer.h" | 21 #include "platform/graphics/GraphicsLayer.h" |
| 22 #include "platform/network/ResourceRequest.h" | 22 #include "platform/network/ResourceRequest.h" |
| 23 #include "platform/weborigin/SecurityPolicy.h" | 23 #include "platform/weborigin/SecurityPolicy.h" |
| 24 #include "public/platform/WebLayer.h" | 24 #include "public/platform/WebLayer.h" |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 inline RemoteFrame::RemoteFrame(RemoteFrameClient* client, | 28 inline RemoteFrame::RemoteFrame(RemoteFrameClient* client, |
| 29 FrameHost* host, | 29 FrameHost* host, |
| 30 FrameOwner* owner) | 30 FrameOwner* owner) |
| 31 : Frame(client, host, owner), | 31 : Frame(client, host, owner, RemoteWindowProxyManager::create(*this)), |
| 32 m_securityContext(RemoteSecurityContext::create()), | 32 m_securityContext(RemoteSecurityContext::create()) { |
| 33 m_windowProxyManager(RemoteWindowProxyManager::create(*this)) { | |
| 34 m_domWindow = RemoteDOMWindow::create(*this); | 33 m_domWindow = RemoteDOMWindow::create(*this); |
| 35 } | 34 } |
| 36 | 35 |
| 37 RemoteFrame* RemoteFrame::create(RemoteFrameClient* client, | 36 RemoteFrame* RemoteFrame::create(RemoteFrameClient* client, |
| 38 FrameHost* host, | 37 FrameHost* host, |
| 39 FrameOwner* owner) { | 38 FrameOwner* owner) { |
| 40 return new RemoteFrame(client, host, owner); | 39 return new RemoteFrame(client, host, owner); |
| 41 } | 40 } |
| 42 | 41 |
| 43 RemoteFrame::~RemoteFrame() { | 42 RemoteFrame::~RemoteFrame() { |
| 44 ASSERT(!m_view); | 43 ASSERT(!m_view); |
| 45 } | 44 } |
| 46 | 45 |
| 47 DEFINE_TRACE(RemoteFrame) { | 46 DEFINE_TRACE(RemoteFrame) { |
| 48 visitor->trace(m_view); | 47 visitor->trace(m_view); |
| 49 visitor->trace(m_securityContext); | 48 visitor->trace(m_securityContext); |
| 50 visitor->trace(m_windowProxyManager); | |
| 51 Frame::trace(visitor); | 49 Frame::trace(visitor); |
| 52 } | 50 } |
| 53 | 51 |
| 54 WindowProxy* RemoteFrame::windowProxy(DOMWrapperWorld& world) { | |
| 55 WindowProxy* windowProxy = m_windowProxyManager->windowProxy(world); | |
| 56 ASSERT(windowProxy); | |
| 57 windowProxy->initializeIfNeeded(); | |
| 58 return windowProxy; | |
| 59 } | |
| 60 | |
| 61 void RemoteFrame::navigate(Document& originDocument, | 52 void RemoteFrame::navigate(Document& originDocument, |
| 62 const KURL& url, | 53 const KURL& url, |
| 63 bool replaceCurrentItem, | 54 bool replaceCurrentItem, |
| 64 UserGestureStatus userGestureStatus) { | 55 UserGestureStatus userGestureStatus) { |
| 65 FrameLoadRequest frameRequest(&originDocument, url); | 56 FrameLoadRequest frameRequest(&originDocument, url); |
| 66 frameRequest.setReplacesCurrentItem(replaceCurrentItem); | 57 frameRequest.setReplacesCurrentItem(replaceCurrentItem); |
| 67 frameRequest.resourceRequest().setHasUserGesture(userGestureStatus == | 58 frameRequest.resourceRequest().setHasUserGesture(userGestureStatus == |
| 68 UserGestureStatus::Active); | 59 UserGestureStatus::Active); |
| 69 navigate(frameRequest); | 60 navigate(frameRequest); |
| 70 } | 61 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 94 PluginScriptForbiddenScope forbidPluginDestructorScripting; | 85 PluginScriptForbiddenScope forbidPluginDestructorScripting; |
| 95 detachChildren(); | 86 detachChildren(); |
| 96 if (!client()) | 87 if (!client()) |
| 97 return; | 88 return; |
| 98 | 89 |
| 99 // Clean up the frame's view if needed. A remote frame only has a view if | 90 // Clean up the frame's view if needed. A remote frame only has a view if |
| 100 // the parent is a local frame. | 91 // the parent is a local frame. |
| 101 if (m_view) | 92 if (m_view) |
| 102 m_view->dispose(); | 93 m_view->dispose(); |
| 103 client()->willBeDetached(); | 94 client()->willBeDetached(); |
| 104 m_windowProxyManager->clearForClose(); | 95 getWindowProxyManager()->clearForClose(); |
| 105 setView(nullptr); | 96 setView(nullptr); |
| 106 // ... the RemoteDOMWindow will need to be informed of detachment, | 97 // ... the RemoteDOMWindow will need to be informed of detachment, |
| 107 // as otherwise it will keep a strong reference back to this RemoteFrame. | 98 // as otherwise it will keep a strong reference back to this RemoteFrame. |
| 108 // That combined with wrappers (owned and kept alive by RemoteFrame) keeping | 99 // That combined with wrappers (owned and kept alive by RemoteFrame) keeping |
| 109 // persistent strong references to RemoteDOMWindow will prevent the GCing | 100 // persistent strong references to RemoteDOMWindow will prevent the GCing |
| 110 // of all these objects. Break the cycle by notifying of detachment. | 101 // of all these objects. Break the cycle by notifying of detachment. |
| 111 toRemoteDOMWindow(m_domWindow)->frameDetached(); | 102 toRemoteDOMWindow(m_domWindow)->frameDetached(); |
| 112 if (m_webLayer) | 103 if (m_webLayer) |
| 113 setWebLayer(nullptr); | 104 setWebLayer(nullptr); |
| 114 Frame::detach(type); | 105 Frame::detach(type); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 GraphicsLayer::registerContentsLayer(m_webLayer); | 156 GraphicsLayer::registerContentsLayer(m_webLayer); |
| 166 | 157 |
| 167 ASSERT(owner()); | 158 ASSERT(owner()); |
| 168 toHTMLFrameOwnerElement(owner())->setNeedsCompositingUpdate(); | 159 toHTMLFrameOwnerElement(owner())->setNeedsCompositingUpdate(); |
| 169 } | 160 } |
| 170 | 161 |
| 171 void RemoteFrame::advanceFocus(WebFocusType type, LocalFrame* source) { | 162 void RemoteFrame::advanceFocus(WebFocusType type, LocalFrame* source) { |
| 172 client()->advanceFocus(type, source); | 163 client()->advanceFocus(type, source); |
| 173 } | 164 } |
| 174 | 165 |
| 175 WindowProxyManagerBase* RemoteFrame::getWindowProxyManager() const { | |
| 176 return m_windowProxyManager.get(); | |
| 177 } | |
| 178 | |
| 179 void RemoteFrame::detachChildren() { | 166 void RemoteFrame::detachChildren() { |
| 180 using FrameVector = HeapVector<Member<Frame>>; | 167 using FrameVector = HeapVector<Member<Frame>>; |
| 181 FrameVector childrenToDetach; | 168 FrameVector childrenToDetach; |
| 182 childrenToDetach.reserveCapacity(tree().childCount()); | 169 childrenToDetach.reserveCapacity(tree().childCount()); |
| 183 for (Frame* child = tree().firstChild(); child; | 170 for (Frame* child = tree().firstChild(); child; |
| 184 child = child->tree().nextSibling()) | 171 child = child->tree().nextSibling()) |
| 185 childrenToDetach.push_back(child); | 172 childrenToDetach.push_back(child); |
| 186 for (const auto& child : childrenToDetach) | 173 for (const auto& child : childrenToDetach) |
| 187 child->detach(FrameDetachType::Remove); | 174 child->detach(FrameDetachType::Remove); |
| 188 } | 175 } |
| 189 | 176 |
| 190 } // namespace blink | 177 } // namespace blink |
| OLD | NEW |