1 /* 2 * Copyright (C) 2006 Eric Seidel (eric (at) 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 "core/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 bool isCompositorFramePending() const OVERRIDE { return false; } 139 140 virtual IntPoint screenToRootView(const IntPoint& p) const OVERRIDE { return p; } 141 virtual IntRect rootViewToScreen(const IntRect& r) const OVERRIDE { return r; } 142 virtual blink::WebScreenInfo screenInfo() const OVERRIDE { return blink::WebScreenInfo(); } 143 virtual void contentsSizeChanged(Frame*, const IntSize&) const OVERRIDE { } 144 145 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned) OVERRIDE { } 146 147 virtual void setToolTip(const String&, TextDirection) OVERRIDE { } 148 149 virtual void print(Frame*) OVERRIDE { } 150 151 virtual void enumerateChosenDirectory(FileChooser*) OVERRIDE { } 152 153 virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) OVERRIDE; 154 virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) OVERRIDE; 155 virtual void openTextDataListChooser(HTMLInputElement&) OVERRIDE; 156 157 virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) OVERRIDE; 158 159 virtual void formStateDidChange(const Node*) OVERRIDE { } 160 161 virtual void setCursor(const Cursor&) OVERRIDE { } 162 163 virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) OVERRIDE { } 164 virtual void scheduleCompositingLayerFlush() OVERRIDE { } 165 166 virtual void needTouchEvents(bool) OVERRIDE { } 167 virtual void setTouchAction(TouchAction touchAction) OVERRIDE { }; 168 169 virtual void numWheelEventHandlersChanged(unsigned) OVERRIDE { } 170 171 virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const OVERRIDE { return false; } 172 173 virtual bool isEmptyChromeClient() const OVERRIDE { return true; } 174 175 virtual void didAssociateFormControls(const Vector<RefPtr<Element> >&) OVERRIDE { } 176 177 virtual void popupOpened(PopupContainer* popupContainer, const IntRect& bounds, 178 bool handleExternal) { } 179 virtual void popupClosed(PopupContainer* popupContainer) OVERRIDE { } 180 181 virtual void annotatedRegionsChanged() OVERRIDE { } 182 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) OVERRIDE { return false; } 183 virtual String acceptLanguages() OVERRIDE; 184 }; 185 186 class EmptyFrameLoaderClient : public FrameLoaderClient { 187 WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED; 188 public: 189 EmptyFrameLoaderClient() { } 190 virtual ~EmptyFrameLoaderClient() { } 191 virtual void frameLoaderDestroyed() OVERRIDE { } 192 193 virtual bool hasWebView() const OVERRIDE { return true; } // mainly for assertions 194 195 virtual void detachedFromParent() OVERRIDE { } 196 197 virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) OVERRIDE { } 198 virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&) OVERRIDE { } 199 virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long) OVERRIDE { } 200 virtual void dispatchDidLoadResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&) OVERRIDE { } 201 202 virtual void dispatchDidHandleOnloadEvents() OVERRIDE { } 203 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() OVERRIDE { } 204 virtual void dispatchWillClose() OVERRIDE { } 205 virtual void dispatchDidStartProvisionalLoad() OVERRIDE { } 206 virtual void dispatchDidReceiveTitle(const String&) OVERRIDE { } 207 virtual void dispatchDidChangeIcons(IconType) OVERRIDE { } 208 virtual void dispatchDidCommitLoad(Frame*, HistoryItem*, NavigationHistoryPolicy) OVERRIDE { } 209 virtual void dispatchDidFailProvisionalLoad(const ResourceError&) OVERRIDE { } 210 virtual void dispatchDidFailLoad(const ResourceError&) OVERRIDE { } 211 virtual void dispatchDidFinishDocumentLoad() OVERRIDE { } 212 virtual void dispatchDidFinishLoad() OVERRIDE { } 213 virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE { } 214 215 virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationPolicy) OVERRIDE; 216 217 virtual void dispatchWillSendSubmitEvent(PassRefPtr<FormState>) OVERRIDE; 218 virtual void dispatchWillSubmitForm(PassRefPtr<FormState>) OVERRIDE; 219 220 virtual void postProgressStartedNotification() OVERRIDE { } 221 virtual void postProgressEstimateChangedNotification() OVERRIDE { } 222 virtual void postProgressFinishedNotification() OVERRIDE { } 223 224 virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& = String()) OVERRIDE { } 225 226 virtual PassRefPtr<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) OVERRIDE; 227 228 virtual String userAgent(const KURL&) OVERRIDE { return ""; } 229 230 virtual String doNotTrackValue() OVERRIDE { return String(); } 231 232 virtual void transitionToCommittedForNewPage() OVERRIDE { } 233 234 virtual bool navigateBackForward(int offset) const OVERRIDE { return false; } 235 virtual void didDisplayInsecureContent() OVERRIDE { } 236 virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) OVERRIDE { } 237 virtual void didDetectXSS(const KURL&, bool) OVERRIDE { } 238 virtual void didDispatchPingLoader(const KURL&) OVERRIDE { } 239 virtual void selectorMatchChanged(const Vector<String>&, const Vector<String>&) OVERRIDE { } 240 virtual PassRefPtr<Frame> createFrame(const KURL&, const String&, const String&, HTMLFrameOwnerElement*) OVERRIDE; 241 virtual PassRefPtr<Widget> createPlugin(const IntSize&, HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool) OVERRIDE; 242 virtual PassRefPtr<Widget> createJavaAppletWidget(const IntSize&, HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) OVERRIDE; 243 244 virtual ObjectContentType objectContentType(const KURL&, const String&, bool) OVERRIDE { return ObjectContentType(); } 245 246 virtual void dispatchDidClearWindowObjectInWorld(DOMWrapperWorld*) OVERRIDE { } 247 virtual void documentElementAvailable() OVERRIDE { } 248 249 virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) OVERRIDE { } 250 virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) OVERRIDE { } 251 virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) OVERRIDE { return false; } 252 253 virtual blink::WebCookieJar* cookieJar() const { return 0; } 254 255 virtual void didRequestAutocomplete(PassRefPtr<FormState>) OVERRIDE; 256 virtual PassOwnPtr<blink::WebServiceWorkerProvider> createServiceWorkerProvider(PassOwnPtr<blink::WebServiceWorkerProviderClient>) OVERRIDE; 257 }; 258 259 class EmptyTextCheckerClient : public TextCheckerClient { 260 public: 261 virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const OVERRIDE { return true; } 262 virtual void checkSpellingOfString(const String&, int*, int*) OVERRIDE { } 263 virtual String getAutoCorrectSuggestionForMisspelledWord(const String&) OVERRIDE { return String(); } 264 virtual void checkGrammarOfString(const String&, Vector<GrammarDetail>&, int*, int*) OVERRIDE { } 265 virtual void requestCheckingOfString(PassRefPtr<TextCheckingRequest>) OVERRIDE; 266 }; 267 268 class EmptySpellCheckerClient : public SpellCheckerClient { 269 WTF_MAKE_NONCOPYABLE(EmptySpellCheckerClient); WTF_MAKE_FAST_ALLOCATED; 270 public: 271 EmptySpellCheckerClient() { } 272 virtual ~EmptySpellCheckerClient() { } 273 274 virtual bool isContinuousSpellCheckingEnabled() OVERRIDE { return false; } 275 virtual void toggleContinuousSpellChecking() OVERRIDE { } 276 virtual bool isGrammarCheckingEnabled() OVERRIDE { return false; } 277 278 TextCheckerClient& textChecker() { return m_textCheckerClient; } 279 280 virtual void updateSpellingUIWithMisspelledWord(const String&) OVERRIDE { } 281 virtual void showSpellingUI(bool) OVERRIDE { } 282 virtual bool spellingUIIsShowing() OVERRIDE { return false; } 283 284 private: 285 EmptyTextCheckerClient m_textCheckerClient; 286 }; 287 288 class EmptyEditorClient : public EditorClient { 289 WTF_MAKE_NONCOPYABLE(EmptyEditorClient); WTF_MAKE_FAST_ALLOCATED; 290 public: 291 EmptyEditorClient() { } 292 virtual ~EmptyEditorClient() { } 293 294 virtual void respondToChangedContents() OVERRIDE { } 295 virtual void respondToChangedSelection(SelectionType) OVERRIDE { } 296 297 virtual bool canCopyCut(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; } 298 virtual bool canPaste(Frame*, bool defaultValue) const OVERRIDE { return defaultValue; } 299 300 virtual void didExecuteCommand(String) OVERRIDE { } 301 virtual bool handleKeyboardEvent() OVERRIDE { return false; } 302 }; 303 304 class EmptyContextMenuClient : public ContextMenuClient { 305 WTF_MAKE_NONCOPYABLE(EmptyContextMenuClient); WTF_MAKE_FAST_ALLOCATED; 306 public: 307 EmptyContextMenuClient() { } 308 virtual ~EmptyContextMenuClient() { } 309 virtual void showContextMenu(const ContextMenu*) OVERRIDE { } 310 virtual void clearContextMenu() OVERRIDE { } 311 }; 312 313 class EmptyDragClient : public DragClient { 314 WTF_MAKE_NONCOPYABLE(EmptyDragClient); WTF_MAKE_FAST_ALLOCATED; 315 public: 316 EmptyDragClient() { } 317 virtual ~EmptyDragClient() {} 318 virtual DragDestinationAction actionMaskForDrag(DragData*) OVERRIDE { return DragDestinationActionNone; } 319 virtual void startDrag(DragImage*, const IntPoint&, const IntPoint&, Clipboard*, Frame*, bool) OVERRIDE { } 320 }; 321 322 class EmptyInspectorClient : public InspectorClient { 323 WTF_MAKE_NONCOPYABLE(EmptyInspectorClient); WTF_MAKE_FAST_ALLOCATED; 324 public: 325 EmptyInspectorClient() { } 326 virtual ~EmptyInspectorClient() { } 327 328 virtual void highlight() OVERRIDE { } 329 virtual void hideHighlight() OVERRIDE { } 330 }; 331 332 class EmptyBackForwardClient : public BackForwardClient { 333 public: 334 virtual int backListCount() OVERRIDE { return 0; } 335 virtual int forwardListCount() OVERRIDE { return 0; } 336 virtual int backForwardListCount() OVERRIDE { return 0; } 337 }; 338 339 void fillWithEmptyClients(Page::PageClients&); 340 341 } 342 343 #endif // EmptyClients_h 344