Upstream version 5.34.104.0
[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/FocusType.h"
41 #include "core/page/Page.h"
42 #include "core/page/SpellCheckerClient.h"
43 #include "core/page/StorageClient.h"
44 #include "platform/DragImage.h"
45 #include "platform/geometry/FloatRect.h"
46 #include "platform/network/ResourceError.h"
47 #include "platform/text/TextCheckerClient.h"
48 #include "public/platform/WebScreenInfo.h"
49 #include "wtf/Forward.h"
50
51 #include <v8.h>
52
53 /*
54  This file holds empty Client stubs for use by WebCore.
55  Viewless element needs to create a dummy Page->Frame->FrameView tree for use in parsing or executing JavaScript.
56  This tree depends heavily on Clients (usually provided by WebKit classes).
57
58  This file was first created for SVGImage as it had no way to access the current Page (nor should it,
59  since Images are not tied to a page).
60  See http://bugs.webkit.org/show_bug.cgi?id=5971 for the original discussion about this file.
61
62  Ideally, whenever you change a Client class, you should add a stub here.
63  Brittle, yes.  Unfortunate, yes.  Hopefully temporary.
64 */
65
66 namespace WebCore {
67
68 class EmptyChromeClient : public ChromeClient {
69     WTF_MAKE_FAST_ALLOCATED;
70 public:
71     virtual ~EmptyChromeClient() { }
72     virtual void chromeDestroyed() OVERRIDE { }
73
74     virtual void* webView() const OVERRIDE { return 0; }
75     virtual void setWindowRect(const FloatRect&) OVERRIDE { }
76     virtual FloatRect windowRect() OVERRIDE { return FloatRect(); }
77
78     virtual FloatRect pageRect() OVERRIDE { return FloatRect(); }
79
80     virtual void focus() OVERRIDE { }
81
82     virtual bool canTakeFocus(FocusType) OVERRIDE { return false; }
83     virtual void takeFocus(FocusType) OVERRIDE { }
84
85     virtual void focusedNodeChanged(Node*) OVERRIDE { }
86     virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) OVERRIDE { return 0; }
87     virtual void show(NavigationPolicy) OVERRIDE { }
88
89     virtual bool canRunModal() OVERRIDE { return false; }
90     virtual void runModal() OVERRIDE { }
91
92     virtual void setToolbarsVisible(bool) OVERRIDE { }
93     virtual bool toolbarsVisible() OVERRIDE { return false; }
94
95     virtual void setStatusbarVisible(bool) OVERRIDE { }
96     virtual bool statusbarVisible() OVERRIDE { return false; }
97
98     virtual void setScrollbarsVisible(bool) OVERRIDE { }
99     virtual bool scrollbarsVisible() OVERRIDE { return false; }
100
101     virtual void setMenubarVisible(bool) OVERRIDE { }
102     virtual bool menubarVisible() OVERRIDE { return false; }
103
104     virtual void setResizable(bool) OVERRIDE { }
105
106     virtual bool shouldReportDetailedMessageForSource(const String&) OVERRIDE { return false; }
107     virtual void addMessageToConsole(MessageSource, MessageLevel, const String&, unsigned, const String&, const String&) OVERRIDE { }
108
109     virtual bool canRunBeforeUnloadConfirmPanel() OVERRIDE { return false; }
110     virtual bool runBeforeUnloadConfirmPanel(const String&, Frame*) OVERRIDE { return true; }
111
112     virtual void closeWindowSoon() OVERRIDE { }
113
114     virtual void runJavaScriptAlert(Frame*, const String&) OVERRIDE { }
115     virtual bool runJavaScriptConfirm(Frame*, const String&) OVERRIDE { return false; }
116     virtual bool runJavaScriptPrompt(Frame*, const String&, const String&, String&) OVERRIDE { return false; }
117
118     virtual bool hasOpenedPopup() const OVERRIDE { return false; }
119     virtual PassRefPtr<PopupMenu> createPopupMenu(Frame&, PopupMenuClient*) const OVERRIDE;
120     virtual void setPagePopupDriver(PagePopupDriver*) OVERRIDE { }
121     virtual void resetPagePopupDriver() OVERRIDE { }
122
123     virtual void setStatusbarText(const String&) OVERRIDE { }
124
125     virtual bool tabsToLinks() OVERRIDE { return false; }
126
127     virtual IntRect windowResizerRect() const OVERRIDE { return IntRect(); }
128
129     virtual void invalidateContentsAndRootView(const IntRect&) OVERRIDE { }
130     virtual void invalidateContentsForSlowScroll(const IntRect&) OVERRIDE { }
131     virtual void scroll(const IntSize&, const IntRect&, const IntRect&) OVERRIDE { }
132     virtual void scheduleAnimation() OVERRIDE { }
133
134     virtual bool isCompositorFramePending() const OVERRIDE { return false; }
135
136     virtual IntRect rootViewToScreen(const IntRect& r) const OVERRIDE { return r; }
137     virtual blink::WebScreenInfo screenInfo() const OVERRIDE { return blink::WebScreenInfo(); }
138     virtual void contentsSizeChanged(Frame*, const IntSize&) const OVERRIDE { }
139
140     virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned) OVERRIDE { }
141
142     virtual void setToolTip(const String&, TextDirection) OVERRIDE { }
143
144     virtual void print(Frame*) OVERRIDE { }
145
146     virtual void enumerateChosenDirectory(FileChooser*) OVERRIDE { }
147
148     virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) OVERRIDE;
149     virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) OVERRIDE;
150     virtual void openTextDataListChooser(HTMLInputElement&) OVERRIDE;
151
152     virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) OVERRIDE;
153
154     virtual void formStateDidChange(const Node*) OVERRIDE { }
155
156     virtual void setCursor(const Cursor&) OVERRIDE { }
157
158     virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) OVERRIDE { }
159
160     virtual void needTouchEvents(bool) OVERRIDE { }
161     virtual void setTouchAction(TouchAction touchAction) OVERRIDE { };
162
163     virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE { }
164
165     virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE { return false; }
166
167     virtual void didAssociateFormControls(const Vector<RefPtr<Element> >&) OVERRIDE { }
168
169     virtual void annotatedRegionsChanged() OVERRIDE { }
170     virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) OVERRIDE { return false; }
171     virtual String acceptLanguages() OVERRIDE;
172 };
173
174 class EmptyFrameLoaderClient FINAL : public FrameLoaderClient {
175     WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED;
176 public:
177     EmptyFrameLoaderClient() { }
178     virtual ~EmptyFrameLoaderClient() {  }
179
180     virtual bool hasWebView() const OVERRIDE { return true; } // mainly for assertions
181
182     virtual Frame* parent() const OVERRIDE { return 0; }
183     virtual Frame* top() const OVERRIDE { return 0; }
184     virtual Frame* previousSibling() const OVERRIDE { return 0; }
185     virtual Frame* nextSibling() const OVERRIDE { return 0; }
186     virtual Frame* firstChild() const OVERRIDE { return 0; }
187     virtual Frame* lastChild() const OVERRIDE { return 0; }
188     virtual void detachedFromParent() OVERRIDE { }
189
190     virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) OVERRIDE { }
191     virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&) OVERRIDE { }
192     virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long) OVERRIDE { }
193     virtual void dispatchDidLoadResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&) OVERRIDE { }
194
195     virtual void dispatchDidHandleOnloadEvents() OVERRIDE { }
196     virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() OVERRIDE { }
197     virtual void dispatchWillClose() OVERRIDE { }
198     virtual void dispatchDidStartProvisionalLoad() OVERRIDE { }
199     virtual void dispatchDidReceiveTitle(const String&) OVERRIDE { }
200     virtual void dispatchDidChangeIcons(IconType) OVERRIDE { }
201     virtual void dispatchDidCommitLoad(Frame*, HistoryItem*, HistoryCommitType) OVERRIDE { }
202     virtual void dispatchDidFailProvisionalLoad(const ResourceError&) OVERRIDE { }
203     virtual void dispatchDidFailLoad(const ResourceError&) OVERRIDE { }
204     virtual void dispatchDidFinishDocumentLoad() OVERRIDE { }
205     virtual void dispatchDidFinishLoad() OVERRIDE { }
206     virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE { }
207
208     virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationPolicy) OVERRIDE;
209
210     virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) OVERRIDE;
211     virtual void dispatchWillSubmitForm(PassRefPtr<FormState>) OVERRIDE;
212
213     virtual void postProgressStartedNotification(LoadStartType) OVERRIDE { }
214     virtual void postProgressEstimateChangedNotification() OVERRIDE { }
215     virtual void postProgressFinishedNotification() OVERRIDE { }
216
217     virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& = String()) OVERRIDE { }
218
219     virtual PassRefPtr<DocumentLoader> createDocumentLoader(Frame*, const ResourceRequest&, const SubstituteData&) OVERRIDE;
220
221     virtual String userAgent(const KURL&) OVERRIDE { return ""; }
222
223     virtual String doNotTrackValue() OVERRIDE { return String(); }
224
225     virtual void transitionToCommittedForNewPage() OVERRIDE { }
226
227     virtual bool navigateBackForward(int offset) const OVERRIDE { return false; }
228     virtual void didDisplayInsecureContent() OVERRIDE { }
229     virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) OVERRIDE { }
230     virtual void didDetectXSS(const KURL&, bool) OVERRIDE { }
231     virtual void didDispatchPingLoader(const KURL&) OVERRIDE { }
232     virtual void selectorMatchChanged(const Vector<String>&, const Vector<String>&) OVERRIDE { }
233     virtual PassRefPtr<Frame> createFrame(const KURL&, const AtomicString&, const Referrer&, HTMLFrameOwnerElement*) OVERRIDE;
234     virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) OVERRIDE;
235     virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) OVERRIDE;
236
237     virtual ObjectContentType objectContentType(const KURL&, const String&, bool) OVERRIDE { return ObjectContentType(); }
238
239     virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) OVERRIDE { }
240     virtual void documentElementAvailable() OVERRIDE { }
241
242     virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) OVERRIDE { }
243     virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) OVERRIDE { }
244     virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) OVERRIDE { return false; }
245
246     virtual blink::WebCookieJar* cookieJar() const OVERRIDE { return 0; }
247
248     virtual void didRequestAutocomplete(PassRefPtr<FormState>) OVERRIDE;
249     virtual PassOwnPtr<blink::WebServiceWorkerProvider> createServiceWorkerProvider(PassOwnPtr<blink::WebServiceWorkerProviderClient>) OVERRIDE;
250 };
251
252 class EmptyTextCheckerClient FINAL : public TextCheckerClient {
253 public:
254     virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const OVERRIDE { return true; }
255     virtual void checkSpellingOfString(const String&, int*, int*) OVERRIDE { }
256     virtual String getAutoCorrectSuggestionForMisspelledWord(const String&) OVERRIDE { return String(); }
257     virtual void checkGrammarOfString(const String&, Vector<GrammarDetail>&, int*, int*) OVERRIDE { }
258     virtual void requestCheckingOfString(PassRefPtr<TextCheckingRequest>) OVERRIDE;
259 };
260
261 class EmptySpellCheckerClient FINAL : public SpellCheckerClient {
262     WTF_MAKE_NONCOPYABLE(EmptySpellCheckerClient); WTF_MAKE_FAST_ALLOCATED;
263 public:
264     EmptySpellCheckerClient() { }
265     virtual ~EmptySpellCheckerClient() { }
266
267     virtual bool isContinuousSpellCheckingEnabled() OVERRIDE { return false; }
268     virtual void toggleContinuousSpellChecking() OVERRIDE { }
269     virtual bool isGrammarCheckingEnabled() OVERRIDE { return false; }
270
271     virtual TextCheckerClient& textChecker() OVERRIDE { return m_textCheckerClient; }
272
273     virtual void updateSpellingUIWithMisspelledWord(const String&) OVERRIDE { }
274     virtual void showSpellingUI(bool) OVERRIDE { }
275     virtual bool spellingUIIsShowing() OVERRIDE { return false; }
276
277 private:
278     EmptyTextCheckerClient m_textCheckerClient;
279 };
280
281 class EmptyEditorClient FINAL : public EditorClient {
282     WTF_MAKE_NONCOPYABLE(EmptyEditorClient); WTF_MAKE_FAST_ALLOCATED;
283 public:
284     EmptyEditorClient() { }
285     virtual ~EmptyEditorClient() { }
286
287     virtual void respondToChangedContents() OVERRIDE { }
288     virtual void respondToChangedSelection(SelectionType) OVERRIDE { }
289
290     virtual bool canCopyCut(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; }
291     virtual bool canPaste(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; }
292
293     virtual void didExecuteCommand(String) OVERRIDE { }
294     virtual bool handleKeyboardEvent() OVERRIDE { return false; }
295 };
296
297 class EmptyContextMenuClient FINAL : public ContextMenuClient {
298     WTF_MAKE_NONCOPYABLE(EmptyContextMenuClient); WTF_MAKE_FAST_ALLOCATED;
299 public:
300     EmptyContextMenuClient() { }
301     virtual ~EmptyContextMenuClient() {  }
302     virtual void showContextMenu(const ContextMenu*) OVERRIDE { }
303     virtual void clearContextMenu() OVERRIDE { }
304 };
305
306 class EmptyDragClient FINAL : public DragClient {
307     WTF_MAKE_NONCOPYABLE(EmptyDragClient); WTF_MAKE_FAST_ALLOCATED;
308 public:
309     EmptyDragClient() { }
310     virtual ~EmptyDragClient() {}
311     virtual DragDestinationAction actionMaskForDrag(DragData*) OVERRIDE { return DragDestinationActionNone; }
312     virtual void startDrag(DragImage*, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) OVERRIDE { }
313 };
314
315 class EmptyInspectorClient FINAL : public InspectorClient {
316     WTF_MAKE_NONCOPYABLE(EmptyInspectorClient); WTF_MAKE_FAST_ALLOCATED;
317 public:
318     EmptyInspectorClient() { }
319     virtual ~EmptyInspectorClient() { }
320
321     virtual void highlight() OVERRIDE { }
322     virtual void hideHighlight() OVERRIDE { }
323 };
324
325 class EmptyBackForwardClient FINAL : public BackForwardClient {
326 public:
327     virtual int backListCount() OVERRIDE { return 0; }
328     virtual int forwardListCount() OVERRIDE { return 0; }
329     virtual int backForwardListCount() OVERRIDE { return 0; }
330 };
331
332 class EmptyStorageClient FINAL : public StorageClient {
333 public:
334     virtual PassOwnPtr<StorageNamespace> createSessionStorageNamespace() OVERRIDE;
335     virtual bool canAccessStorage(Frame*, StorageType) const OVERRIDE { return false; }
336 };
337
338 void fillWithEmptyClients(Page::PageClients&);
339
340 }
341
342 #endif // EmptyClients_h