1/*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef Chrome_h
21#define Chrome_h
22
23#include "Cursor.h"
24#include "FileChooser.h"
25#include "FocusDirection.h"
26#include "HostWindow.h"
27#include <wtf/Forward.h>
28#include <wtf/RefPtr.h>
29
30#if PLATFORM(MAC)
31#ifndef __OBJC__
32class NSView;
33#endif
34#endif
35
36namespace WebCore {
37
38    class ChromeClient;
39    class ContextMenu;
40    class FloatRect;
41    class Frame;
42    class Geolocation;
43    class HitTestResult;
44    class IntRect;
45    class Node;
46    class Page;
47    class String;
48#if ENABLE(NOTIFICATIONS)
49    class NotificationPresenter;
50#endif
51
52    struct FrameLoadRequest;
53    struct WindowFeatures;
54
55    class Chrome : public HostWindow {
56    public:
57        Chrome(Page*, ChromeClient*);
58        ~Chrome();
59
60        ChromeClient* client() { return m_client; }
61
62        // HostWindow methods.
63        virtual void repaint(const IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false);
64        virtual void scroll(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
65        virtual IntPoint screenToWindow(const IntPoint&) const;
66        virtual IntRect windowToScreen(const IntRect&) const;
67        virtual PlatformPageClient platformPageClient() const;
68        virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const;
69        virtual void scrollbarsModeDidChange() const;
70
71        void contentsSizeChanged(Frame*, const IntSize&) const;
72
73        void setWindowRect(const FloatRect&) const;
74        FloatRect windowRect() const;
75
76        FloatRect pageRect() const;
77
78        float scaleFactor();
79
80#ifdef ANDROID_USER_GESTURE
81        void focus(bool userGesture) const;
82#else
83        void focus() const;
84#endif
85        void unfocus() const;
86
87        bool canTakeFocus(FocusDirection) const;
88        void takeFocus(FocusDirection) const;
89
90        void focusedNodeChanged(Node*) const;
91
92        Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&) const;
93        void show() const;
94
95        bool canRunModal() const;
96        bool canRunModalNow() const;
97        void runModal() const;
98
99        void setToolbarsVisible(bool) const;
100        bool toolbarsVisible() const;
101
102        void setStatusbarVisible(bool) const;
103        bool statusbarVisible() const;
104
105        void setScrollbarsVisible(bool) const;
106        bool scrollbarsVisible() const;
107
108        void setMenubarVisible(bool) const;
109        bool menubarVisible() const;
110
111        void setResizable(bool) const;
112
113        bool canRunBeforeUnloadConfirmPanel();
114        bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame);
115
116        void closeWindowSoon();
117
118        void runJavaScriptAlert(Frame*, const String&);
119        bool runJavaScriptConfirm(Frame*, const String&);
120        bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
121        void setStatusbarText(Frame*, const String&);
122        bool shouldInterruptJavaScript();
123
124        void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
125        void registerContentHandler(const String& mimeType, const String& baseURL, const String& url, const String& title);
126
127        IntRect windowResizerRect() const;
128
129        void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
130
131        void setToolTip(const HitTestResult&);
132
133        void print(Frame*);
134
135        void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
136        void cancelGeolocationPermissionRequestForFrame(Frame*);
137
138        void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
139
140        bool setCursor(PlatformCursorHandle);
141
142#if PLATFORM(MAC)
143        void focusNSView(NSView*);
144#endif
145
146#if ENABLE(NOTIFICATIONS)
147        NotificationPresenter* notificationPresenter() const;
148#endif
149
150    private:
151        Page* m_page;
152        ChromeClient* m_client;
153    };
154}
155
156#endif // Chrome_h
157