1/*
2 * Copyright (C) 2006 Eric Seidel (eric@webkit.org)
3 * Copyright (C) 2008-2017 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 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 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#pragma once
30
31#include "ChromeClient.h"
32#include <wtf/UniqueRef.h>
33
34// Empty client classes for use by WebCore.
35//
36// First created for SVGImage as it had no way to access the current Page (nor should it, since Images are not tied to a page).
37// See http://bugs.webkit.org/show_bug.cgi?id=5971 for the original discussion about this file.
38
39namespace WebCore {
40
41class DiagnosticLoggingClient;
42class EditorClient;
43class HTMLImageElement;
44class PageConfiguration;
45
46class EmptyChromeClient : public ChromeClient {
47 WTF_MAKE_FAST_ALLOCATED;
48
49 void chromeDestroyed() override { }
50
51 void setWindowRect(const FloatRect&) final { }
52 FloatRect windowRect() final { return FloatRect(); }
53
54 FloatRect pageRect() final { return FloatRect(); }
55
56 void focus() final { }
57 void unfocus() final { }
58
59 bool canTakeFocus(FocusDirection) final { return false; }
60 void takeFocus(FocusDirection) final { }
61
62 void focusedElementChanged(Element*) final { }
63 void focusedFrameChanged(Frame*) final { }
64
65 Page* createWindow(Frame&, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) final { return nullptr; }
66 void show() final { }
67
68 bool canRunModal() final { return false; }
69 void runModal() final { }
70
71 void setToolbarsVisible(bool) final { }
72 bool toolbarsVisible() final { return false; }
73
74 void setStatusbarVisible(bool) final { }
75 bool statusbarVisible() final { return false; }
76
77 void setScrollbarsVisible(bool) final { }
78 bool scrollbarsVisible() final { return false; }
79
80 void setMenubarVisible(bool) final { }
81 bool menubarVisible() final { return false; }
82
83 void setResizable(bool) final { }
84
85 void addMessageToConsole(MessageSource, MessageLevel, const String&, unsigned, unsigned, const String&) final { }
86
87 bool canRunBeforeUnloadConfirmPanel() final { return false; }
88 bool runBeforeUnloadConfirmPanel(const String&, Frame&) final { return true; }
89
90 void closeWindowSoon() final { }
91
92 void runJavaScriptAlert(Frame&, const String&) final { }
93 bool runJavaScriptConfirm(Frame&, const String&) final { return false; }
94 bool runJavaScriptPrompt(Frame&, const String&, const String&, String&) final { return false; }
95
96 bool selectItemWritingDirectionIsNatural() final { return false; }
97 bool selectItemAlignmentFollowsMenuWritingDirection() final { return false; }
98 RefPtr<PopupMenu> createPopupMenu(PopupMenuClient&) const final;
99 RefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient&) const final;
100
101 void setStatusbarText(const String&) final { }
102
103 KeyboardUIMode keyboardUIMode() final { return KeyboardAccessDefault; }
104
105 void invalidateRootView(const IntRect&) final { }
106 void invalidateContentsAndRootView(const IntRect&) override { }
107 void invalidateContentsForSlowScroll(const IntRect&) final { }
108 void scroll(const IntSize&, const IntRect&, const IntRect&) final { }
109
110 IntPoint screenToRootView(const IntPoint& p) const final { return p; }
111 IntRect rootViewToScreen(const IntRect& r) const final { return r; }
112 IntPoint accessibilityScreenToRootView(const IntPoint& p) const final { return p; };
113 IntRect rootViewToAccessibilityScreen(const IntRect& r) const final { return r; };
114
115 void didFinishLoadingImageForElement(HTMLImageElement&) final { }
116
117 PlatformPageClient platformPageClient() const final { return 0; }
118 void contentsSizeChanged(Frame&, const IntSize&) const final { }
119 void intrinsicContentsSizeChanged(const IntSize&) const final { }
120
121 void mouseDidMoveOverElement(const HitTestResult&, unsigned) final { }
122
123 void setToolTip(const String&, TextDirection) final { }
124
125 void print(Frame&) final { }
126
127 void exceededDatabaseQuota(Frame&, const String&, DatabaseDetails) final { }
128
129 void reachedMaxAppCacheSize(int64_t) final { }
130 void reachedApplicationCacheOriginQuota(SecurityOrigin&, int64_t) final { }
131
132#if ENABLE(INPUT_TYPE_COLOR)
133 std::unique_ptr<ColorChooser> createColorChooser(ColorChooserClient&, const Color&) final;
134#endif
135
136#if ENABLE(DATALIST_ELEMENT)
137 std::unique_ptr<DataListSuggestionPicker> createDataListSuggestionPicker(DataListSuggestionsClient&) final;
138#endif
139
140 void runOpenPanel(Frame&, FileChooser&) final;
141 void showShareSheet(ShareDataWithParsedURL&, CompletionHandler<void(bool)>&&) final;
142 void loadIconForFiles(const Vector<String>&, FileIconLoader&) final { }
143
144 void elementDidFocus(Element&) final { }
145 void elementDidBlur(Element&) final { }
146
147#if !PLATFORM(IOS_FAMILY)
148 void setCursor(const Cursor&) final { }
149 void setCursorHiddenUntilMouseMoves(bool) final { }
150#endif
151
152 void scrollRectIntoView(const IntRect&) const final { }
153
154 void attachRootGraphicsLayer(Frame&, GraphicsLayer*) final { }
155 void attachViewOverlayGraphicsLayer(GraphicsLayer*) final { }
156 void setNeedsOneShotDrawingSynchronization() final { }
157 void scheduleCompositingLayerFlush() final { }
158
159#if PLATFORM(WIN)
160 void setLastSetCursorToCurrentCursor() final { }
161 void AXStartFrameLoad() final { }
162 void AXFinishFrameLoad() final { }
163#endif
164
165#if ENABLE(IOS_TOUCH_EVENTS)
166 void didPreventDefaultForEvent() final { }
167#endif
168
169#if PLATFORM(IOS_FAMILY)
170 void didReceiveMobileDocType(bool) final { }
171 void setNeedsScrollNotifications(Frame&, bool) final { }
172 void observedContentChange(Frame&) final { }
173 void notifyRevealedSelectionByScrollingFrame(Frame&) final { }
174 void didLayout(LayoutType) final { }
175 void didStartOverflowScroll() final { }
176 void didEndOverflowScroll() final { }
177
178 void suppressFormNotifications() final { }
179 void restoreFormNotifications() final { }
180
181 void addOrUpdateScrollingLayer(Node*, PlatformLayer*, PlatformLayer*, const IntSize&, bool, bool) final { }
182 void removeScrollingLayer(Node*, PlatformLayer*, PlatformLayer*) final { }
183
184 void webAppOrientationsUpdated() final { };
185 void showPlaybackTargetPicker(bool, RouteSharingPolicy, const String&) final { };
186#endif // PLATFORM(IOS_FAMILY)
187
188#if ENABLE(ORIENTATION_EVENTS)
189 int deviceOrientation() const final { return 0; }
190#endif
191
192#if PLATFORM(IOS_FAMILY)
193 bool isStopping() final { return false; }
194#endif
195
196 void wheelEventHandlersChanged(bool) final { }
197
198 bool isEmptyChromeClient() const final { return true; }
199
200 void didAssociateFormControls(const Vector<RefPtr<Element>>&, Frame&) final { }
201 bool shouldNotifyOnFormChanges() final { return false; }
202
203 RefPtr<Icon> createIconForFiles(const Vector<String>& /* filenames */) final { return nullptr; }
204};
205
206DiagnosticLoggingClient& emptyDiagnosticLoggingClient();
207WEBCORE_EXPORT PageConfiguration pageConfigurationWithEmptyClients();
208
209}
210