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 "config.h" | 5 #include "config.h" |
6 #include "web/WebRemoteFrameImpl.h" | 6 #include "web/WebRemoteFrameImpl.h" |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/frame/RemoteFrame.h" | 9 #include "core/frame/RemoteFrame.h" |
10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace { | 24 namespace { |
25 | 25 |
26 // Helper class to bridge communication for a local frame with a remote parent. | 26 // Helper class to bridge communication for a local frame with a remote parent. |
27 // Currently, it serves two purposes: | 27 // Currently, it serves two purposes: |
28 // 1. Allows the local frame's loader to retrieve sandbox flags associated with | 28 // 1. Allows the local frame's loader to retrieve sandbox flags associated with |
29 // its owner element in another process. | 29 // its owner element in another process. |
30 // 2. Trigger a load event on its owner element once it finishes a load. | 30 // 2. Trigger a load event on its owner element once it finishes a load. |
31 class RemoteBridgeFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<Remo
teBridgeFrameOwner>, public FrameOwner { | 31 class RemoteBridgeFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<Remo
teBridgeFrameOwner>, public FrameOwner { |
32 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RemoteBridgeFrameOwner); | 32 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RemoteBridgeFrameOwner); |
33 public: | 33 public: |
34 static PassOwnPtrWillBeRawPtr<RemoteBridgeFrameOwner> create(PassRefPtrWillB
eRawPtr<WebLocalFrameImpl> frame) | 34 static PassOwnPtrWillBeRawPtr<RemoteBridgeFrameOwner> create(PassRefPtrWillB
eRawPtr<WebLocalFrameImpl> frame, SandboxFlags flags) |
35 { | 35 { |
36 return adoptPtrWillBeNoop(new RemoteBridgeFrameOwner(frame)); | 36 return adoptPtrWillBeNoop(new RemoteBridgeFrameOwner(frame, flags)); |
37 } | 37 } |
38 | 38 |
39 virtual bool isLocal() const override; | 39 virtual bool isLocal() const override |
40 virtual SandboxFlags sandboxFlags() const override; | 40 { |
| 41 return false; |
| 42 } |
| 43 |
| 44 virtual SandboxFlags sandboxFlags() const override |
| 45 { |
| 46 return m_sandboxFlags; |
| 47 } |
| 48 |
| 49 void setSandboxFlags(SandboxFlags flags) |
| 50 { |
| 51 m_sandboxFlags = flags; |
| 52 } |
| 53 |
41 virtual void dispatchLoad() override; | 54 virtual void dispatchLoad() override; |
42 | 55 |
43 virtual void trace(Visitor*); | 56 virtual void trace(Visitor*); |
44 | 57 |
45 private: | 58 private: |
46 explicit RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl>); | 59 explicit RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl>, S
andboxFlags); |
47 | 60 |
48 RefPtrWillBeMember<WebLocalFrameImpl> m_frame; | 61 RefPtrWillBeMember<WebLocalFrameImpl> m_frame; |
| 62 SandboxFlags m_sandboxFlags; |
49 }; | 63 }; |
50 | 64 |
51 RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFr
ameImpl> frame) | 65 RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFr
ameImpl> frame, SandboxFlags flags) |
52 : m_frame(frame) | 66 : m_frame(frame) |
| 67 , m_sandboxFlags(flags) |
53 { | 68 { |
54 } | 69 } |
55 | 70 |
56 void RemoteBridgeFrameOwner::trace(Visitor* visitor) | 71 void RemoteBridgeFrameOwner::trace(Visitor* visitor) |
57 { | 72 { |
58 visitor->trace(m_frame); | 73 visitor->trace(m_frame); |
59 FrameOwner::trace(visitor); | 74 FrameOwner::trace(visitor); |
60 } | 75 } |
61 | 76 |
62 bool RemoteBridgeFrameOwner::isLocal() const | |
63 { | |
64 return false; | |
65 } | |
66 | |
67 SandboxFlags RemoteBridgeFrameOwner::sandboxFlags() const | |
68 { | |
69 // FIXME: Implement. Most likely grab it from m_frame. | |
70 return 0; | |
71 } | |
72 | |
73 void RemoteBridgeFrameOwner::dispatchLoad() | 77 void RemoteBridgeFrameOwner::dispatchLoad() |
74 { | 78 { |
75 // FIXME: Implement. Most likely goes through m_frame->client(). | 79 // FIXME: Implement. Most likely goes through m_frame->client(). |
76 } | 80 } |
77 | 81 |
78 } // namespace | 82 } // namespace |
79 | 83 |
80 bool PlaceholderFrameOwner::isLocal() const | 84 bool PlaceholderFrameOwner::isLocal() const |
81 { | 85 { |
82 return false; | 86 return false; |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 ASSERT_NOT_REACHED(); | 791 ASSERT_NOT_REACHED(); |
788 return false; | 792 return false; |
789 } | 793 } |
790 | 794 |
791 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const | 795 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const |
792 { | 796 { |
793 ASSERT_NOT_REACHED(); | 797 ASSERT_NOT_REACHED(); |
794 return WebString(); | 798 return WebString(); |
795 } | 799 } |
796 | 800 |
| 801 // FIXME(alexmos): This will go away once the Chromium side is updated to pass s
andbox flags. |
797 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr
ameClient* client) | 802 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr
ameClient* client) |
798 { | 803 { |
| 804 return createLocalChild(name, WebSandboxFlags::None, client); |
| 805 } |
| 806 |
| 807 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebSa
ndboxFlags sandboxFlags, WebFrameClient* client) |
| 808 { |
799 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client)
); | 809 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client)
); |
800 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner>>::AddResult resu
lt = | 810 WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult res
ult = |
801 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child)); | 811 m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child, sta
tic_cast<SandboxFlags>(sandboxFlags))); |
802 appendChild(child); | 812 appendChild(child); |
803 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame,
which may | 813 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame,
which may |
804 // result in the browser observing two navigations to about:blank (one from
the initial | 814 // result in the browser observing two navigations to about:blank (one from
the initial |
805 // frame creation, and one from swapping it into the remote process). FrameL
oader might | 815 // frame creation, and one from swapping it into the remote process). FrameL
oader might |
806 // need a special initialization function for this case to avoid that duplic
ate navigation. | 816 // need a special initialization function for this case to avoid that duplic
ate navigation. |
807 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(),
name, nullAtom); | 817 child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(),
name, nullAtom); |
808 // Partially related with the above FIXME--the init() call may trigger JS di
spatch. However, | 818 // Partially related with the above FIXME--the init() call may trigger JS di
spatch. However, |
809 // if the parent is remote, it should never be detached synchronously... | 819 // if the parent is remote, it should never be detached synchronously... |
810 ASSERT(child->frame()); | 820 ASSERT(child->frame()); |
811 return child; | 821 return child; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 localFrameImpl->frame()->view()->frameRect(), | 857 localFrameImpl->frame()->view()->frameRect(), |
848 localFrameImpl->frame()->view()->visibleContentScaleFactor()); | 858 localFrameImpl->frame()->view()->visibleContentScaleFactor()); |
849 } | 859 } |
850 | 860 |
851 void WebRemoteFrameImpl::setReplicatedOrigin(const WebSecurityOrigin& origin) co
nst | 861 void WebRemoteFrameImpl::setReplicatedOrigin(const WebSecurityOrigin& origin) co
nst |
852 { | 862 { |
853 ASSERT(frame()); | 863 ASSERT(frame()); |
854 frame()->securityContext()->setReplicatedOrigin(origin); | 864 frame()->securityContext()->setReplicatedOrigin(origin); |
855 } | 865 } |
856 | 866 |
| 867 void WebRemoteFrameImpl::setReplicatedSandboxFlags(WebSandboxFlags flags) const |
| 868 { |
| 869 ASSERT(frame()); |
| 870 frame()->securityContext()->enforceSandboxFlags(static_cast<SandboxFlags>(fl
ags)); |
| 871 } |
| 872 |
857 void WebRemoteFrameImpl::didStartLoading() | 873 void WebRemoteFrameImpl::didStartLoading() |
858 { | 874 { |
859 frame()->setIsLoading(true); | 875 frame()->setIsLoading(true); |
860 } | 876 } |
861 | 877 |
862 void WebRemoteFrameImpl::didStopLoading() | 878 void WebRemoteFrameImpl::didStopLoading() |
863 { | 879 { |
864 frame()->setIsLoading(false); | 880 frame()->setIsLoading(false); |
865 if (parent() && parent()->isWebLocalFrame()) { | 881 if (parent() && parent()->isWebLocalFrame()) { |
866 WebLocalFrameImpl* parentFrame = | 882 WebLocalFrameImpl* parentFrame = |
867 toWebLocalFrameImpl(parent()->toWebLocalFrame()); | 883 toWebLocalFrameImpl(parent()->toWebLocalFrame()); |
868 parentFrame->frame()->loader().checkCompleted(); | 884 parentFrame->frame()->loader().checkCompleted(); |
869 } | 885 } |
870 } | 886 } |
871 | 887 |
872 } // namespace blink | 888 } // namespace blink |
OLD | NEW |