Update To 11.40.268.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/ChromeClient.h"
36 #include "core/page/ContextMenuClient.h"
37 #include "core/page/DragClient.h"
38 #include "core/page/EditorClient.h"
39 #include "core/page/FocusType.h"
40 #include "core/page/Page.h"
41 #include "core/page/SpellCheckerClient.h"
42 #include "core/page/StorageClient.h"
43 #include "platform/DragImage.h"
44 #include "platform/geometry/FloatRect.h"
45 #include "platform/heap/Handle.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 #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->LocalFrame->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 blink {
66
67 class EmptyChromeClient : public ChromeClient {
68     WTF_MAKE_FAST_ALLOCATED;
69 public:
70     virtual ~EmptyChromeClient() { }
71     virtual void chromeDestroyed() override { }
72
73     virtual void* webView() const override { return 0; }
74     virtual void setWindowRect(const FloatRect&) override { }
75     virtual FloatRect windowRect() override { return FloatRect(); }
76
77     virtual FloatRect pageRect() override { return FloatRect(); }
78
79     virtual void focus() override { }
80
81     virtual bool canTakeFocus(FocusType) override { return false; }
82     virtual void takeFocus(FocusType) override { }
83
84     virtual void focusedNodeChanged(Node*) override { }
85     virtual void focusedFrameChanged(LocalFrame*) override { }
86     virtual Page* createWindow(LocalFrame*, 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(LocalFrame*, MessageSource, MessageLevel, const String&, unsigned, const String&, const String&) override { }
108
109     virtual bool canRunBeforeUnloadConfirmPanel() override { return false; }
110     virtual bool runBeforeUnloadConfirmPanel(const String&, LocalFrame*) override { return true; }
111
112     virtual void closeWindowSoon() override { }
113
114     virtual void runJavaScriptAlert(LocalFrame*, const String&) override { }
115     virtual bool runJavaScriptConfirm(LocalFrame*, const String&) override { return false; }
116     virtual bool runJavaScriptPrompt(LocalFrame*, const String&, const String&, String&) override { return false; }
117
118     virtual bool hasOpenedPopup() const override { return false; }
119     virtual PassRefPtrWillBeRawPtr<PopupMenu> createPopupMenu(LocalFrame&, PopupMenuClient*) const override;
120     virtual void setPagePopupDriver(PagePopupDriver*) override { }
121     virtual void resetPagePopupDriver() override { }
122     virtual PagePopupDriver* pagePopupDriver() const override { return nullptr; }
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 PassOwnPtrWillBeRawPtr<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 detached() 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&, HTMLFrameOwnerElement*) override;
230     virtual PassOwnPtrWillBeRawPtr<PluginPlaceholder> createPluginPlaceholder(Document&, const KURL&, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) override;
231     virtual PassRefPtrWillBeRawPtr<Widget> createPlugin(HTMLPlugInElement*, const KURL&, const Vector<String>&, const Vector<String>&, const String&, bool, DetachedPluginPolicy) override;
232     virtual bool canCreatePluginWithoutRenderer(const String& mimeType) const override { return false; }
233     virtual PassRefPtrWillBeRawPtr<Widget> createJavaAppletWidget(HTMLAppletElement*, const KURL&, const Vector<String>&, const Vector<String>&) override;
234
235     virtual ObjectContentType objectContentType(const KURL&, const String&, bool) override { return ObjectContentType(); }
236
237     virtual void dispatchDidClearWindowObjectInMainWorld() override { }
238     virtual void documentElementAvailable() override { }
239
240     virtual void didCreateScriptContext(v8::Handle<v8::Context>, int extensionGroup, int worldId) override { }
241     virtual void willReleaseScriptContext(v8::Handle<v8::Context>, int worldId) override { }
242     virtual bool allowScriptExtension(const String& extensionName, int extensionGroup, int worldId) override { return false; }
243
244     virtual blink::WebCookieJar* cookieJar() const override { return 0; }
245
246     virtual void didRequestAutocomplete(HTMLFormElement*) override;
247
248     virtual PassOwnPtr<blink::WebServiceWorkerProvider> createServiceWorkerProvider() override;
249     virtual bool isControlledByServiceWorker(DocumentLoader&) override { return false; }
250     virtual int64_t serviceWorkerID(DocumentLoader&) override { return -1; }
251     virtual PassOwnPtr<blink::WebApplicationCacheHost> createApplicationCacheHost(blink::WebApplicationCacheHostClient*) override;
252 };
253
254 class EmptyTextCheckerClient : public TextCheckerClient {
255 public:
256     ~EmptyTextCheckerClient() { }
257
258     virtual bool shouldEraseMarkersAfterChangeSelection(TextCheckingType) const override { return true; }
259     virtual void checkSpellingOfString(const String&, int*, int*) override { }
260     virtual String getAutoCorrectSuggestionForMisspelledWord(const String&) override { return String(); }
261     virtual void checkGrammarOfString(const String&, Vector<GrammarDetail>&, int*, int*) override { }
262     virtual void requestCheckingOfString(PassRefPtrWillBeRawPtr<TextCheckingRequest>) override;
263 };
264
265 class EmptySpellCheckerClient : public SpellCheckerClient {
266     WTF_MAKE_NONCOPYABLE(EmptySpellCheckerClient); WTF_MAKE_FAST_ALLOCATED;
267 public:
268     EmptySpellCheckerClient() { }
269     virtual ~EmptySpellCheckerClient() { }
270
271     virtual bool isContinuousSpellCheckingEnabled() override { return false; }
272     virtual void toggleContinuousSpellChecking() override { }
273     virtual bool isGrammarCheckingEnabled() override { return false; }
274
275     virtual TextCheckerClient& textChecker() override { return m_textCheckerClient; }
276
277     virtual void updateSpellingUIWithMisspelledWord(const String&) override { }
278     virtual void showSpellingUI(bool) override { }
279     virtual bool spellingUIIsShowing() override { return false; }
280
281 private:
282     EmptyTextCheckerClient m_textCheckerClient;
283 };
284
285 class EmptyEditorClient final : public EditorClient {
286     WTF_MAKE_NONCOPYABLE(EmptyEditorClient); WTF_MAKE_FAST_ALLOCATED;
287 public:
288     EmptyEditorClient() { }
289     virtual ~EmptyEditorClient() { }
290
291     virtual void respondToChangedContents() override { }
292     virtual void respondToChangedSelection(LocalFrame*, SelectionType) override { }
293
294     virtual bool canCopyCut(LocalFrame*, bool defaultValue) const override { return defaultValue; }
295     virtual bool canPaste(LocalFrame*, bool defaultValue) const override { return defaultValue; }
296
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&, DataTransfer*, LocalFrame*, 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 EmptyStorageClient final : public StorageClient {
329 public:
330     virtual PassOwnPtr<StorageNamespace> createSessionStorageNamespace() override;
331     virtual bool canAccessStorage(LocalFrame*, StorageType) const override { return false; }
332 };
333
334 void fillWithEmptyClients(Page::PageClients&);
335
336 }
337
338 #endif // EmptyClients_h