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.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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.
29 #ifndef EmptyClients_h
30 #define EmptyClients_h
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"
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).
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.
61 Ideally, whenever you change a Client class, you should add a stub here.
62 Brittle, yes. Unfortunate, yes. Hopefully temporary.
67 class GraphicsContext3D;
69 class EmptyChromeClient : public ChromeClient {
70 WTF_MAKE_FAST_ALLOCATED;
72 virtual ~EmptyChromeClient() { }
73 virtual void chromeDestroyed() OVERRIDE { }
75 virtual void* webView() const OVERRIDE { return 0; }
76 virtual void setWindowRect(const FloatRect&) OVERRIDE { }
77 virtual FloatRect windowRect() OVERRIDE { return FloatRect(); }
79 virtual FloatRect pageRect() OVERRIDE { return FloatRect(); }
81 virtual void focus() OVERRIDE { }
82 virtual void unfocus() OVERRIDE { }
84 virtual bool canTakeFocus(FocusDirection) OVERRIDE { return false; }
85 virtual void takeFocus(FocusDirection) OVERRIDE { }
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 { }
91 virtual bool canRunModal() OVERRIDE { return false; }
92 virtual void runModal() OVERRIDE { }
94 virtual void setToolbarsVisible(bool) OVERRIDE { }
95 virtual bool toolbarsVisible() OVERRIDE { return false; }
97 virtual void setStatusbarVisible(bool) OVERRIDE { }
98 virtual bool statusbarVisible() OVERRIDE { return false; }
100 virtual void setScrollbarsVisible(bool) OVERRIDE { }
101 virtual bool scrollbarsVisible() OVERRIDE { return false; }
103 virtual void setMenubarVisible(bool) OVERRIDE { }
104 virtual bool menubarVisible() OVERRIDE { return false; }
106 virtual void setResizable(bool) OVERRIDE { }
108 virtual bool shouldReportDetailedMessageForSource(const String&) OVERRIDE { return false; }
109 virtual void addMessageToConsole(MessageSource, MessageLevel, const String&, unsigned, const String&, const String&) OVERRIDE { }
111 virtual bool canRunBeforeUnloadConfirmPanel() OVERRIDE { return false; }
112 virtual bool runBeforeUnloadConfirmPanel(const String&, Frame*) OVERRIDE { return true; }
114 virtual void closeWindowSoon() OVERRIDE { }
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; }
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 { }
127 virtual void setStatusbarText(const String&) OVERRIDE { }
129 virtual bool tabsToLinks() OVERRIDE { return false; }
131 virtual IntRect windowResizerRect() const OVERRIDE { return IntRect(); }
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 { }
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 { }
143 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned) OVERRIDE { }
145 virtual void setToolTip(const String&, TextDirection) OVERRIDE { }
147 virtual void print(Frame*) OVERRIDE { }
149 virtual void enumerateChosenDirectory(FileChooser*) OVERRIDE { }
151 virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) OVERRIDE;
152 virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) OVERRIDE;
153 virtual void openTextDataListChooser(HTMLInputElement&) OVERRIDE;
155 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) OVERRIDE;
157 virtual void formStateDidChange(const Node*) OVERRIDE { }
159 virtual void setCursor(const Cursor&) OVERRIDE { }
161 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) OVERRIDE { }
162 virtual void scheduleCompositingLayerFlush() OVERRIDE { }
164 virtual void needTouchEvents(bool) OVERRIDE { }
165 virtual void setTouchAction(TouchAction touchAction) OVERRIDE { };
167 virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE { }
169 virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE { return false; }
171 virtual bool isEmptyChromeClient() const OVERRIDE { return true; }
173 virtual void didAssociateFormControls(const Vector<RefPtr<Element> >&) OVERRIDE { }
175 virtual void popupOpened(PopupContainer* popupContainer, const IntRect& bounds, bool handleExternal) OVERRIDE { }
176 virtual void popupClosed(PopupContainer* popupContainer) OVERRIDE { }
178 virtual void annotatedRegionsChanged() OVERRIDE { }
179 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) OVERRIDE { return false; }
180 virtual String acceptLanguages() OVERRIDE;
183 class EmptyFrameLoaderClient FINAL : public FrameLoaderClient {
184 WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED;
186 EmptyFrameLoaderClient() { }
187 virtual ~EmptyFrameLoaderClient() { }
189 virtual bool hasWebView() const OVERRIDE { return true; } // mainly for assertions
191 virtual void detachedFromParent() OVERRIDE { }
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 { }
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 { }
211 virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationPolicy) OVERRIDE;
213 virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) OVERRIDE;
214 virtual void dispatchWillSubmitForm(PassRefPtr<FormState>) OVERRIDE;
216 virtual void postProgressStartedNotification(LoadStartType) OVERRIDE { }
217 virtual void postProgressEstimateChangedNotification() OVERRIDE { }
218 virtual void postProgressFinishedNotification() OVERRIDE { }
220 virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& = String()) OVERRIDE { }
222 virtual PassRefPtr<DocumentLoader> createDocumentLoader(Frame*, const ResourceRequest&, const SubstituteData&) OVERRIDE;
224 virtual String userAgent(const KURL&) OVERRIDE { return ""; }
226 virtual String doNotTrackValue() OVERRIDE { return String(); }
228 virtual void transitionToCommittedForNewPage() OVERRIDE { }
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;
240 virtual ObjectContentType objectContentType(const KURL&, const String&, bool) OVERRIDE { return ObjectContentType(); }
242 virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) OVERRIDE { }
243 virtual void documentElementAvailable() OVERRIDE { }
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; }
249 virtual blink::WebCookieJar* cookieJar() const OVERRIDE { return 0; }
251 virtual void didRequestAutocomplete(PassRefPtr<FormState>) OVERRIDE;
252 virtual PassOwnPtr<blink::WebServiceWorkerProvider> createServiceWorkerProvider(PassOwnPtr<blink::WebServiceWorkerProviderClient>) OVERRIDE;
255 class EmptyTextCheckerClient FINAL : public TextCheckerClient {
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;
264 class EmptySpellCheckerClient FINAL : public SpellCheckerClient {
265 WTF_MAKE_NONCOPYABLE(EmptySpellCheckerClient); WTF_MAKE_FAST_ALLOCATED;
267 EmptySpellCheckerClient() { }
268 virtual ~EmptySpellCheckerClient() { }
270 virtual bool isContinuousSpellCheckingEnabled() OVERRIDE { return false; }
271 virtual void toggleContinuousSpellChecking() OVERRIDE { }
272 virtual bool isGrammarCheckingEnabled() OVERRIDE { return false; }
274 virtual TextCheckerClient& textChecker() OVERRIDE { return m_textCheckerClient; }
276 virtual void updateSpellingUIWithMisspelledWord(const String&) OVERRIDE { }
277 virtual void showSpellingUI(bool) OVERRIDE { }
278 virtual bool spellingUIIsShowing() OVERRIDE { return false; }
281 EmptyTextCheckerClient m_textCheckerClient;
284 class EmptyEditorClient FINAL : public EditorClient {
285 WTF_MAKE_NONCOPYABLE(EmptyEditorClient); WTF_MAKE_FAST_ALLOCATED;
287 EmptyEditorClient() { }
288 virtual ~EmptyEditorClient() { }
290 virtual void respondToChangedContents() OVERRIDE { }
291 virtual void respondToChangedSelection(SelectionType) OVERRIDE { }
293 virtual bool canCopyCut(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; }
294 virtual bool canPaste(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; }
296 virtual void didExecuteCommand(String) OVERRIDE { }
297 virtual bool handleKeyboardEvent() OVERRIDE { return false; }
300 class EmptyContextMenuClient FINAL : public ContextMenuClient {
301 WTF_MAKE_NONCOPYABLE(EmptyContextMenuClient); WTF_MAKE_FAST_ALLOCATED;
303 EmptyContextMenuClient() { }
304 virtual ~EmptyContextMenuClient() { }
305 virtual void showContextMenu(const ContextMenu*) OVERRIDE { }
306 virtual void clearContextMenu() OVERRIDE { }
309 class EmptyDragClient FINAL : public DragClient {
310 WTF_MAKE_NONCOPYABLE(EmptyDragClient); WTF_MAKE_FAST_ALLOCATED;
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 { }
318 class EmptyInspectorClient FINAL : public InspectorClient {
319 WTF_MAKE_NONCOPYABLE(EmptyInspectorClient); WTF_MAKE_FAST_ALLOCATED;
321 EmptyInspectorClient() { }
322 virtual ~EmptyInspectorClient() { }
324 virtual void highlight() OVERRIDE { }
325 virtual void hideHighlight() OVERRIDE { }
328 class EmptyBackForwardClient FINAL : public BackForwardClient {
330 virtual int backListCount() OVERRIDE { return 0; }
331 virtual int forwardListCount() OVERRIDE { return 0; }
332 virtual int backForwardListCount() OVERRIDE { return 0; }
335 void fillWithEmptyClients(Page::PageClients&);
339 #endif // EmptyClients_h