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
3// found in the LICENSE file.
4
5#include "config.h"
6#include "web/WebRemoteFrameImpl.h"
7
8#include "core/frame/FrameOwner.h"
9#include "core/frame/FrameView.h"
10#include "core/frame/RemoteFrame.h"
11#include "core/frame/Settings.h"
12#include "core/page/Page.h"
13#include "platform/heap/Handle.h"
14#include "public/platform/WebFloatRect.h"
15#include "public/platform/WebRect.h"
16#include "public/web/WebDocument.h"
17#include "public/web/WebPerformance.h"
18#include "public/web/WebRange.h"
19#include "web/WebLocalFrameImpl.h"
20#include "web/WebViewImpl.h"
21#include <v8/include/v8.h>
22
23namespace blink {
24
25namespace {
26
27// Helper class to bridge communication for a local frame with a remote parent.
28// Currently, it serves two purposes:
29// 1. Allows the local frame's loader to retrieve sandbox flags associated with
30//    its owner element in another process.
31// 2. Trigger a load event on its owner element once it finishes a load.
32class RemoteBridgeFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<RemoteBridgeFrameOwner>, public FrameOwner {
33    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RemoteBridgeFrameOwner);
34public:
35    static PassOwnPtrWillBeRawPtr<RemoteBridgeFrameOwner> create(PassRefPtrWillBeRawPtr<WebLocalFrameImpl> frame)
36    {
37        return adoptPtrWillBeNoop(new RemoteBridgeFrameOwner(frame));
38    }
39
40    virtual bool isLocal() const OVERRIDE;
41    virtual SandboxFlags sandboxFlags() const OVERRIDE;
42    virtual void dispatchLoad() OVERRIDE;
43
44    virtual void trace(Visitor*);
45
46private:
47    explicit RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl>);
48
49    RefPtrWillBeMember<WebLocalFrameImpl> m_frame;
50};
51
52RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl> frame)
53    : m_frame(frame)
54{
55}
56
57void RemoteBridgeFrameOwner::trace(Visitor* visitor)
58{
59    visitor->trace(m_frame);
60    FrameOwner::trace(visitor);
61}
62
63bool RemoteBridgeFrameOwner::isLocal() const
64{
65    return false;
66}
67
68SandboxFlags RemoteBridgeFrameOwner::sandboxFlags() const
69{
70    // FIXME: Implement. Most likely grab it from m_frame.
71    return 0;
72}
73
74void RemoteBridgeFrameOwner::dispatchLoad()
75{
76    // FIXME: Implement. Most likely goes through m_frame->client().
77}
78
79// FIXME: This is just a placeholder frame owner to supply to RemoteFrame when
80// the parent is also a remote frame. Strictly speaking, this shouldn't be
81// necessary, since a remote frame shouldn't ever need to communicate with a
82// remote parent (there are no sandbox flags to retrieve in this case, nor can
83// the RemoteFrame itself load a document). In most circumstances, the check for
84// frame->owner() can be replaced with a check for frame->tree().parent(). Once
85// that's done, this class can be removed.
86class PlaceholderFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<PlaceholderFrameOwner>, public FrameOwner {
87    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PlaceholderFrameOwner);
88public:
89    virtual bool isLocal() const OVERRIDE;
90    virtual SandboxFlags sandboxFlags() const OVERRIDE;
91    virtual void dispatchLoad() OVERRIDE;
92};
93
94bool PlaceholderFrameOwner::isLocal() const
95{
96    return false;
97}
98
99SandboxFlags PlaceholderFrameOwner::sandboxFlags() const
100{
101    ASSERT_NOT_REACHED();
102    return 0;
103}
104
105void PlaceholderFrameOwner::dispatchLoad()
106{
107    ASSERT_NOT_REACHED();
108}
109
110} // namespace
111
112WebRemoteFrame* WebRemoteFrame::create(WebRemoteFrameClient* client)
113{
114    WebRemoteFrameImpl* frame = new WebRemoteFrameImpl(client);
115#if ENABLE(OILPAN)
116    return frame;
117#else
118    return adoptRef(frame).leakRef();
119#endif
120}
121
122WebRemoteFrameImpl::WebRemoteFrameImpl(WebRemoteFrameClient* client)
123    : m_frameClient(this)
124    , m_client(client)
125#if ENABLE(OILPAN)
126    , m_selfKeepAlive(this)
127#endif
128{
129}
130
131WebRemoteFrameImpl::~WebRemoteFrameImpl()
132{
133}
134
135void WebRemoteFrameImpl::trace(Visitor* visitor)
136{
137#if ENABLE(OILPAN)
138    visitor->trace(m_frame);
139    visitor->trace(m_ownersForChildren);
140
141    WebFrame::traceChildren(visitor, this);
142#endif
143}
144
145bool WebRemoteFrameImpl::isWebLocalFrame() const
146{
147    return false;
148}
149
150WebLocalFrame* WebRemoteFrameImpl::toWebLocalFrame()
151{
152    ASSERT_NOT_REACHED();
153    return 0;
154}
155
156bool WebRemoteFrameImpl::isWebRemoteFrame() const
157{
158    return true;
159}
160
161WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame()
162{
163    return this;
164}
165
166void WebRemoteFrameImpl::close()
167{
168#if ENABLE(OILPAN)
169    m_selfKeepAlive.clear();
170#else
171    deref();
172#endif
173}
174
175WebString WebRemoteFrameImpl::uniqueName() const
176{
177    ASSERT_NOT_REACHED();
178    return WebString();
179}
180
181WebString WebRemoteFrameImpl::assignedName() const
182{
183    ASSERT_NOT_REACHED();
184    return WebString();
185}
186
187void WebRemoteFrameImpl::setName(const WebString&)
188{
189    ASSERT_NOT_REACHED();
190}
191
192WebVector<WebIconURL> WebRemoteFrameImpl::iconURLs(int iconTypesMask) const
193{
194    ASSERT_NOT_REACHED();
195    return WebVector<WebIconURL>();
196}
197
198void WebRemoteFrameImpl::setIsRemote(bool)
199{
200    ASSERT_NOT_REACHED();
201}
202
203void WebRemoteFrameImpl::setRemoteWebLayer(WebLayer* webLayer)
204{
205    if (!frame())
206        return;
207
208    frame()->setRemotePlatformLayer(webLayer);
209}
210
211void WebRemoteFrameImpl::setPermissionClient(WebPermissionClient*)
212{
213    ASSERT_NOT_REACHED();
214}
215
216void WebRemoteFrameImpl::setSharedWorkerRepositoryClient(WebSharedWorkerRepositoryClient*)
217{
218    ASSERT_NOT_REACHED();
219}
220
221void WebRemoteFrameImpl::setCanHaveScrollbars(bool)
222{
223    ASSERT_NOT_REACHED();
224}
225
226WebSize WebRemoteFrameImpl::scrollOffset() const
227{
228    ASSERT_NOT_REACHED();
229    return WebSize();
230}
231
232void WebRemoteFrameImpl::setScrollOffset(const WebSize&)
233{
234    ASSERT_NOT_REACHED();
235}
236
237WebSize WebRemoteFrameImpl::minimumScrollOffset() const
238{
239    ASSERT_NOT_REACHED();
240    return WebSize();
241}
242
243WebSize WebRemoteFrameImpl::maximumScrollOffset() const
244{
245    ASSERT_NOT_REACHED();
246    return WebSize();
247}
248
249WebSize WebRemoteFrameImpl::contentsSize() const
250{
251    ASSERT_NOT_REACHED();
252    return WebSize();
253}
254
255bool WebRemoteFrameImpl::hasVisibleContent() const
256{
257    ASSERT_NOT_REACHED();
258    return false;
259}
260
261WebRect WebRemoteFrameImpl::visibleContentRect() const
262{
263    ASSERT_NOT_REACHED();
264    return WebRect();
265}
266
267bool WebRemoteFrameImpl::hasHorizontalScrollbar() const
268{
269    ASSERT_NOT_REACHED();
270    return false;
271}
272
273bool WebRemoteFrameImpl::hasVerticalScrollbar() const
274{
275    ASSERT_NOT_REACHED();
276    return false;
277}
278
279WebView* WebRemoteFrameImpl::view() const
280{
281    if (!frame())
282        return 0;
283    return WebViewImpl::fromPage(frame()->page());
284}
285
286WebViewImpl* WebRemoteFrameImpl::viewImpl() const
287{
288    if (!frame())
289        return 0;
290    return WebViewImpl::fromPage(frame()->page());
291}
292
293void WebRemoteFrameImpl::removeChild(WebFrame* frame)
294{
295    WebFrame::removeChild(frame);
296    m_ownersForChildren.remove(frame);
297}
298
299WebDocument WebRemoteFrameImpl::document() const
300{
301    return WebDocument();
302}
303
304WebPerformance WebRemoteFrameImpl::performance() const
305{
306    ASSERT_NOT_REACHED();
307    return WebPerformance();
308}
309
310bool WebRemoteFrameImpl::dispatchBeforeUnloadEvent()
311{
312    ASSERT_NOT_REACHED();
313    return false;
314}
315
316void WebRemoteFrameImpl::dispatchUnloadEvent()
317{
318    ASSERT_NOT_REACHED();
319}
320
321NPObject* WebRemoteFrameImpl::windowObject() const
322{
323    ASSERT_NOT_REACHED();
324    return 0;
325}
326
327void WebRemoteFrameImpl::bindToWindowObject(const WebString& name, NPObject*)
328{
329    ASSERT_NOT_REACHED();
330}
331
332void WebRemoteFrameImpl::bindToWindowObject(const WebString& name, NPObject*, void*)
333{
334    ASSERT_NOT_REACHED();
335}
336
337void WebRemoteFrameImpl::executeScript(const WebScriptSource&)
338{
339    ASSERT_NOT_REACHED();
340}
341
342void WebRemoteFrameImpl::executeScriptInIsolatedWorld(
343    int worldID, const WebScriptSource* sources, unsigned numSources,
344    int extensionGroup)
345{
346    ASSERT_NOT_REACHED();
347}
348
349void WebRemoteFrameImpl::setIsolatedWorldSecurityOrigin(int worldID, const WebSecurityOrigin&)
350{
351    ASSERT_NOT_REACHED();
352}
353
354void WebRemoteFrameImpl::setIsolatedWorldContentSecurityPolicy(int worldID, const WebString&)
355{
356    ASSERT_NOT_REACHED();
357}
358
359void WebRemoteFrameImpl::addMessageToConsole(const WebConsoleMessage&)
360{
361    ASSERT_NOT_REACHED();
362}
363
364void WebRemoteFrameImpl::collectGarbage()
365{
366    ASSERT_NOT_REACHED();
367}
368
369bool WebRemoteFrameImpl::checkIfRunInsecureContent(const WebURL&) const
370{
371    ASSERT_NOT_REACHED();
372    return false;
373}
374
375v8::Handle<v8::Value> WebRemoteFrameImpl::executeScriptAndReturnValue(
376    const WebScriptSource&)
377{
378    ASSERT_NOT_REACHED();
379    return v8::Handle<v8::Value>();
380}
381
382void WebRemoteFrameImpl::executeScriptInIsolatedWorld(
383    int worldID, const WebScriptSource* sourcesIn, unsigned numSources,
384    int extensionGroup, WebVector<v8::Local<v8::Value> >* results)
385{
386    ASSERT_NOT_REACHED();
387}
388
389v8::Handle<v8::Value> WebRemoteFrameImpl::callFunctionEvenIfScriptDisabled(
390    v8::Handle<v8::Function>,
391    v8::Handle<v8::Value>,
392    int argc,
393    v8::Handle<v8::Value> argv[])
394{
395    ASSERT_NOT_REACHED();
396    return v8::Handle<v8::Value>();
397}
398
399v8::Local<v8::Context> WebRemoteFrameImpl::mainWorldScriptContext() const
400{
401    ASSERT_NOT_REACHED();
402    return v8::Local<v8::Context>();
403}
404
405void WebRemoteFrameImpl::reload(bool ignoreCache)
406{
407    ASSERT_NOT_REACHED();
408}
409
410void WebRemoteFrameImpl::reloadWithOverrideURL(const WebURL& overrideUrl, bool ignoreCache)
411{
412    ASSERT_NOT_REACHED();
413}
414
415void WebRemoteFrameImpl::loadRequest(const WebURLRequest&)
416{
417    ASSERT_NOT_REACHED();
418}
419
420void WebRemoteFrameImpl::loadHistoryItem(const WebHistoryItem&, WebHistoryLoadType, WebURLRequest::CachePolicy)
421{
422    ASSERT_NOT_REACHED();
423}
424
425void WebRemoteFrameImpl::loadData(
426    const WebData&, const WebString& mimeType, const WebString& textEncoding,
427    const WebURL& baseURL, const WebURL& unreachableURL, bool replace)
428{
429    ASSERT_NOT_REACHED();
430}
431
432void WebRemoteFrameImpl::loadHTMLString(
433    const WebData& html, const WebURL& baseURL, const WebURL& unreachableURL,
434    bool replace)
435{
436    ASSERT_NOT_REACHED();
437}
438
439void WebRemoteFrameImpl::stopLoading()
440{
441    ASSERT_NOT_REACHED();
442}
443
444WebDataSource* WebRemoteFrameImpl::provisionalDataSource() const
445{
446    ASSERT_NOT_REACHED();
447    return 0;
448}
449
450WebDataSource* WebRemoteFrameImpl::dataSource() const
451{
452    ASSERT_NOT_REACHED();
453    return 0;
454}
455
456void WebRemoteFrameImpl::enableViewSourceMode(bool enable)
457{
458    ASSERT_NOT_REACHED();
459}
460
461bool WebRemoteFrameImpl::isViewSourceModeEnabled() const
462{
463    ASSERT_NOT_REACHED();
464    return false;
465}
466
467void WebRemoteFrameImpl::setReferrerForRequest(WebURLRequest&, const WebURL& referrer)
468{
469    ASSERT_NOT_REACHED();
470}
471
472void WebRemoteFrameImpl::dispatchWillSendRequest(WebURLRequest&)
473{
474    ASSERT_NOT_REACHED();
475}
476
477WebURLLoader* WebRemoteFrameImpl::createAssociatedURLLoader(const WebURLLoaderOptions&)
478{
479    ASSERT_NOT_REACHED();
480    return 0;
481}
482
483unsigned WebRemoteFrameImpl::unloadListenerCount() const
484{
485    ASSERT_NOT_REACHED();
486    return 0;
487}
488
489void WebRemoteFrameImpl::replaceSelection(const WebString&)
490{
491    ASSERT_NOT_REACHED();
492}
493
494void WebRemoteFrameImpl::insertText(const WebString&)
495{
496    ASSERT_NOT_REACHED();
497}
498
499void WebRemoteFrameImpl::setMarkedText(const WebString&, unsigned location, unsigned length)
500{
501    ASSERT_NOT_REACHED();
502}
503
504void WebRemoteFrameImpl::unmarkText()
505{
506    ASSERT_NOT_REACHED();
507}
508
509bool WebRemoteFrameImpl::hasMarkedText() const
510{
511    ASSERT_NOT_REACHED();
512    return false;
513}
514
515WebRange WebRemoteFrameImpl::markedRange() const
516{
517    ASSERT_NOT_REACHED();
518    return WebRange();
519}
520
521bool WebRemoteFrameImpl::firstRectForCharacterRange(unsigned location, unsigned length, WebRect&) const
522{
523    ASSERT_NOT_REACHED();
524    return false;
525}
526
527size_t WebRemoteFrameImpl::characterIndexForPoint(const WebPoint&) const
528{
529    ASSERT_NOT_REACHED();
530    return 0;
531}
532
533bool WebRemoteFrameImpl::executeCommand(const WebString&, const WebNode&)
534{
535    ASSERT_NOT_REACHED();
536    return false;
537}
538
539bool WebRemoteFrameImpl::executeCommand(const WebString&, const WebString& value, const WebNode&)
540{
541    ASSERT_NOT_REACHED();
542    return false;
543}
544
545bool WebRemoteFrameImpl::isCommandEnabled(const WebString&) const
546{
547    ASSERT_NOT_REACHED();
548    return false;
549}
550
551void WebRemoteFrameImpl::enableContinuousSpellChecking(bool)
552{
553}
554
555bool WebRemoteFrameImpl::isContinuousSpellCheckingEnabled() const
556{
557    return false;
558}
559
560void WebRemoteFrameImpl::requestTextChecking(const WebElement&)
561{
562    ASSERT_NOT_REACHED();
563}
564
565void WebRemoteFrameImpl::replaceMisspelledRange(const WebString&)
566{
567    ASSERT_NOT_REACHED();
568}
569
570void WebRemoteFrameImpl::removeSpellingMarkers()
571{
572    ASSERT_NOT_REACHED();
573}
574
575bool WebRemoteFrameImpl::hasSelection() const
576{
577    ASSERT_NOT_REACHED();
578    return false;
579}
580
581WebRange WebRemoteFrameImpl::selectionRange() const
582{
583    ASSERT_NOT_REACHED();
584    return WebRange();
585}
586
587WebString WebRemoteFrameImpl::selectionAsText() const
588{
589    ASSERT_NOT_REACHED();
590    return WebString();
591}
592
593WebString WebRemoteFrameImpl::selectionAsMarkup() const
594{
595    ASSERT_NOT_REACHED();
596    return WebString();
597}
598
599bool WebRemoteFrameImpl::selectWordAroundCaret()
600{
601    ASSERT_NOT_REACHED();
602    return false;
603}
604
605void WebRemoteFrameImpl::selectRange(const WebPoint& base, const WebPoint& extent)
606{
607    ASSERT_NOT_REACHED();
608}
609
610void WebRemoteFrameImpl::selectRange(const WebRange&)
611{
612    ASSERT_NOT_REACHED();
613}
614
615void WebRemoteFrameImpl::moveRangeSelection(const WebPoint& base, const WebPoint& extent)
616{
617    ASSERT_NOT_REACHED();
618}
619
620void WebRemoteFrameImpl::moveCaretSelection(const WebPoint&)
621{
622    ASSERT_NOT_REACHED();
623}
624
625bool WebRemoteFrameImpl::setEditableSelectionOffsets(int start, int end)
626{
627    ASSERT_NOT_REACHED();
628    return false;
629}
630
631bool WebRemoteFrameImpl::setCompositionFromExistingText(int compositionStart, int compositionEnd, const WebVector<WebCompositionUnderline>& underlines)
632{
633    ASSERT_NOT_REACHED();
634    return false;
635}
636
637void WebRemoteFrameImpl::extendSelectionAndDelete(int before, int after)
638{
639    ASSERT_NOT_REACHED();
640}
641
642void WebRemoteFrameImpl::setCaretVisible(bool)
643{
644    ASSERT_NOT_REACHED();
645}
646
647int WebRemoteFrameImpl::printBegin(const WebPrintParams&, const WebNode& constrainToNode)
648{
649    ASSERT_NOT_REACHED();
650    return 0;
651}
652
653float WebRemoteFrameImpl::printPage(int pageToPrint, WebCanvas*)
654{
655    ASSERT_NOT_REACHED();
656    return 0.0;
657}
658
659float WebRemoteFrameImpl::getPrintPageShrink(int page)
660{
661    ASSERT_NOT_REACHED();
662    return 0.0;
663}
664
665void WebRemoteFrameImpl::printEnd()
666{
667    ASSERT_NOT_REACHED();
668}
669
670bool WebRemoteFrameImpl::isPrintScalingDisabledForPlugin(const WebNode&)
671{
672    ASSERT_NOT_REACHED();
673    return false;
674}
675
676int WebRemoteFrameImpl::getPrintCopiesForPlugin(const WebNode&)
677{
678    ASSERT_NOT_REACHED();
679    return 1;
680}
681
682bool WebRemoteFrameImpl::hasCustomPageSizeStyle(int pageIndex)
683{
684    ASSERT_NOT_REACHED();
685    return false;
686}
687
688bool WebRemoteFrameImpl::isPageBoxVisible(int pageIndex)
689{
690    ASSERT_NOT_REACHED();
691    return false;
692}
693
694void WebRemoteFrameImpl::pageSizeAndMarginsInPixels(
695    int pageIndex,
696    WebSize& pageSize,
697    int& marginTop,
698    int& marginRight,
699    int& marginBottom,
700    int& marginLeft)
701{
702    ASSERT_NOT_REACHED();
703}
704
705WebString WebRemoteFrameImpl::pageProperty(const WebString& propertyName, int pageIndex)
706{
707    ASSERT_NOT_REACHED();
708    return WebString();
709}
710
711void WebRemoteFrameImpl::printPagesWithBoundaries(WebCanvas*, const WebSize&)
712{
713    ASSERT_NOT_REACHED();
714}
715
716bool WebRemoteFrameImpl::find(
717    int identifier, const WebString& searchText, const WebFindOptions&,
718    bool wrapWithinFrame, WebRect* selectionRect)
719{
720    ASSERT_NOT_REACHED();
721    return false;
722}
723
724void WebRemoteFrameImpl::stopFinding(bool clearSelection)
725{
726    ASSERT_NOT_REACHED();
727}
728
729void WebRemoteFrameImpl::scopeStringMatches(
730    int identifier, const WebString& searchText, const WebFindOptions&,
731    bool reset)
732{
733    ASSERT_NOT_REACHED();
734}
735
736void WebRemoteFrameImpl::cancelPendingScopingEffort()
737{
738    ASSERT_NOT_REACHED();
739}
740
741void WebRemoteFrameImpl::increaseMatchCount(int count, int identifier)
742{
743    ASSERT_NOT_REACHED();
744}
745
746void WebRemoteFrameImpl::resetMatchCount()
747{
748    ASSERT_NOT_REACHED();
749}
750
751int WebRemoteFrameImpl::findMatchMarkersVersion() const
752{
753    ASSERT_NOT_REACHED();
754    return 0;
755}
756
757WebFloatRect WebRemoteFrameImpl::activeFindMatchRect()
758{
759    ASSERT_NOT_REACHED();
760    return WebFloatRect();
761}
762
763void WebRemoteFrameImpl::findMatchRects(WebVector<WebFloatRect>&)
764{
765    ASSERT_NOT_REACHED();
766}
767
768int WebRemoteFrameImpl::selectNearestFindMatch(const WebFloatPoint&, WebRect* selectionRect)
769{
770    ASSERT_NOT_REACHED();
771    return 0;
772}
773
774void WebRemoteFrameImpl::setTickmarks(const WebVector<WebRect>&)
775{
776    ASSERT_NOT_REACHED();
777}
778
779void WebRemoteFrameImpl::dispatchMessageEventWithOriginCheck(
780    const WebSecurityOrigin& intendedTargetOrigin,
781    const WebDOMEvent&)
782{
783    ASSERT_NOT_REACHED();
784}
785
786WebString WebRemoteFrameImpl::contentAsText(size_t maxChars) const
787{
788    ASSERT_NOT_REACHED();
789    return WebString();
790}
791
792WebString WebRemoteFrameImpl::contentAsMarkup() const
793{
794    ASSERT_NOT_REACHED();
795    return WebString();
796}
797
798WebString WebRemoteFrameImpl::renderTreeAsText(RenderAsTextControls toShow) const
799{
800    ASSERT_NOT_REACHED();
801    return WebString();
802}
803
804WebString WebRemoteFrameImpl::markerTextForListItem(const WebElement&) const
805{
806    ASSERT_NOT_REACHED();
807    return WebString();
808}
809
810WebRect WebRemoteFrameImpl::selectionBoundsRect() const
811{
812    ASSERT_NOT_REACHED();
813    return WebRect();
814}
815
816bool WebRemoteFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) const
817{
818    ASSERT_NOT_REACHED();
819    return false;
820}
821
822WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
823{
824    ASSERT_NOT_REACHED();
825    return WebString();
826}
827
828WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFrameClient* client)
829{
830    WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client));
831    WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult result =
832        m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child));
833    appendChild(child);
834    // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may
835    // result in the browser observing two navigations to about:blank (one from the initial
836    // frame creation, and one from swapping it into the remote process). FrameLoader might
837    // need a special initialization function for this case to avoid that duplicate navigation.
838    child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name, nullAtom);
839    // Partially related with the above FIXME--the init() call may trigger JS dispatch. However,
840    // if the parent is remote, it should never be detached synchronously...
841    ASSERT(child->frame());
842    return child;
843}
844
845void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner, const AtomicString& name)
846{
847    setCoreFrame(RemoteFrame::create(&m_frameClient, host, owner));
848    m_frame->tree().setName(name, nullAtom);
849}
850
851WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, WebRemoteFrameClient* client)
852{
853    WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(client));
854    WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult result =
855        m_ownersForChildren.add(child, adoptPtrWillBeNoop(new PlaceholderFrameOwner));
856    appendChild(child);
857    child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name);
858    return child;
859}
860
861void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame)
862{
863    m_frame = frame;
864}
865
866WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame)
867{
868    if (!frame.client())
869        return 0;
870    return static_cast<RemoteFrameClient*>(frame.client())->webFrame();
871}
872
873void WebRemoteFrameImpl::initializeFromFrame(WebLocalFrame* source) const
874{
875    ASSERT(source);
876    WebLocalFrameImpl* localFrameImpl = toWebLocalFrameImpl(source);
877    client()->initializeChildFrame(
878        localFrameImpl->frame()->view()->frameRect(),
879        localFrameImpl->frame()->view()->visibleContentScaleFactor());
880}
881
882} // namespace blink
883