Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / frame / Frame.h
1 /*
2  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3  *                     1999-2001 Lars Knoll <knoll@kde.org>
4  *                     1999-2001 Antti Koivisto <koivisto@kde.org>
5  *                     2000-2001 Simon Hausmann <hausmann@kde.org>
6  *                     2000-2001 Dirk Mueller <mueller@kde.org>
7  *                     2000 Stefan Schimanski <1Stein@gmx.de>
8  * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
9  * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
10  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public License
23  * along with this library; see the file COPYING.LIB.  If not, write to
24  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25  * Boston, MA 02110-1301, USA.
26  */
27
28 #ifndef Frame_h
29 #define Frame_h
30
31 #include "core/page/FrameTree.h"
32 #include "platform/heap/Handle.h"
33 #include "wtf/Forward.h"
34 #include "wtf/RefCounted.h"
35
36 namespace blink {
37 class WebLayer;
38 }
39
40 namespace blink {
41
42 class ChromeClient;
43 class FrameClient;
44 class FrameHost;
45 class FrameOwner;
46 class HTMLFrameOwnerElement;
47 class LocalDOMWindow;
48 class Page;
49 class RenderPart;
50 class Settings;
51
52 class Frame : public RefCounted<Frame> {
53 public:
54     virtual bool isLocalFrame() const { return false; }
55     virtual bool isRemoteFrame() const { return false; }
56
57     virtual ~Frame();
58
59     virtual void detach() = 0;
60     void detachChildren();
61
62     FrameClient* client() const;
63     void clearClient();
64
65     // NOTE: Page is moving out of Blink up into the browser process as
66     // part of the site-isolation (out of process iframes) work.
67     // FrameHost should be used instead where possible.
68     Page* page() const;
69     FrameHost* host() const; // Null when the frame is detached.
70
71     bool isMainFrame() const;
72     bool isLocalRoot() const;
73
74     virtual void disconnectOwnerElement();
75
76     FrameOwner* owner() const;
77     HTMLFrameOwnerElement* deprecatedLocalOwner() const;
78
79     // FIXME: LocalDOMWindow and Document should both be moved to LocalFrame
80     // after RemoteFrame is complete enough to exist without them.
81     virtual void setDOMWindow(PassRefPtrWillBeRawPtr<LocalDOMWindow>);
82     LocalDOMWindow* domWindow() const;
83
84     FrameTree& tree() const;
85     ChromeClient& chromeClient() const;
86
87     RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
88
89     // FIXME: These should move to RemoteFrame when that is instantiated.
90     void setRemotePlatformLayer(blink::WebLayer*);
91     blink::WebLayer* remotePlatformLayer() const { return m_remotePlatformLayer; }
92
93     Settings* settings() const; // can be null
94
95     // FIXME: This method identifies a LocalFrame that is acting as a RemoteFrame.
96     // It is necessary only until we can instantiate a RemoteFrame, at which point
97     // it can be removed and its callers can be converted to use the isRemoteFrame()
98     // method.
99     bool isRemoteFrameTemporary() const { return m_remotePlatformLayer; }
100
101 protected:
102     Frame(FrameClient*, FrameHost*, FrameOwner*);
103
104     mutable FrameTree m_treeNode;
105
106     FrameHost* m_host;
107     FrameOwner* m_owner;
108
109     RefPtrWillBePersistent<LocalDOMWindow> m_domWindow;
110
111 private:
112     FrameClient* m_client;
113     blink::WebLayer* m_remotePlatformLayer;
114 };
115
116 inline FrameClient* Frame::client() const
117 {
118     return m_client;
119 }
120
121 inline void Frame::clearClient()
122 {
123     m_client = 0;
124 }
125
126 inline LocalDOMWindow* Frame::domWindow() const
127 {
128     return m_domWindow.get();
129 }
130
131 inline FrameOwner* Frame::owner() const
132 {
133     return m_owner;
134 }
135
136 inline FrameTree& Frame::tree() const
137 {
138     return m_treeNode;
139 }
140
141 // Allow equality comparisons of Frames by reference or pointer, interchangeably.
142 DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES_REFCOUNTED(Frame)
143
144 } // namespace blink
145
146 #endif // Frame_h