Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / frame / RemoteFrame.cpp
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 "core/frame/RemoteFrame.h"
7
8 #include "core/frame/RemoteFrameClient.h"
9 #include "core/frame/RemoteFrameView.h"
10 #include "core/html/HTMLFrameOwnerElement.h"
11 #include "platform/weborigin/SecurityPolicy.h"
12
13 namespace blink {
14
15 inline RemoteFrame::RemoteFrame(RemoteFrameClient* client, FrameHost* host, FrameOwner* owner)
16     : Frame(client, host, owner)
17 {
18 }
19
20 PassRefPtrWillBeRawPtr<RemoteFrame> RemoteFrame::create(RemoteFrameClient* client, FrameHost* host, FrameOwner* owner)
21 {
22     return adoptRefWillBeNoop(new RemoteFrame(client, host, owner));
23 }
24
25 RemoteFrame::~RemoteFrame()
26 {
27     setView(nullptr);
28 }
29
30 void RemoteFrame::trace(Visitor* visitor)
31 {
32     visitor->trace(m_view);
33     Frame::trace(visitor);
34 }
35
36 void RemoteFrame::navigate(Document& originDocument, const KURL& url, bool lockBackForwardList)
37 {
38     // The process where this frame actually lives won't have sufficient information to determine
39     // correct referrer, since it won't have access to the originDocument. Set it now.
40     ResourceRequest request(url);
41     request.setHTTPReferrer(SecurityPolicy::generateReferrer(originDocument.referrerPolicy(), url, originDocument.outgoingReferrer()));
42     remoteFrameClient()->navigate(request, lockBackForwardList);
43 }
44
45 void RemoteFrame::detach()
46 {
47     detachChildren();
48     if (!client())
49         return;
50     Frame::detach();
51 }
52
53 void RemoteFrame::forwardInputEvent(Event* event)
54 {
55     remoteFrameClient()->forwardInputEvent(event);
56 }
57
58 void RemoteFrame::setView(PassRefPtrWillBeRawPtr<RemoteFrameView> view)
59 {
60     // Oilpan: as RemoteFrameView performs no finalization actions,
61     // no explicit dispose() of it needed here. (cf. FrameView::dispose().)
62     m_view = view;
63 }
64
65 void RemoteFrame::createView()
66 {
67     RefPtrWillBeRawPtr<RemoteFrameView> view = RemoteFrameView::create(this);
68     setView(view);
69
70     if (ownerRenderer()) {
71         HTMLFrameOwnerElement* owner = deprecatedLocalOwner();
72         ASSERT(owner);
73         owner->setWidget(view);
74     }
75 }
76
77 RemoteFrameClient* RemoteFrame::remoteFrameClient() const
78 {
79     return static_cast<RemoteFrameClient*>(client());
80 }
81
82 } // namespace blink