Upstream version 7.36.149.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 "platform/heap/Handle.h"
32 #include "wtf/Forward.h"
33 #include "wtf/HashSet.h"
34 #include "wtf/RefCounted.h"
35
36 namespace blink {
37 class WebLayer;
38 }
39
40 namespace WebCore {
41
42 class DOMWindow;
43 class ChromeClient;
44 class FrameDestructionObserver;
45 class FrameHost;
46 class HTMLFrameOwnerElement;
47 class Page;
48 class RenderPart;
49 class Settings;
50
51 class Frame : public RefCounted<Frame> {
52 public:
53     virtual bool isLocalFrame() const { return false; }
54     virtual bool isRemoteFrame() const { return false; }
55
56     virtual ~Frame();
57
58     void addDestructionObserver(FrameDestructionObserver*);
59     void removeDestructionObserver(FrameDestructionObserver*);
60
61     virtual void willDetachFrameHost();
62     virtual void detachFromFrameHost();
63
64     // NOTE: Page is moving out of Blink up into the browser process as
65     // part of the site-isolation (out of process iframes) work.
66     // FrameHost should be used instead where possible.
67     Page* page() const;
68     FrameHost* host() const; // Null when the frame is detached.
69
70     bool isMainFrame() const;
71
72     virtual void disconnectOwnerElement();
73
74     HTMLFrameOwnerElement* ownerElement() const;
75
76     // FIXME: DOMWindow and Document should both be moved to LocalFrame
77     // after RemoteFrame is complete enough to exist without them.
78     virtual void setDOMWindow(PassRefPtrWillBeRawPtr<DOMWindow>);
79     DOMWindow* domWindow() const;
80
81     ChromeClient& chromeClient() const;
82
83     RenderPart* ownerRenderer() const; // Renderer for the element that contains this frame.
84
85     int64_t frameID() const { return m_frameID; }
86
87     // FIXME: These should move to RemoteFrame when that is instantiated.
88     void setRemotePlatformLayer(blink::WebLayer* remotePlatformLayer) { m_remotePlatformLayer = remotePlatformLayer; }
89     blink::WebLayer* remotePlatformLayer() const { return m_remotePlatformLayer; }
90
91     Settings* settings() const; // can be null
92
93     // FIXME: This method identifies a LocalFrame that is acting as a RemoteFrame.
94     // It is necessary only until we can instantiate a RemoteFrame, at which point
95     // it can be removed and its callers can be converted to use the isRemoteFrame()
96     // method.
97     bool isRemoteFrameTemporary() const { return m_remotePlatformLayer; }
98
99 protected:
100     Frame(FrameHost*, HTMLFrameOwnerElement*);
101
102     FrameHost* m_host;
103     HTMLFrameOwnerElement* m_ownerElement;
104
105     RefPtrWillBePersistent<DOMWindow> m_domWindow;
106
107 private:
108
109     HashSet<FrameDestructionObserver*> m_destructionObservers;
110
111     // Temporary hack for history.
112     int64_t m_frameID;
113
114     blink::WebLayer* m_remotePlatformLayer;
115 };
116
117 inline DOMWindow* Frame::domWindow() const
118 {
119     return m_domWindow.get();
120 }
121
122 inline HTMLFrameOwnerElement* Frame::ownerElement() const
123 {
124     return m_ownerElement;
125 }
126
127 } // namespace WebCore
128
129 #endif // Frame_h