1 | /* |
2 | * Copyright (C) 2010-2017 Apple Inc. All rights reserved. |
3 | * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. |
13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
16 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
17 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
18 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
24 | * THE POSSIBILITY OF SUCH DAMAGE. |
25 | */ |
26 | |
27 | #pragma once |
28 | |
29 | #include <WebCore/ChromeClient.h> |
30 | |
31 | namespace WebCore { |
32 | class HTMLImageElement; |
33 | class RegistrableDomain; |
34 | enum class StorageAccessPromptWasShown : bool; |
35 | enum class StorageAccessWasGranted : bool; |
36 | } |
37 | |
38 | namespace WebKit { |
39 | |
40 | class WebFrame; |
41 | class WebPage; |
42 | |
43 | class WebChromeClient final : public WebCore::ChromeClient { |
44 | public: |
45 | WebChromeClient(WebPage&); |
46 | |
47 | WebPage& page() const { return m_page; } |
48 | |
49 | private: |
50 | ~WebChromeClient(); |
51 | |
52 | void (WebCore::HTMLMenuElement&); |
53 | void (WebCore::HTMLMenuElement&); |
54 | void (WebCore::HTMLMenuItemElement&); |
55 | void (WebCore::HTMLMenuItemElement&); |
56 | |
57 | void chromeDestroyed() final; |
58 | |
59 | void setWindowRect(const WebCore::FloatRect&) final; |
60 | WebCore::FloatRect windowRect() final; |
61 | |
62 | WebCore::FloatRect () final; |
63 | |
64 | void focus() final; |
65 | void unfocus() final; |
66 | |
67 | bool canTakeFocus(WebCore::FocusDirection) final; |
68 | void takeFocus(WebCore::FocusDirection) final; |
69 | |
70 | void focusedElementChanged(WebCore::Element*) final; |
71 | void focusedFrameChanged(WebCore::Frame*) final; |
72 | |
73 | // The Frame pointer provides the ChromeClient with context about which |
74 | // Frame wants to create the new Page. Also, the newly created window |
75 | // should not be shown to the user until the ChromeClient of the newly |
76 | // created Page has its show method called. |
77 | WebCore::Page* createWindow(WebCore::Frame&, const WebCore::FrameLoadRequest&, const WebCore::WindowFeatures&, const WebCore::NavigationAction&) final; |
78 | void show() final; |
79 | |
80 | bool canRunModal() final; |
81 | void runModal() final; |
82 | |
83 | void reportProcessCPUTime(Seconds, WebCore::ActivityStateForCPUSampling) final; |
84 | |
85 | void setToolbarsVisible(bool) final; |
86 | bool toolbarsVisible() final; |
87 | |
88 | void setStatusbarVisible(bool) final; |
89 | bool statusbarVisible() final; |
90 | |
91 | void setScrollbarsVisible(bool) final; |
92 | bool scrollbarsVisible() final; |
93 | |
94 | void (bool) final; |
95 | bool () final; |
96 | |
97 | void setResizable(bool) final; |
98 | |
99 | void addMessageToConsole(JSC::MessageSource, JSC::MessageLevel, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID) final; |
100 | |
101 | bool canRunBeforeUnloadConfirmPanel() final; |
102 | bool runBeforeUnloadConfirmPanel(const String& message, WebCore::Frame&) final; |
103 | |
104 | void closeWindowSoon() final; |
105 | |
106 | void runJavaScriptAlert(WebCore::Frame&, const String&) final; |
107 | bool runJavaScriptConfirm(WebCore::Frame&, const String&) final; |
108 | bool runJavaScriptPrompt(WebCore::Frame&, const String& message, const String& defaultValue, String& result) final; |
109 | void setStatusbarText(const String&) final; |
110 | |
111 | WebCore::KeyboardUIMode keyboardUIMode() final; |
112 | |
113 | // HostWindow member function finals. |
114 | void invalidateRootView(const WebCore::IntRect&) final; |
115 | void invalidateContentsAndRootView(const WebCore::IntRect&) final; |
116 | void invalidateContentsForSlowScroll(const WebCore::IntRect&) final; |
117 | void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, const WebCore::IntRect& clipRect) final; |
118 | |
119 | WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const final; |
120 | WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const final; |
121 | |
122 | WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) const final; |
123 | WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) const final; |
124 | |
125 | void didFinishLoadingImageForElement(WebCore::HTMLImageElement&) final; |
126 | |
127 | PlatformPageClient platformPageClient() const final; |
128 | void contentsSizeChanged(WebCore::Frame&, const WebCore::IntSize&) const final; |
129 | void intrinsicContentsSizeChanged(const WebCore::IntSize&) const final; |
130 | void scrollRectIntoView(const WebCore::IntRect&) const final; // Currently only Mac has a non empty implementation. |
131 | |
132 | bool shouldUnavailablePluginMessageBeButton(WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final; |
133 | void unavailablePluginButtonClicked(WebCore::Element&, WebCore::RenderEmbeddedObject::PluginUnavailabilityReason) const final; |
134 | |
135 | void mouseDidMoveOverElement(const WebCore::HitTestResult&, unsigned modifierFlags) final; |
136 | |
137 | void setToolTip(const String&, WebCore::TextDirection) final; |
138 | |
139 | void print(WebCore::Frame&) final; |
140 | |
141 | void exceededDatabaseQuota(WebCore::Frame&, const String& databaseName, WebCore::DatabaseDetails) final; |
142 | |
143 | void reachedMaxAppCacheSize(int64_t spaceNeeded) final; |
144 | void reachedApplicationCacheOriginQuota(WebCore::SecurityOrigin&, int64_t spaceNeeded) final; |
145 | |
146 | bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename) final; |
147 | String generateReplacementFile(const String& path) final; |
148 | |
149 | #if ENABLE(INPUT_TYPE_COLOR) |
150 | std::unique_ptr<WebCore::ColorChooser> createColorChooser(WebCore::ColorChooserClient&, const WebCore::Color&) final; |
151 | #endif |
152 | |
153 | #if ENABLE(DATALIST_ELEMENT) |
154 | std::unique_ptr<WebCore::DataListSuggestionPicker> createDataListSuggestionPicker(WebCore::DataListSuggestionsClient&) final; |
155 | #endif |
156 | |
157 | #if ENABLE(IOS_TOUCH_EVENTS) |
158 | void didPreventDefaultForEvent() final; |
159 | #endif |
160 | |
161 | #if PLATFORM(IOS_FAMILY) |
162 | void didReceiveMobileDocType(bool) final; |
163 | void setNeedsScrollNotifications(WebCore::Frame&, bool) final; |
164 | void observedContentChange(WebCore::Frame&) final; |
165 | void notifyRevealedSelectionByScrollingFrame(WebCore::Frame&) final; |
166 | bool isStopping() final; |
167 | |
168 | void didLayout(LayoutType = NormalLayout) final; |
169 | void didStartOverflowScroll() final; |
170 | void didEndOverflowScroll() final; |
171 | bool hasStablePageScaleFactor() const final; |
172 | |
173 | // FIXME: See <rdar://problem/5975559> |
174 | void suppressFormNotifications() final; |
175 | void restoreFormNotifications() final; |
176 | |
177 | void addOrUpdateScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer, const WebCore::IntSize& scrollSize, bool allowHorizontalScrollbar, bool allowVerticalScrollbar) final; |
178 | void removeScrollingLayer(WebCore::Node*, PlatformLayer* scrollingLayer, PlatformLayer* contentsLayer) final; |
179 | |
180 | void webAppOrientationsUpdated() final; |
181 | void showPlaybackTargetPicker(bool hasVideo, WebCore::RouteSharingPolicy, const String&) final; |
182 | |
183 | Seconds eventThrottlingDelay() final; |
184 | |
185 | void associateEditableImageWithAttachment(WebCore::GraphicsLayer::EmbeddedViewID, const String& attachmentID) final; |
186 | void didCreateEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final; |
187 | void didDestroyEditableImage(WebCore::GraphicsLayer::EmbeddedViewID) final; |
188 | #endif |
189 | |
190 | #if ENABLE(ORIENTATION_EVENTS) |
191 | int deviceOrientation() const final; |
192 | #endif |
193 | |
194 | void runOpenPanel(WebCore::Frame&, WebCore::FileChooser&) final; |
195 | void showShareSheet(WebCore::ShareDataWithParsedURL&, WTF::CompletionHandler<void(bool)>&&) final; |
196 | void loadIconForFiles(const Vector<String>&, WebCore::FileIconLoader&) final; |
197 | |
198 | #if !PLATFORM(IOS_FAMILY) |
199 | void setCursor(const WebCore::Cursor&) final; |
200 | void setCursorHiddenUntilMouseMoves(bool) final; |
201 | #endif |
202 | |
203 | #if ENABLE(POINTER_LOCK) |
204 | bool requestPointerLock() final; |
205 | void requestPointerUnlock() final; |
206 | #endif |
207 | |
208 | void didAssociateFormControls(const Vector<RefPtr<WebCore::Element>>&, WebCore::Frame&) final; |
209 | bool shouldNotifyOnFormChanges() final; |
210 | |
211 | bool selectItemWritingDirectionIsNatural() final; |
212 | bool () final; |
213 | RefPtr<WebCore::PopupMenu> (WebCore::PopupMenuClient&) const final; |
214 | RefPtr<WebCore::SearchPopupMenu> (WebCore::PopupMenuClient&) const final; |
215 | |
216 | WebCore::GraphicsLayerFactory* graphicsLayerFactory() const final; |
217 | void attachRootGraphicsLayer(WebCore::Frame&, WebCore::GraphicsLayer*) final; |
218 | void attachViewOverlayGraphicsLayer(WebCore::GraphicsLayer*) final; |
219 | void setNeedsOneShotDrawingSynchronization() final; |
220 | void scheduleCompositingLayerFlush() final; |
221 | bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) final; |
222 | |
223 | void contentRuleListNotification(const URL&, const WebCore::ContentRuleListResults&) final; |
224 | |
225 | #if PLATFORM(WIN) |
226 | void setLastSetCursorToCurrentCursor() final { } |
227 | void AXStartFrameLoad() final { } |
228 | void AXFinishFrameLoad() final { } |
229 | #endif |
230 | |
231 | #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) |
232 | RefPtr<WebCore::DisplayRefreshMonitor> createDisplayRefreshMonitor(WebCore::PlatformDisplayID) const final; |
233 | #endif |
234 | |
235 | CompositingTriggerFlags allowedCompositingTriggers() const final |
236 | { |
237 | return static_cast<CompositingTriggerFlags>( |
238 | ThreeDTransformTrigger | |
239 | VideoTrigger | |
240 | PluginTrigger| |
241 | CanvasTrigger | |
242 | #if PLATFORM(MAC) || PLATFORM(IOS_FAMILY) |
243 | ScrollableNonMainFrameTrigger | |
244 | #endif |
245 | #if PLATFORM(IOS_FAMILY) |
246 | AnimatedOpacityTrigger | // Allow opacity animations to trigger compositing mode for iPhone: <rdar://problem/7830677> |
247 | #endif |
248 | AnimationTrigger); |
249 | } |
250 | |
251 | bool layerTreeStateIsFrozen() const final; |
252 | bool layerFlushThrottlingIsActive() const final; |
253 | |
254 | #if ENABLE(ASYNC_SCROLLING) |
255 | RefPtr<WebCore::ScrollingCoordinator> createScrollingCoordinator(WebCore::Page&) const final; |
256 | #endif |
257 | |
258 | #if (PLATFORM(IOS_FAMILY) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)) |
259 | bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final; |
260 | bool supportsVideoFullscreenStandby() final; |
261 | void setUpPlaybackControlsManager(WebCore::HTMLMediaElement&) final; |
262 | void clearPlaybackControlsManager() final; |
263 | void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool standby) final; |
264 | void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) final; |
265 | #endif |
266 | |
267 | #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE) |
268 | void exitVideoFullscreenToModeWithoutAnimation(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) final; |
269 | #endif |
270 | |
271 | #if ENABLE(FULLSCREEN_API) |
272 | bool supportsFullScreenForElement(const WebCore::Element&, bool withKeyboard) final; |
273 | void enterFullScreenForElement(WebCore::Element&) final; |
274 | void exitFullScreenForElement(WebCore::Element*) final; |
275 | #endif |
276 | |
277 | #if PLATFORM(COCOA) |
278 | void elementDidFocus(WebCore::Element&) final; |
279 | void elementDidBlur(WebCore::Element&) final; |
280 | void elementDidRefocus(WebCore::Element&) final; |
281 | void focusedElementDidChangeInputMode(WebCore::Element&, WebCore::InputMode) final; |
282 | |
283 | void makeFirstResponder() final; |
284 | void assistiveTechnologyMakeFirstResponder() final; |
285 | #endif |
286 | |
287 | void enableSuddenTermination() final; |
288 | void disableSuddenTermination() final; |
289 | |
290 | #if PLATFORM(IOS_FAMILY) |
291 | WebCore::FloatSize screenSize() const final; |
292 | WebCore::FloatSize availableScreenSize() const final; |
293 | WebCore::FloatSize overrideScreenSize() const final; |
294 | #endif |
295 | |
296 | void dispatchDisabledAdaptationsDidChange(const OptionSet<WebCore::DisabledAdaptations>&) const final; |
297 | void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const final; |
298 | |
299 | void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&) final; |
300 | void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle newStyle) final; |
301 | |
302 | Optional<WebCore::ScrollbarOverlayStyle> preferredScrollbarOverlayStyle() final; |
303 | |
304 | WebCore::Color underlayColor() const final; |
305 | |
306 | void pageExtendedBackgroundColorDidChange(WebCore::Color) const final; |
307 | |
308 | void wheelEventHandlersChanged(bool) final; |
309 | |
310 | String plugInStartLabelTitle(const String& mimeType) const final; |
311 | String plugInStartLabelSubtitle(const String& mimeType) const final; |
312 | String () const final; |
313 | String () const final; |
314 | |
315 | void (WebCore::GraphicsLayer&) final; |
316 | void (WebCore::GraphicsLayer&) final; |
317 | |
318 | bool shouldUseTiledBackingForFrameView(const WebCore::FrameView&) const final; |
319 | |
320 | void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t) final; |
321 | void handleAutoplayEvent(WebCore::AutoplayEvent, OptionSet<WebCore::AutoplayEventFlags>) final; |
322 | |
323 | #if ENABLE(MEDIA_SESSION) |
324 | void hasMediaSessionWithActiveMediaElementsDidChange(bool) final; |
325 | void mediaSessionMetadataDidChange(const WebCore::MediaSessionMetadata&) final; |
326 | void focusedContentMediaElementDidChange(uint64_t) final; |
327 | #endif |
328 | |
329 | #if ENABLE(WEB_CRYPTO) |
330 | bool wrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final; |
331 | bool unwrapCryptoKey(const Vector<uint8_t>&, Vector<uint8_t>&) const final; |
332 | #endif |
333 | |
334 | String signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&) const final; |
335 | |
336 | #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC) |
337 | void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&) final; |
338 | #endif |
339 | |
340 | #if ENABLE(SERVICE_CONTROLS) |
341 | void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) final; |
342 | bool hasRelevantSelectionServices(bool isTextOnly) const final; |
343 | #endif |
344 | |
345 | bool shouldDispatchFakeMouseMoveEvents() const final; |
346 | |
347 | void handleAutoFillButtonClick(WebCore::HTMLInputElement&) final; |
348 | |
349 | void inputElementDidResignStrongPasswordAppearance(WebCore::HTMLInputElement&) final; |
350 | |
351 | #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS_FAMILY) |
352 | void addPlaybackTargetPickerClient(uint64_t /*contextId*/) final; |
353 | void removePlaybackTargetPickerClient(uint64_t /*contextId*/) final; |
354 | void showPlaybackTargetPicker(uint64_t contextId, const WebCore::IntPoint&, bool) final; |
355 | void playbackTargetPickerClientStateDidChange(uint64_t, WebCore::MediaProducer::MediaStateFlags) final; |
356 | void setMockMediaPlaybackTargetPickerEnabled(bool) final; |
357 | void setMockMediaPlaybackTargetPickerState(const String&, WebCore::MediaPlaybackTargetContext::State) final; |
358 | #endif |
359 | |
360 | void imageOrMediaDocumentSizeChanged(const WebCore::IntSize&) final; |
361 | |
362 | RefPtr<WebCore::Icon> createIconForFiles(const Vector<String>& filenames) final; |
363 | |
364 | #if ENABLE(VIDEO) && USE(GSTREAMER) |
365 | void requestInstallMissingMediaPlugins(const String& /*details*/, const String& /*description*/, WebCore::MediaPlayerRequestInstallMissingPluginsCallback&) final; |
366 | #endif |
367 | |
368 | void didInvalidateDocumentMarkerRects() final; |
369 | |
370 | #if ENABLE(RESOURCE_LOAD_STATISTICS) |
371 | void hasStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, uint64_t frameID, WebCore::PageIdentifier, WTF::CompletionHandler<void(bool)>&&) final; |
372 | void requestStorageAccess(WebCore::RegistrableDomain&& subFrameDomain, WebCore::RegistrableDomain&& topFrameDomain, uint64_t frameID, WebCore::PageIdentifier, WTF::CompletionHandler<void(WebCore::StorageAccessWasGranted, WebCore::StorageAccessPromptWasShown)>&&) final; |
373 | #endif |
374 | |
375 | #if ENABLE(DEVICE_ORIENTATION) |
376 | void shouldAllowDeviceOrientationAndMotionAccess(WebCore::Frame&, bool mayPrompt, CompletionHandler<void(WebCore::DeviceOrientationOrMotionPermissionState)>&&) final; |
377 | #endif |
378 | |
379 | void configureLoggingChannel(const String&, WTFLogChannelState, WTFLogLevel) final; |
380 | |
381 | bool userIsInteracting() const final; |
382 | void setUserIsInteracting(bool) final; |
383 | |
384 | String m_cachedToolTip; |
385 | mutable RefPtr<WebFrame> m_cachedFrameSetLargestFrame; |
386 | mutable bool m_cachedMainFrameHasHorizontalScrollbar { false }; |
387 | mutable bool m_cachedMainFrameHasVerticalScrollbar { false }; |
388 | |
389 | WebPage& m_page; |
390 | }; |
391 | |
392 | } // namespace WebKit |
393 | |