1/*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 * Copyright (C) 2012, Samsung Electronics. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB.  If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#ifndef Chrome_h
23#define Chrome_h
24
25#include "Cursor.h"
26#include "FocusDirection.h"
27#include "HostWindow.h"
28#include <wtf/Forward.h>
29#include <wtf/RefPtr.h>
30
31#if PLATFORM(COCOA)
32#ifndef __OBJC__
33class NSView;
34#endif
35#endif
36
37namespace WebCore {
38
39class ChromeClient;
40class ColorChooser;
41class ColorChooserClient;
42class DateTimeChooser;
43class DateTimeChooserClient;
44class FileChooser;
45class FileIconLoader;
46class FloatRect;
47class Element;
48class Frame;
49class Geolocation;
50class HitTestResult;
51class IntRect;
52class NavigationAction;
53class Page;
54class PopupMenu;
55class PopupMenuClient;
56class PopupOpeningObserver;
57class SearchPopupMenu;
58
59struct DateTimeChooserParameters;
60struct FrameLoadRequest;
61struct ViewportArguments;
62struct WindowFeatures;
63
64class Chrome : public HostWindow {
65public:
66    Chrome(Page&, ChromeClient&);
67    virtual ~Chrome();
68
69    ChromeClient& client() { return m_client; }
70
71    // HostWindow methods.
72    virtual void invalidateRootView(const IntRect&) override;
73    virtual void invalidateContentsAndRootView(const IntRect&) override;
74    virtual void invalidateContentsForSlowScroll(const IntRect&) override;
75    virtual void scroll(const IntSize&, const IntRect&, const IntRect&) override;
76#if USE(TILED_BACKING_STORE)
77    virtual void delegatedScrollRequested(const IntPoint& scrollPoint) override;
78#endif
79    virtual IntPoint screenToRootView(const IntPoint&) const override;
80    virtual IntRect rootViewToScreen(const IntRect&) const override;
81#if PLATFORM(IOS)
82    virtual IntPoint accessibilityScreenToRootView(const IntPoint&) const override;
83    virtual IntRect rootViewToAccessibilityScreen(const IntRect&) const override;
84#endif
85    virtual PlatformPageClient platformPageClient() const override;
86    virtual void scrollbarsModeDidChange() const override;
87    virtual void setCursor(const Cursor&) override;
88    virtual void setCursorHiddenUntilMouseMoves(bool) override;
89
90#if ENABLE(REQUEST_ANIMATION_FRAME)
91    virtual void scheduleAnimation() override;
92#endif
93
94    virtual PlatformDisplayID displayID() const override;
95    virtual void windowScreenDidChange(PlatformDisplayID) override;
96
97    FloatSize screenSize() const override;
98    FloatSize availableScreenSize() const override;
99
100    void scrollRectIntoView(const IntRect&) const;
101
102    void contentsSizeChanged(Frame*, const IntSize&) const;
103
104    void setWindowRect(const FloatRect&) const;
105    FloatRect windowRect() const;
106
107    FloatRect pageRect() const;
108
109    void focus() const;
110    void unfocus() const;
111
112    bool canTakeFocus(FocusDirection) const;
113    void takeFocus(FocusDirection) const;
114
115    void focusedElementChanged(Element*) const;
116    void focusedFrameChanged(Frame*) const;
117
118    Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) const;
119    void show() const;
120
121    bool canRunModal() const;
122    bool canRunModalNow() const;
123    void runModal() const;
124
125    void setToolbarsVisible(bool) const;
126    bool toolbarsVisible() const;
127
128    void setStatusbarVisible(bool) const;
129    bool statusbarVisible() const;
130
131    void setScrollbarsVisible(bool) const;
132    bool scrollbarsVisible() const;
133
134    void setMenubarVisible(bool) const;
135    bool menubarVisible() const;
136
137    void setResizable(bool) const;
138
139    bool canRunBeforeUnloadConfirmPanel();
140    bool runBeforeUnloadConfirmPanel(const String& message, Frame*);
141
142    void closeWindowSoon();
143
144    void runJavaScriptAlert(Frame*, const String&);
145    bool runJavaScriptConfirm(Frame*, const String&);
146    bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
147    void setStatusbarText(Frame*, const String&);
148    bool shouldInterruptJavaScript();
149
150    IntRect windowResizerRect() const;
151
152    void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
153
154    void setToolTip(const HitTestResult&);
155
156    void print(Frame*);
157
158    void enableSuddenTermination();
159    void disableSuddenTermination();
160
161#if ENABLE(INPUT_TYPE_COLOR)
162    PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color& initialColor);
163#endif
164
165#if ENABLE(DATE_AND_TIME_INPUT_TYPES) && !PLATFORM(IOS)
166    PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&)
167#endif
168
169    void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
170    void loadIconForFiles(const Vector<String>&, FileIconLoader*);
171
172    void dispatchViewportPropertiesDidChange(const ViewportArguments&) const;
173
174    bool requiresFullscreenForVideoPlayback();
175
176#if PLATFORM(COCOA)
177    void focusNSView(NSView*);
178#endif
179
180    bool selectItemWritingDirectionIsNatural();
181    bool selectItemAlignmentFollowsMenuWritingDirection();
182    bool hasOpenedPopup() const;
183    PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
184    PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const;
185
186#if PLATFORM(IOS)
187    // FIXME: Can we come up with a better name for this setter?
188    void setDispatchViewportDataDidChangeSuppressed(bool dispatchViewportDataDidChangeSuppressed) { m_isDispatchViewportDataDidChangeSuppressed = dispatchViewportDataDidChangeSuppressed; }
189
190    void didReceiveDocType(Frame*);
191#endif
192
193    void registerPopupOpeningObserver(PopupOpeningObserver*);
194    void unregisterPopupOpeningObserver(PopupOpeningObserver*);
195
196private:
197    void notifyPopupOpeningObservers() const;
198
199    Page& m_page;
200    ChromeClient& m_client;
201    PlatformDisplayID m_displayID;
202    Vector<PopupOpeningObserver*> m_popupOpeningObservers;
203#if PLATFORM(IOS)
204    bool m_isDispatchViewportDataDidChangeSuppressed;
205#endif
206};
207
208}
209
210#endif // Chrome_h
211