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/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/heap/Handle.h" 47 #include "platform/network/ResourceError.h" 48 #include "platform/text/TextCheckerClient.h" 49 #include "public/platform/WebScreenInfo.h" 50 #include "wtf/Forward.h" 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->LocalFrame->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 blink { 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 void focusedFrameChanged(LocalFrame*) OVERRIDE { } 87 virtual Page* createWindow(LocalFrame*, const FrameLoadRequest&, const WindowFeatures&, NavigationPolicy, ShouldSendReferrer) OVERRIDE { return 0; } 88 virtual void show(NavigationPolicy) OVERRIDE { } 89 90 virtual bool canRunModal() OVERRIDE { return false; } 91 virtual void runModal() OVERRIDE { } 92 93 virtual void setToolbarsVisible(bool) OVERRIDE { } 94 virtual bool toolbarsVisible() OVERRIDE { return false; } 95 96 virtual void setStatusbarVisible(bool) OVERRIDE { } 97 virtual bool statusbarVisible() OVERRIDE { return false; } 98 99 virtual void setScrollbarsVisible(bool) OVERRIDE { } 100 virtual bool scrollbarsVisible() OVERRIDE { return false; } 101 102 virtual void setMenubarVisible(bool) OVERRIDE { } 103 virtual bool menubarVisible() OVERRIDE { return false; } 104 105 virtual void setResizable(bool) OVERRIDE { } 106 107 virtual bool shouldReportDetailedMessageForSource(const String&) OVERRIDE { return false; } 108 virtual void addMessageToConsole(LocalFrame*, MessageSource, MessageLevel, const String&, unsigned, const String&, const String&) OVERRIDE { } 109 110 virtual bool canRunBeforeUnloadConfirmPanel() OVERRIDE { return false; } 111 virtual bool runBeforeUnloadConfirmPanel(const String&, LocalFrame*) OVERRIDE { return true; } 112 113 virtual void closeWindowSoon() OVERRIDE { } 114 115 virtual void runJavaScriptAlert(LocalFrame*, const String&) OVERRIDE { } 116 virtual bool runJavaScriptConfirm(LocalFrame*, const String&) OVERRIDE { return false; } 117 virtual bool runJavaScriptPrompt(LocalFrame*, const String&, const String&, String&) OVERRIDE { return false; } 118 119 virtual bool hasOpenedPopup() const OVERRIDE { return false; } 120 virtual PassRefPtrWillBeRawPtr<PopupMenu> createPopupMenu(LocalFrame&, PopupMenuClient*) const OVERRIDE; 121 virtual void setPagePopupDriver(PagePopupDriver*) OVERRIDE { } 122 virtual void resetPagePopupDriver() OVERRIDE { } 123 124 virtual void setStatusbarText(const String&) OVERRIDE { } 125 126 virtual bool tabsToLinks() OVERRIDE { return false; } 127 128 virtual IntRect windowResizerRect() const OVERRIDE { return IntRect(); } 129 130 virtual void invalidateContentsAndRootView(const IntRect&) OVERRIDE { } 131 virtual void invalidateContentsForSlowScroll(const IntRect&) OVERRIDE { } 132 virtual void scheduleAnimation() OVERRIDE { } 133 134 virtual IntRect rootViewToScreen(const IntRect& r) const OVERRIDE { return r; } 135 virtual blink::WebScreenInfo screenInfo() const OVERRIDE { return blink::WebScreenInfo(); } 136 virtual void contentsSizeChanged(LocalFrame*, const IntSize&) const OVERRIDE { } 137 138 virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned) OVERRIDE { } 139 140 virtual void setToolTip(const String&, TextDirection) OVERRIDE { } 141 142 virtual void print(LocalFrame*) OVERRIDE { } 143 144 virtual void enumerateChosenDirectory(FileChooser*) OVERRIDE { } 145 146 virtual PassOwnPtr<ColorChooser> createColorChooser(LocalFrame*, ColorChooserClient*, const Color&) OVERRIDE; 147 virtual PassRefPtr<DateTimeChooser> openDateTimeChooser(DateTimeChooserClient*, const DateTimeChooserParameters&) OVERRIDE; 148 virtual void openTextDataListChooser(HTMLInputElement&) OVERRIDE; 149 150 virtual void runOpenPanel(LocalFrame*, PassRefPtr<FileChooser>) OVERRIDE; 151 152 virtual void setCursor(const Cursor&) OVERRIDE { } 153 154 virtual void attachRootGraphicsLayer(GraphicsLayer*) OVERRIDE { } 155 156 virtual void needTouchEvents(bool) OVERRIDE { } 157 virtual void setTouchAction(TouchAction touchAction) OVERRIDE { }; 158 159 virtual void didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element> >&) OVERRIDE { } 160 161 virtual void annotatedRegionsChanged() OVERRIDE { } 162 virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&) OVERRIDE { return false; } 163 virtual String acceptLanguages() OVERRIDE; 164 }; 165 166 class EmptyFrameLoaderClient : public FrameLoaderClient { 167 WTF_MAKE_NONCOPYABLE(EmptyFrameLoaderClient); WTF_MAKE_FAST_ALLOCATED; 168 public: 169 EmptyFrameLoaderClient() { } 170 virtual ~EmptyFrameLoaderClient() { } 171 172 virtual bool hasWebView() const OVERRIDE { return true; } // mainly for assertions 173 174 virtual Frame* opener() const OVERRIDE { return 0; } 175 virtual void setOpener(Frame*) OVERRIDE { } 176 177 virtual Frame* parent() const OVERRIDE { return 0; } 178 virtual Frame* top() const OVERRIDE { return 0; } 179 virtual Frame* previousSibling() const OVERRIDE { return 0; } 180 virtual Frame* nextSibling() const OVERRIDE { return 0; } 181 virtual Frame* firstChild() const OVERRIDE { return 0; } 182 virtual Frame* lastChild() const OVERRIDE { return 0; } 183 virtual void detachedFromParent() OVERRIDE { } 184 185 virtual void dispatchWillSendRequest(DocumentLoader*, unsigned long, ResourceRequest&, const ResourceResponse&) OVERRIDE { } 186 virtual void dispatchDidReceiveResponse(DocumentLoader*, unsigned long, const ResourceResponse&) OVERRIDE { } 187 virtual void dispatchDidFinishLoading(DocumentLoader*, unsigned long) OVERRIDE { } 188 virtual void dispatchDidLoadResourceFromMemoryCache(const ResourceRequest&, const ResourceResponse&) OVERRIDE { } 189 190 virtual void dispatchDidHandleOnloadEvents() OVERRIDE { } 191 virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() OVERRIDE { } 192 virtual void dispatchWillClose() OVERRIDE { } 193 virtual void dispatchDidStartProvisionalLoad(bool isTransitionNavigation) OVERRIDE { } 194 virtual void dispatchDidReceiveTitle(const String&) OVERRIDE { } 195 virtual void dispatchDidChangeIcons(IconType) OVERRIDE { } 196 virtual void dispatchDidCommitLoad(LocalFrame*, HistoryItem*, HistoryCommitType) OVERRIDE { } 197 virtual void dispatchDidFailProvisionalLoad(const ResourceError&) OVERRIDE { } 198 virtual void dispatchDidFailLoad(const ResourceError&) OVERRIDE { } 199 virtual void dispatchDidFinishDocumentLoad() OVERRIDE { } 200 virtual void dispatchDidFinishLoad() OVERRIDE { } 201 virtual void dispatchDidFirstVisuallyNonEmptyLayout() OVERRIDE { } 202 virtual void dispatchDidChangeThemeColor() OVERRIDE { }; 203 204 virtual NavigationPolicy decidePolicyForNavigation(const ResourceRequest&, DocumentLoader*, NavigationPolicy, bool isTransitionNavigation) OVERRIDE; 205 206 virtual void dispatchWillSendSubmitEvent(HTMLFormElement*) OVERRIDE; 207 virtual void dispatchWillSubmitForm(HTMLFormElement*) OVERRIDE; 208 209 virtual void didStartLoading(LoadStartType) OVERRIDE { } 210 virtual void progressEstimateChanged(double) OVERRIDE { } 211 virtual void didStopLoading() OVERRIDE { } 212 213 virtual void loadURLExternally(const ResourceRequest&, NavigationPolicy, const String& = String()) OVERRIDE { } 214 215 virtual PassRefPtr<DocumentLoader> createDocumentLoader(LocalFrame*, const ResourceRequest&, const SubstituteData&) OVERRIDE; 216 217 virtual String userAgent(const KURL&) OVERRIDE { return ""; } 218 219 virtual String doNotTrackValue() OVERRIDE { return String(); } 220 221 virtual void transitionToCommittedForNewPage() OVERRIDE { } 222 223 virtual bool navigateBackForward(int offset) const OVERRIDE { return false; } 224 virtual void didDisplayInsecureContent() OVERRIDE { } 225 virtual void didRunInsecureContent(SecurityOrigin*, const KURL&) OVERRIDE { } 226 virtual void didDetectXSS(const KURL&, bool) OVERRIDE { } 227 virtual void didDispatchPingLoader(const KURL&) OVERRIDE { } 228 virtual void selectorMatchChanged(const Vector<String>&, const Vector<String>&) OVERRIDE { } 229 virtual PassRefPtrWillBeRawPtr<LocalFrame> createFrame(const KURL&, const AtomicString&, const Referrer&, HTMLFrameOwnerElement*) OVERRIDE; 230 virtual PassRefPtr<Widget> createPlugin(HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool, DetachedPluginPolicy) OVERRIDE; 231 virtual bool canCreatePluginWithoutRenderer(const String& mimeType) const OVERRIDE { return false; } 232 virtual PassRefPtr<Widget> createJavaAppletWidget(HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) OVERRIDE; 233 234 virtual ObjectContentType objectContentType(const KURL&, const String&, bool) OVERRIDE { return ObjectContentType(); } 235 236 virtual void dispatchDidClearWindowObjectInMainWorld() OVERRIDE { } 237 virtual void documentElementAvailable() OVERRIDE { } 238 239 virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) OVERRIDE { } 240 virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) OVERRIDE { } 241 virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) OVERRIDE { return false; } 242 243 virtual blink::WebCookieJar* cookieJar() const OVERRIDE { return 0; } 244 245 virtual void didRequestAutocomplete(HTMLFormElement*) OVERRIDE; 246 247 virtual PassOwnPtr<blink::WebServiceWorkerProvider> createServiceWorkerProvider() OVERRIDE; 248 virtual bool isControlledByServiceWorker() OVERRIDE { return false; } 249 virtual PassOwnPtr<blink::WebApplicationCacheHost> createApplicationCacheHost(blink::WebApplicationCacheHostClient*) OVERRIDE; 250 }; 251 252 class EmptyTextCheckerClient : public TextCheckerClient { 253 public: 254 ~EmptyTextCheckerClient() { } 255 256 virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const OVERRIDE { return true; } 257 virtual void checkSpellingOfString(const String&, int*, int*) OVERRIDE { } 258 virtual String getAutoCorrectSuggestionForMisspelledWord(const String&) OVERRIDE { return String(); } 259 virtual void checkGrammarOfString(const String&, Vector<GrammarDetail>&, int*, int*) OVERRIDE { } 260 virtual void requestCheckingOfString(PassRefPtrWillBeRawPtr<TextCheckingRequest>) OVERRIDE; 261 }; 262 263 class EmptySpellCheckerClient : public SpellCheckerClient { 264 WTF_MAKE_NONCOPYABLE(EmptySpellCheckerClient); WTF_MAKE_FAST_ALLOCATED; 265 public: 266 EmptySpellCheckerClient() { } 267 virtual ~EmptySpellCheckerClient() { } 268 269 virtual bool isContinuousSpellCheckingEnabled() OVERRIDE { return false; } 270 virtual void toggleContinuousSpellChecking() OVERRIDE { } 271 virtual bool isGrammarCheckingEnabled() OVERRIDE { return false; } 272 273 virtual TextCheckerClient& textChecker() OVERRIDE { return m_textCheckerClient; } 274 275 virtual void updateSpellingUIWithMisspelledWord(const String&) OVERRIDE { } 276 virtual void showSpellingUI(bool) OVERRIDE { } 277 virtual bool spellingUIIsShowing() OVERRIDE { return false; } 278 279 private: 280 EmptyTextCheckerClient m_textCheckerClient; 281 }; 282 283 class EmptyEditorClient FINAL : public EditorClient { 284 WTF_MAKE_NONCOPYABLE(EmptyEditorClient); WTF_MAKE_FAST_ALLOCATED; 285 public: 286 EmptyEditorClient() { } 287 virtual ~EmptyEditorClient() { } 288 289 virtual void respondToChangedContents() OVERRIDE { } 290 virtual void respondToChangedSelection(LocalFrame*, SelectionType) OVERRIDE { } 291 292 virtual bool canCopyCut(LocalFrame*, bool defaultValue) const OVERRIDE { return defaultValue; } 293 virtual bool canPaste(LocalFrame*, bool defaultValue) const OVERRIDE { return defaultValue; } 294 295 virtual bool handleKeyboardEvent() OVERRIDE { return false; } 296 }; 297 298 class EmptyContextMenuClient FINAL : public ContextMenuClient { 299 WTF_MAKE_NONCOPYABLE(EmptyContextMenuClient); WTF_MAKE_FAST_ALLOCATED; 300 public: 301 EmptyContextMenuClient() { } 302 virtual ~EmptyContextMenuClient() { } 303 virtual void showContextMenu(const ContextMenu*) OVERRIDE { } 304 virtual void clearContextMenu() OVERRIDE { } 305 }; 306 307 class EmptyDragClient FINAL : public DragClient { 308 WTF_MAKE_NONCOPYABLE(EmptyDragClient); WTF_MAKE_FAST_ALLOCATED; 309 public: 310 EmptyDragClient() { } 311 virtual ~EmptyDragClient() {} 312 virtual DragDestinationAction actionMaskForDrag(DragData*) OVERRIDE { return DragDestinationActionNone; } 313 virtual void startDrag(DragImage*, const IntPoint&, const IntPoint&, DataTransfer*, LocalFrame*, bool) OVERRIDE { } 314 }; 315 316 class EmptyInspectorClient FINAL : public InspectorClient { 317 WTF_MAKE_NONCOPYABLE(EmptyInspectorClient); WTF_MAKE_FAST_ALLOCATED; 318 public: 319 EmptyInspectorClient() { } 320 virtual ~EmptyInspectorClient() { } 321 322 virtual void highlight() OVERRIDE { } 323 virtual void hideHighlight() OVERRIDE { } 324 }; 325 326 class EmptyBackForwardClient FINAL : public BackForwardClient { 327 public: 328 virtual int backListCount() OVERRIDE { return 0; } 329 virtual int forwardListCount() OVERRIDE { return 0; } 330 virtual int backForwardListCount() OVERRIDE { return 0; } 331 }; 332 333 class EmptyStorageClient FINAL : public StorageClient { 334 public: 335 virtual PassOwnPtr<StorageNamespace> createSessionStorageNamespace() OVERRIDE; 336 virtual bool canAccessStorage(LocalFrame*, StorageType) const OVERRIDE { return false; } 337 }; 338 339 void fillWithEmptyClients(Page::PageClients&); 340 341 } 342 343 #endif // EmptyClients_h 344