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 "core/loader/NavigationPolicy.h"
26#include "core/page/FocusDirection.h"
27#include "core/platform/Cursor.h"
28#include "core/platform/HostWindow.h"
29#include "wtf/Forward.h"
30
31namespace WebCore {
32
33class ChromeClient;
34class ColorChooser;
35class ColorChooserClient;
36class DateTimeChooser;
37class DateTimeChooserClient;
38class FileChooser;
39class FloatRect;
40class Frame;
41class Geolocation;
42class HitTestResult;
43class IntRect;
44class Node;
45class Page;
46class PopupMenu;
47class PopupMenuClient;
48class PopupOpeningObserver;
49class SearchPopupMenu;
50
51struct DateTimeChooserParameters;
52struct ViewportArguments;
53struct WindowFeatures;
54
55class Chrome : public HostWindow {
56public:
57    ~Chrome();
58
59    static PassOwnPtr<Chrome> create(Page*, ChromeClient*);
60
61    ChromeClient* client() { return m_client; }
62
63    // HostWindow methods.
64    virtual void invalidateContentsAndRootView(const IntRect&) OVERRIDE;
65    virtual void invalidateContentsForSlowScroll(const IntRect&) OVERRIDE;
66    virtual void scroll(const IntSize&, const IntRect&, const IntRect&) OVERRIDE;
67    virtual IntPoint screenToRootView(const IntPoint&) const OVERRIDE;
68    virtual IntRect rootViewToScreen(const IntRect&) const OVERRIDE;
69    virtual WebKit::WebScreenInfo screenInfo() const OVERRIDE;
70    virtual void setCursor(const Cursor&) OVERRIDE;
71
72    virtual void scheduleAnimation() OVERRIDE;
73
74    void contentsSizeChanged(Frame*, const IntSize&) const;
75    void layoutUpdated(Frame*) const;
76
77    void setWindowRect(const FloatRect&) const;
78    FloatRect windowRect() const;
79
80    FloatRect pageRect() const;
81
82    void focus() const;
83    void unfocus() const;
84
85    bool canTakeFocus(FocusDirection) const;
86    void takeFocus(FocusDirection) const;
87
88    void focusedNodeChanged(Node*) const;
89
90    void show(NavigationPolicy = NavigationPolicyIgnore) const;
91
92    bool canRunModal() const;
93    bool canRunModalNow() const;
94    void runModal() const;
95
96    void setWindowFeatures(const WindowFeatures&) const;
97
98    bool toolbarsVisible() const;
99    bool statusbarVisible() const;
100    bool scrollbarsVisible() const;
101    bool menubarVisible() const;
102
103    bool canRunBeforeUnloadConfirmPanel();
104    bool runBeforeUnloadConfirmPanel(const String& message, Frame*);
105
106    void closeWindowSoon();
107
108    void runJavaScriptAlert(Frame*, const String&);
109    bool runJavaScriptConfirm(Frame*, const String&);
110    bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
111    void setStatusbarText(Frame*, const String&);
112
113    IntRect windowResizerRect() const;
114
115    void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
116
117    void setToolTip(const HitTestResult&);
118
119    void print(Frame*);
120
121    PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color& initialColor);
122    PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&);
123
124    void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
125    void enumerateChosenDirectory(FileChooser*);
126
127    void dispatchViewportPropertiesDidChange(const ViewportArguments&) const;
128
129    bool hasOpenedPopup() const;
130    PassRefPtr<PopupMenu> createPopupMenu(Frame&, PopupMenuClient*) const;
131
132    void registerPopupOpeningObserver(PopupOpeningObserver*);
133    void unregisterPopupOpeningObserver(PopupOpeningObserver*);
134
135private:
136    Chrome(Page*, ChromeClient*);
137    void notifyPopupOpeningObservers() const;
138
139    Page* m_page;
140    ChromeClient* m_client;
141    Vector<PopupOpeningObserver*> m_popupOpeningObservers;
142};
143
144}
145
146#endif // Chrome_h
147