1 | /* |
2 | * Copyright (C) 2014-2018 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include "WKPage.h" |
29 | #include "WebEvent.h" |
30 | #include "WebHitTestResultData.h" |
31 | #include "WebPageProxy.h" |
32 | #include <WebCore/FloatRect.h> |
33 | #include <wtf/CompletionHandler.h> |
34 | |
35 | #if PLATFORM(IOS_FAMILY) |
36 | OBJC_CLASS NSArray; |
37 | OBJC_CLASS _WKActivatedElementInfo; |
38 | OBJC_CLASS UIViewController; |
39 | #endif |
40 | |
41 | namespace WebCore { |
42 | class RegistrableDomain; |
43 | class ResourceRequest; |
44 | struct FontAttributes; |
45 | struct SecurityOriginData; |
46 | struct WindowFeatures; |
47 | } |
48 | |
49 | namespace WebKit { |
50 | class NativeWebKeyboardEvent; |
51 | class NativeWebWheelEvent; |
52 | class NotificationPermissionRequest; |
53 | class UserMediaPermissionRequestProxy; |
54 | class WebColorPickerResultListenerProxy; |
55 | class WebFrameProxy; |
56 | class WebOpenPanelResultListenerProxy; |
57 | class WebPageProxy; |
58 | struct NavigationActionData; |
59 | |
60 | #if ENABLE(MEDIA_SESSION) |
61 | class WebMediaSessionMetadata; |
62 | #endif |
63 | } |
64 | |
65 | namespace API { |
66 | |
67 | class Data; |
68 | class Dictionary; |
69 | class Object; |
70 | class OpenPanelParameters; |
71 | class SecurityOrigin; |
72 | |
73 | class UIClient { |
74 | public: |
75 | virtual ~UIClient() { } |
76 | |
77 | virtual void createNewPage(WebKit::WebPageProxy&, WebCore::WindowFeatures&&, Ref<API::NavigationAction>&&, CompletionHandler<void(RefPtr<WebKit::WebPageProxy>&&)>&& completionHandler) { completionHandler(nullptr); } |
78 | virtual void showPage(WebKit::WebPageProxy*) { } |
79 | virtual void fullscreenMayReturnToInline(WebKit::WebPageProxy*) { } |
80 | virtual void didEnterFullscreen(WebKit::WebPageProxy*) { } |
81 | virtual void didExitFullscreen(WebKit::WebPageProxy*) { } |
82 | virtual void hasVideoInPictureInPictureDidChange(WebKit::WebPageProxy*, bool) { } |
83 | virtual void close(WebKit::WebPageProxy*) { } |
84 | |
85 | virtual bool takeFocus(WebKit::WebPageProxy*, WKFocusDirection) { return false; } |
86 | virtual void focus(WebKit::WebPageProxy*) { } |
87 | virtual void unfocus(WebKit::WebPageProxy*) { } |
88 | |
89 | virtual void runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void ()>&& completionHandler) { completionHandler(); } |
90 | virtual void runJavaScriptConfirm(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void (bool)>&& completionHandler) { completionHandler(false); } |
91 | virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void (const WTF::String&)>&& completionHandler) { completionHandler(WTF::String()); } |
92 | |
93 | virtual void setStatusText(WebKit::WebPageProxy*, const WTF::String&) { } |
94 | virtual void mouseDidMoveOverElement(WebKit::WebPageProxy&, const WebKit::WebHitTestResultData&, OptionSet<WebKit::WebEvent::Modifier>, Object*) { } |
95 | #if ENABLE(NETSCAPE_PLUGIN_API) |
96 | virtual void unavailablePluginButtonClicked(WebKit::WebPageProxy&, WKPluginUnavailabilityReason, Dictionary&) { } |
97 | #endif // ENABLE(NETSCAPE_PLUGIN_API) |
98 | |
99 | virtual void didNotHandleKeyEvent(WebKit::WebPageProxy*, const WebKit::NativeWebKeyboardEvent&) { } |
100 | virtual void didNotHandleWheelEvent(WebKit::WebPageProxy*, const WebKit::NativeWebWheelEvent&) { } |
101 | |
102 | virtual void toolbarsAreVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); } |
103 | virtual void setToolbarsAreVisible(WebKit::WebPageProxy&, bool) { } |
104 | virtual void (WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); } |
105 | virtual void (WebKit::WebPageProxy&, bool) { } |
106 | virtual void statusBarIsVisible(WebKit::WebPageProxy&, Function<void(bool)>&& completionHandler) { completionHandler(true); } |
107 | virtual void setStatusBarIsVisible(WebKit::WebPageProxy&, bool) { } |
108 | virtual void setIsResizable(WebKit::WebPageProxy&, bool) { } |
109 | |
110 | virtual void setWindowFrame(WebKit::WebPageProxy&, const WebCore::FloatRect&) { } |
111 | virtual void windowFrame(WebKit::WebPageProxy&, Function<void(WebCore::FloatRect)>&& completionHandler) { completionHandler({ }); } |
112 | |
113 | virtual bool canRunBeforeUnloadConfirmPanel() const { return false; } |
114 | virtual void runBeforeUnloadConfirmPanel(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, Function<void (bool)>&& completionHandler) { completionHandler(true); } |
115 | |
116 | virtual void pageDidScroll(WebKit::WebPageProxy*) { } |
117 | |
118 | virtual void exceededDatabaseQuota(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, SecurityOrigin*, const WTF::String&, const WTF::String&, unsigned long long currentQuota, unsigned long long, unsigned long long, unsigned long long, Function<void (unsigned long long)>&& completionHandler) |
119 | { |
120 | completionHandler(currentQuota); |
121 | } |
122 | |
123 | virtual void reachedApplicationCacheOriginQuota(WebKit::WebPageProxy*, const WebCore::SecurityOrigin&, uint64_t currentQuota, uint64_t, Function<void (unsigned long long)>&& completionHandler) |
124 | { |
125 | completionHandler(currentQuota); |
126 | } |
127 | |
128 | virtual bool needsFontAttributes() const { return false; } |
129 | virtual void didChangeFontAttributes(const WebCore::FontAttributes&) { } |
130 | |
131 | virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::SecurityOriginData&, OpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; } |
132 | virtual void decidePolicyForGeolocationPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, Function<void(bool)>&) { } |
133 | virtual void decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionRequestProxy& request) { request.deny(); } |
134 | virtual void checkUserMediaPermissionForOrigin(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, SecurityOrigin&, SecurityOrigin&, WebKit::UserMediaPermissionCheckProxy& request) { request.deny(); } |
135 | virtual void decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy&, SecurityOrigin&, Function<void(bool)>&& completionHandler) { completionHandler(false); } |
136 | virtual void requestStorageAccessConfirm(WebKit::WebPageProxy&, WebKit::WebFrameProxy*, const WebCore::RegistrableDomain& requestingDomain, const WebCore::RegistrableDomain& currentDomain, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); } |
137 | |
138 | // Printing. |
139 | virtual float (WebKit::WebPageProxy&, WebKit::WebFrameProxy&) { return 0; } |
140 | virtual float (WebKit::WebPageProxy&, WebKit::WebFrameProxy&) { return 0; } |
141 | virtual void (WebKit::WebPageProxy&, WebKit::WebFrameProxy&, WebCore::FloatRect&&) { } |
142 | virtual void (WebKit::WebPageProxy&, WebKit::WebFrameProxy&, WebCore::FloatRect&&) { } |
143 | virtual void printFrame(WebKit::WebPageProxy&, WebKit::WebFrameProxy&) { } |
144 | |
145 | virtual bool canRunModal() const { return false; } |
146 | virtual void runModal(WebKit::WebPageProxy&) { } |
147 | |
148 | virtual void saveDataToFileInDownloadsFolder(WebKit::WebPageProxy*, const WTF::String&, const WTF::String&, const WTF::URL&, Data&) { } |
149 | |
150 | virtual void pinnedStateDidChange(WebKit::WebPageProxy&) { } |
151 | |
152 | virtual void isPlayingMediaDidChange(WebKit::WebPageProxy&) { } |
153 | virtual void mediaCaptureStateDidChange(WebCore::MediaProducer::MediaStateFlags) { } |
154 | virtual void handleAutoplayEvent(WebKit::WebPageProxy&, WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) { } |
155 | |
156 | #if ENABLE(MEDIA_SESSION) |
157 | virtual void mediaSessionMetadataDidChange(WebKit::WebPageProxy&, WebKit::WebMediaSessionMetadata*) { } |
158 | #endif |
159 | |
160 | #if PLATFORM(IOS_FAMILY) |
161 | #if HAVE(APP_LINKS) |
162 | virtual bool shouldIncludeAppLinkActionsForElement(_WKActivatedElementInfo *) { return true; } |
163 | #endif |
164 | virtual RetainPtr<NSArray> actionsForElement(_WKActivatedElementInfo *, RetainPtr<NSArray> defaultActions) { return defaultActions; } |
165 | virtual void didNotHandleTapAsClick(const WebCore::IntPoint&) { } |
166 | virtual UIViewController *presentingViewController() { return nullptr; } |
167 | #endif |
168 | #if PLATFORM(COCOA) |
169 | virtual NSDictionary *dataDetectionContext() { return nullptr; } |
170 | #endif |
171 | |
172 | #if ENABLE(POINTER_LOCK) |
173 | virtual void requestPointerLock(WebKit::WebPageProxy*) { } |
174 | virtual void didLosePointerLock(WebKit::WebPageProxy*) { } |
175 | #endif |
176 | |
177 | #if ENABLE(DEVICE_ORIENTATION) |
178 | virtual void shouldAllowDeviceOrientationAndMotionAccess(WebKit::WebPageProxy&, WebKit::WebFrameProxy& webFrameProxy, const WebCore::SecurityOriginData&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(false); } |
179 | #endif |
180 | |
181 | virtual void didClickAutoFillButton(WebKit::WebPageProxy&, Object*) { } |
182 | |
183 | virtual void didResignInputElementStrongPasswordAppearance(WebKit::WebPageProxy&, Object*) { } |
184 | |
185 | virtual void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) { } |
186 | |
187 | virtual void didExceedBackgroundResourceLimitWhileInForeground(WebKit::WebPageProxy&, WKResourceLimit) { } |
188 | |
189 | virtual void didShowSafeBrowsingWarning() { } |
190 | }; |
191 | |
192 | } // namespace API |
193 | |