aa85a92db9378d9e602343c6a4b998949cc1919d
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / loader / EmptyClients.h
1 /*
2  * Copyright (C) 2006 Eric Seidel (eric@webkit.org)
3  * Copyright (C) 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28
29 #ifndef EmptyClients_h
30 #define EmptyClients_h
31
32 #include "core/editing/UndoStep.h"
33 #include "core/inspector/InspectorClient.h"
34 #include "core/loader/FrameLoaderClient.h"
35 #include "core/page/BackForwardClient.h"
36 #include "core/page/ChromeClient.h"
37 #include "core/page/ContextMenuClient.h"
38 #include "core/page/DragClient.h"
39 #include "core/page/EditorClient.h"
40 #include "core/page/FocusDirection.h"
41 #include "core/page/Page.h"
42 #include "core/page/SpellCheckerClient.h"
43 #include "platform/DragImage.h"
44 #include "platform/geometry/FloatRect.h"
45 #include "platform/network/ResourceError.h"
46 #include "platform/text/TextCheckerClient.h"
47 #include "public/platform/WebScreenInfo.h"
48 #include "wtf/Forward.h"
49
50 #include <v8.h>
51
52 /*
53  This file holds empty Client stubs for use by WebCore.
54  Viewless element needs to create a dummy Page->Frame->FrameView tree for use in parsing or executing JavaScript.
55  This tree depends heavily on Clients (usually provided by WebKit classes).
56
57  This file was first created for SVGImage as it had no way to access the current Page (nor should it,
58  since Images are not tied to a page).
59  See http://bugs.webkit.org/show_bug.cgi?id=5971 for the original discussion about this file.
60
61  Ideally, whenever you change a Client class, you should add a stub here.
62  Brittle, yes.  Unfortunate, yes.  Hopefully temporary.
63 */
64
65 namespace WebCore {
66
67 class GraphicsContext3D;
68
69 class EmptyChromeClient : public ChromeClient {
70     WTF_MAKE_FAST_ALLOCATED;
71 public:
72     virtual ~EmptyChromeClient() { }
73     virtual void chromeDestroyed() OVERRIDE { }
74
75     virtual void* webView() const OVERRIDE { return 0; }
76     virtual void setWindowRect(const FloatRect&) OVERRIDE { }
77     virtual FloatRect windowRect() OVERRIDE { return FloatRect(); }
78
79     virtual FloatRect pageRect() OVERRIDE { return FloatRect(); }
80
81     virtual void focus() OVERRIDE { }
82     virtual void unfocus() OVERRIDE { }
83
84     virtual bool canTakeFocus(FocusDirection) OVERRIDE { return false; }
85     virtual void takeFocus(FocusDirection) OVERRIDE { }
86
87     virtual void focusedNodeChanged(Node*) OVERRIDE { }
88     virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) OVERRIDE { return 0; }
89     virtual void show(NavigationPolicy) OVERRIDE { }
90
91     virtual bool canRunModal() OVERRIDE { return false; }
92     virtual void runModal() OVERRIDE { }
93
94     virtual void setToolbarsVisible(bool) OVERRIDE { }
95     virtual bool toolbarsVisible() OVERRIDE { return false; }
96
97     virtual void setStatusbarVisible(bool) OVERRIDE { }
98     virtual bool statusbarVisible() OVERRIDE { return false; }
99
100     virtual void setScrollbarsVisible(bool) OVERRIDE { }
101     virtual bool scrollbarsVisible() OVERRIDE { return false; }
102
103     virtual void setMenubarVisible(bool) OVERRIDE { }
104     virtual bool menubarVisible() OVERRIDE { return false; }
105
106     virtual void setResizable(bool) OVERRIDE { }
107
108     virtual bool shouldReportDetailedMessageForSource(const String&) OVERRIDE { return false; }
109     virtual void addMessageToConsole(MessageSource, MessageLevel, const String&, unsigned, const String&, const String&) OVERRIDE { }
110
111     virtual bool canRunBeforeUnloadConfirmPanel() OVERRIDE { return false; }
112     virtual bool runBeforeUnloadConfirmPanel(const String&, Frame*) OVERRIDE { return true; }
113
114     virtual void closeWindowSoon() OVERRIDE { }
115
116     virtual void runJavaScriptAlert(Frame*, const String&) OVERRIDE { }
117     virtual bool runJavaScriptConfirm(Frame*, const String&) OVERRIDE { return false; }
118     virtual bool runJavaScriptPrompt(Frame*, const String&, const String&, String&) OVERRIDE { return false; }
119
120     virtual bool hasOpenedPopup() const OVERRIDE { return false; }
121     virtual PassRefPtr<PopupMenu> createPopupMenu(Frame&, PopupMenuClient*) const OVERRIDE;
122     virtual PagePopup* openPagePopup(PagePopupClient*, const IntRect&) OVERRIDE { return 0; }
123     virtual void closePagePopup(PagePopup*) OVERRIDE { }
124     virtual void setPagePopupDriver(PagePopupDriver*) OVERRIDE { }
125     virtual void resetPagePopupDriver() OVERRIDE { }
126
127     virtual void setStatusbarText(const String&) OVERRIDE { }
128
129     virtual bool tabsToLinks() OVERRIDE { return false; }
130
131     virtual IntRect windowResizerRect() const OVERRIDE { return IntRect(); }
132
133     virtual void invalidateContentsAndRootView(const IntRect&) OVERRIDE { }
134     virtual void invalidateContentsForSlowScroll(const IntRect&) OVERRIDE { }
135     virtual void scroll(const IntSize&, const IntRect&, const IntRect&) OVERRIDE { }
136     virtual void scheduleAnimation() OVERRIDE { }
137
138     virtual IntPoint screenToRootView(const IntPoint& p) const OVERRIDE { return p; }
139     virtual IntRect rootViewToScreen(const IntRect& r) const OVERRIDE { return r; }
140     virtual blink::WebScreenInfo screenInfo() const OVERRIDE { return blink::WebScreenInfo(); }
141     virtual void contentsSizeChanged(Frame*, const IntSize&) const OVERRIDE { }
142
143     virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned) OVERRIDE { }
144
145     virtual void setToolTip(const String&, TextDirection) OVERRIDE { }
146
147     virtual void print(Frame*) OVERRIDE { }
148
149     virtual void enumerateChosenDirectory(FileChooser*) OVERRIDE { }
150
151     virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) OVERRIDE;
152     virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) OVERRIDE;
153     virtual void openTextDataListChooser(HTMLInputElement&) OVERRIDE;
154
155     virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) OVERRIDE;
156
157     virtual void formStateDidChange(const Node*) OVERRIDE { }
158
159     virtual void setCursor(const Cursor&) OVERRIDE { }
160
161     virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) OVERRIDE { }
162     virtual void scheduleCompositingLayerFlush() OVERRIDE { }
163
164     virtual void needTouchEvents(bool) OVERRIDE { }
165     virtual void setTouchAction(TouchAction touchAction) OVERRIDE { };
166
167     virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE { }
168
169     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE { return false; }
170
171     virtual bool isEmptyChromeClient() const OVERRIDE { return true; }
172
173     virtual void didAssociateFormControls(const Vector<RefPtr<Element> >&) OVERRIDE { }
174
175     virtual void popupOpened(PopupContainer* popupContainer, const IntRect& bounds, bool handleExternal) OVERRIDE { }
176     virtual void popupClosed(PopupContainer* popupContainer) OVERRIDE { }
177
178     virtual void annotatedRegionsChanged() OVERRIDE { }
179     virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) OVERRIDE { return false; }
180     virtual String acceptLanguages() OVERRIDE;
181 };
182
183 class EmptyFrameLoaderClient FINAL : public FrameLoaderClient {
184     WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED;
185 public:
186     EmptyFrameLoaderClient() { }
187     virtual ~EmptyFrameLoaderClient() {  }
188
189     virtual bool hasWebView() const OVERRIDE { return true; } // mainly for assertions
190
191     virtual void detachedFromParent() OVERRIDE { }
192
193     virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) OVERRIDE { }
194     virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&) OVERRIDE { }
195     virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long) OVERRIDE { }
196     virtual void dispatchDidLoadResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&) OVERRIDE { }
197
198     virtual void dispatchDidHandleOnloadEvents() OVERRIDE { }
199     virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() OVERRIDE { }
200     virtual void dispatchWillClose() OVERRIDE { }
201     virtual void dispatchDidStartProvisionalLoad() OVERRIDE { }
202     virtual void dispatchDidReceiveTitle(const String&) OVERRIDE { }
203     virtual void dispatchDidChangeIcons(IconType) OVERRIDE { }
204     virtual void dispatchDidCommitLoad(Frame*, HistoryItem*, HistoryCommitType) OVERRIDE { }
205     virtual void dispatchDidFailProvisionalLoad(const ResourceError&) OVERRIDE { }
206     virtual void dispatchDidFailLoad(const ResourceError&) OVERRIDE { }
207     virtual void dispatchDidFinishDocumentLoad() OVERRIDE { }
208     virtual void dispatchDidFinishLoad() OVERRIDE { }
209     virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE { }
210
211     virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationPolicy) OVERRIDE;
212
213     virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) OVERRIDE;
214     virtual void dispatchWillSubmitForm(PassRefPtr<FormState>) OVERRIDE;
215
216     virtual void postProgressStartedNotification(LoadStartType) OVERRIDE { }
217     virtual void postProgressEstimateChangedNotification() OVERRIDE { }
218     virtual void postProgressFinishedNotification() OVERRIDE { }
219
220     virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& = String()) OVERRIDE { }
221
222     virtual PassRefPtr<DocumentLoader> createDocumentLoader(Frame*, const ResourceRequest&, const SubstituteData&) OVERRIDE;
223
224     virtual String userAgent(const KURL&) OVERRIDE { return ""; }
225
226     virtual String doNotTrackValue() OVERRIDE { return String(); }
227
228     virtual void transitionToCommittedForNewPage() OVERRIDE { }
229
230     virtual bool navigateBackForward(int offset) const OVERRIDE { return false; }
231     virtual void didDisplayInsecureContent() OVERRIDE { }
232     virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) OVERRIDE { }
233     virtual void didDetectXSS(const KURL&, bool) OVERRIDE { }
234     virtual void didDispatchPingLoader(const KURL&) OVERRIDE { }
235     virtual void selectorMatchChanged(const Vector<String>&, const Vector<String>&) OVERRIDE { }
236     virtual PassRefPtr<Frame> createFrame(const KURL&, const AtomicString&, const String&, HTMLFrameOwnerElement*) OVERRIDE;
237     virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) OVERRIDE;
238     virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) OVERRIDE;
239
240     virtual ObjectContentType objectContentType(const KURL&, const String&, bool) OVERRIDE { return ObjectContentType(); }
241
242     virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) OVERRIDE { }
243     virtual void documentElementAvailable() OVERRIDE { }
244
245     virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) OVERRIDE { }
246     virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) OVERRIDE { }
247     virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) OVERRIDE { return false; }
248
249     virtual blink::WebCookieJar* cookieJar() const OVERRIDE { return 0; }
250
251     virtual void didRequestAutocomplete(PassRefPtr<FormState>) OVERRIDE;
252     virtual PassOwnPtr<blink::WebServiceWorkerProvider> createServiceWorkerProvider(PassOwnPtr<blink::WebServiceWorkerProviderClient>) OVERRIDE;
253 };
254
255 class EmptyTextCheckerClient FINAL : public TextCheckerClient {
256 public:
257     virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const OVERRIDE { return true; }
258     virtual void checkSpellingOfString(const String&, int*, int*) OVERRIDE { }
259     virtual String getAutoCorrectSuggestionForMisspelledWord(const String&) OVERRIDE { return String(); }
260     virtual void checkGrammarOfString(const String&, Vector<GrammarDetail>&, int*, int*) OVERRIDE { }
261     virtual void requestCheckingOfString(PassRefPtr<TextCheckingRequest>) OVERRIDE;
262 };
263
264 class EmptySpellCheckerClient FINAL : public SpellCheckerClient {
265     WTF_MAKE_NONCOPYABLE(EmptySpellCheckerClient); WTF_MAKE_FAST_ALLOCATED;
266 public:
267     EmptySpellCheckerClient() { }
268     virtual ~EmptySpellCheckerClient() { }
269
270     virtual bool isContinuousSpellCheckingEnabled() OVERRIDE { return false; }
271     virtual void toggleContinuousSpellChecking() OVERRIDE { }
272     virtual bool isGrammarCheckingEnabled() OVERRIDE { return false; }
273
274     virtual TextCheckerClient& textChecker() OVERRIDE { return m_textCheckerClient; }
275
276     virtual void updateSpellingUIWithMisspelledWord(const String&) OVERRIDE { }
277     virtual void showSpellingUI(bool) OVERRIDE { }
278     virtual bool spellingUIIsShowing() OVERRIDE { return false; }
279
280 private:
281     EmptyTextCheckerClient m_textCheckerClient;
282 };
283
284 class EmptyEditorClient FINAL : public EditorClient {
285     WTF_MAKE_NONCOPYABLE(EmptyEditorClient); WTF_MAKE_FAST_ALLOCATED;
286 public:
287     EmptyEditorClient() { }
288     virtual ~EmptyEditorClient() { }
289
290     virtual void respondToChangedContents() OVERRIDE { }
291     virtual void respondToChangedSelection(SelectionType) OVERRIDE { }
292
293     virtual bool canCopyCut(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; }
294     virtual bool canPaste(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; }
295
296     virtual void didExecuteCommand(String) OVERRIDE { }
297     virtual bool handleKeyboardEvent() OVERRIDE { return false; }
298 };
299
300 class EmptyContextMenuClient FINAL : public ContextMenuClient {
301     WTF_MAKE_NONCOPYABLE(EmptyContextMenuClient); WTF_MAKE_FAST_ALLOCATED;
302 public:
303     EmptyContextMenuClient() { }
304     virtual ~EmptyContextMenuClient() {  }
305     virtual void showContextMenu(const ContextMenu*) OVERRIDE { }
306     virtual void clearContextMenu() OVERRIDE { }
307 };
308
309 class EmptyDragClient FINAL : public DragClient {
310     WTF_MAKE_NONCOPYABLE(EmptyDragClient); WTF_MAKE_FAST_ALLOCATED;
311 public:
312     EmptyDragClient() { }
313     virtual ~EmptyDragClient() {}
314     virtual DragDestinationAction actionMaskForDrag(DragData*) OVERRIDE { return DragDestinationActionNone; }
315     virtual void startDrag(DragImage*, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) OVERRIDE { }
316 };
317
318 class EmptyInspectorClient FINAL : public InspectorClient {
319     WTF_MAKE_NONCOPYABLE(EmptyInspectorClient); WTF_MAKE_FAST_ALLOCATED;
320 public:
321     EmptyInspectorClient() { }
322     virtual ~EmptyInspectorClient() { }
323
324     virtual void highlight() OVERRIDE { }
325     virtual void hideHighlight() OVERRIDE { }
326 };
327
328 class EmptyBackForwardClient FINAL : public BackForwardClient {
329 public:
330     virtual int backListCount() OVERRIDE { return 0; }
331     virtual int forwardListCount() OVERRIDE { return 0; }
332     virtual int backForwardListCount() OVERRIDE { return 0; }
333 };
334
335 void fillWithEmptyClients(Page::PageClients&);
336
337 }
338
339 #endif // EmptyClients_h