Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: Source/web/WebRemoteFrameImpl.cpp

Issue 334483002: Add Blink APIs for frame tree mirroring. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Devirtualize initializeAsMainFrame Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/web/WebRemoteFrameImpl.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/RemoteFrame.h" 8 #include "core/frame/RemoteFrame.h"
9 #include "public/platform/WebFloatRect.h" 9 #include "public/platform/WebFloatRect.h"
10 #include "public/platform/WebRect.h" 10 #include "public/platform/WebRect.h"
11 #include "public/web/WebDocument.h" 11 #include "public/web/WebDocument.h"
12 #include "public/web/WebPerformance.h" 12 #include "public/web/WebPerformance.h"
13 #include "public/web/WebRange.h" 13 #include "public/web/WebRange.h"
14 #include "web/WebLocalFrameImpl.h"
15 #include "web/WebViewImpl.h"
14 #include <v8/include/v8.h> 16 #include <v8/include/v8.h>
15 17
18 using namespace WebCore;
19
16 namespace blink { 20 namespace blink {
17 21
22 namespace {
23
24 // Helper class to bridge communication for a local frame with a remote parent.
25 // Currently, it serves two purposes:
26 // 1. Allows the local frame's loader to retrieve sandbox flags associated with
27 // its owner element in another process.
28 // 2. Trigger a load event on its owner element once it finishes a load.
29 class RemoteBridgeFrameOwner : public FrameOwner {
30 public:
31 explicit RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl>);
32
33 virtual bool isLocal() const OVERRIDE;
34 virtual SandboxFlags sandboxFlags() const OVERRIDE;
35 virtual void dispatchLoad() OVERRIDE;
36
37 private:
38 RefPtr<WebLocalFrameImpl> m_frame;
39 };
40
41 RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl> fra me)
42 : m_frame(frame)
43 {
44 }
45
46 bool RemoteBridgeFrameOwner::isLocal() const
47 {
48 return false;
49 }
50
51 SandboxFlags RemoteBridgeFrameOwner::sandboxFlags() const
52 {
53 // FIXME: Implement. Most likely grab it from m_frame.
54 return 0;
55 }
56
57 void RemoteBridgeFrameOwner::dispatchLoad()
58 {
59 // FIXME: Implement. Most likely goes through m_frame->client().
60 }
61
62 // FIXME: This is just a placeholder frame owner to supply to RemoteFrame when
63 // the parent is also a remote frame. Strictly speaking, this shouldn't be
64 // necessary, since a remote frame shouldn't ever need to communicate with a
65 // remote parent (there are no sandbox flags to retrieve in this case, nor can
66 // the RemoteFrame itself load a document). In most circumstances, the check for
67 // frame->owner() can be replaced with a check for frame->tree().parent(). Once
68 // that's done, this class can be removed.
69 class PlaceholderFrameOwner : public FrameOwner {
70 public:
71 virtual bool isLocal() const OVERRIDE;
72 virtual SandboxFlags sandboxFlags() const OVERRIDE;
73 virtual void dispatchLoad() OVERRIDE;
74 };
75
76 bool PlaceholderFrameOwner::isLocal() const
77 {
78 return false;
79 }
80
81 SandboxFlags PlaceholderFrameOwner::sandboxFlags() const
82 {
83 ASSERT_NOT_REACHED();
84 return 0;
85 }
86
87 void PlaceholderFrameOwner::dispatchLoad()
88 {
89 ASSERT_NOT_REACHED();
90 }
91
92 } // namespace
93
18 WebRemoteFrame* WebRemoteFrame::create(WebFrameClient*) 94 WebRemoteFrame* WebRemoteFrame::create(WebFrameClient*)
19 { 95 {
20 return adoptRef(new WebRemoteFrameImpl()).leakRef(); 96 return adoptRef(new WebRemoteFrameImpl()).leakRef();
21 } 97 }
22 98
23 WebRemoteFrameImpl::WebRemoteFrameImpl() 99 WebRemoteFrameImpl::WebRemoteFrameImpl()
24 : m_frameClient(this) 100 : m_frameClient(this)
25 { 101 {
26 } 102 }
27 103
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 ASSERT_NOT_REACHED(); 231 ASSERT_NOT_REACHED();
156 return false; 232 return false;
157 } 233 }
158 234
159 WebView* WebRemoteFrameImpl::view() const 235 WebView* WebRemoteFrameImpl::view() const
160 { 236 {
161 ASSERT_NOT_REACHED(); 237 ASSERT_NOT_REACHED();
162 return 0; 238 return 0;
163 } 239 }
164 240
241 void WebRemoteFrameImpl::removeChild(WebFrame* frame)
242 {
243 WebFrame::removeChild(frame);
244 m_ownersForChildren.remove(frame);
245 }
246
165 WebFrame* WebRemoteFrameImpl::traversePrevious(bool wrap) const 247 WebFrame* WebRemoteFrameImpl::traversePrevious(bool wrap) const
166 { 248 {
167 ASSERT_NOT_REACHED(); 249 ASSERT_NOT_REACHED();
168 return 0; 250 return 0;
169 } 251 }
170 252
171 WebFrame* WebRemoteFrameImpl::traverseNext(bool wrap) const 253 WebFrame* WebRemoteFrameImpl::traverseNext(bool wrap) const
172 { 254 {
173 ASSERT_NOT_REACHED(); 255 ASSERT_NOT_REACHED();
174 return 0; 256 return 0;
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 ASSERT_NOT_REACHED(); 797 ASSERT_NOT_REACHED();
716 return false; 798 return false;
717 } 799 }
718 800
719 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const 801 WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
720 { 802 {
721 ASSERT_NOT_REACHED(); 803 ASSERT_NOT_REACHED();
722 return WebString(); 804 return WebString();
723 } 805 }
724 806
807 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFr ameClient* client)
808 {
809 WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client) );
810 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result =
811 m_ownersForChildren.add(child, adoptPtr(new RemoteBridgeFrameOwner(child )));
812 appendChild(child);
813 // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may
814 // result in the browser observing two navigations to about:blank (one from the initial
815 // frame creation, and one from swapping it into the remote process). FrameL oader might
816 // need a special initialization function for this case to avoid that duplic ate navigation.
817 child->initializeAsChildFrame(frame()->host(), result.storedValue->value.get (), name, AtomicString());
818 // Partially related with the above FIXME--the init() call may trigger JS di spatch. However,
819 // if the parent is remote, it should never be detached synchronously...
820 ASSERT(child->frame());
821 return child;
822 }
823
824 void WebRemoteFrameImpl::initializeAsMainFrame(Page* page)
825 {
826 setWebCoreFrame(RemoteFrame::create(&m_frameClient, &page->frameHost(), 0));
827 }
828
829 WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, Web FrameClient* client)
830 {
831 WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(clie nt));
832 HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result =
833 m_ownersForChildren.add(child, adoptPtr(new PlaceholderFrameOwner));
834 appendChild(child);
835 RefPtr<RemoteFrame> childFrame = RemoteFrame::create(&child->m_frameClient, frame()->host(), result.storedValue->value.get());
836 child->setWebCoreFrame(childFrame);
837 childFrame->tree().setName(name, AtomicString());
838 return child;
839 }
840
841 void WebRemoteFrameImpl::setWebCoreFrame(PassRefPtr<RemoteFrame> frame)
842 {
843 m_frame = frame;
844 }
845
725 } // namespace blink 846 } // namespace blink
726 847
OLDNEW
« no previous file with comments | « Source/web/WebRemoteFrameImpl.h ('k') | Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698