Storage Access API: Web process should ask UI process for grant/deny
[WebKit-https.git] / Source / WebKit / WebProcess / WebCoreSupport / WebChromeClient.cpp
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 #include "config.h"
28 #include "WebChromeClient.h"
29
30 #include "APIArray.h"
31 #include "APISecurityOrigin.h"
32 #include "DrawingArea.h"
33 #include "FindController.h"
34 #include "FrameInfoData.h"
35 #include "HangDetectionDisabler.h"
36 #include "InjectedBundleNavigationAction.h"
37 #include "InjectedBundleNodeHandle.h"
38 #include "NavigationActionData.h"
39 #include "PageBanner.h"
40 #include "UserData.h"
41 #include "WebColorChooser.h"
42 #include "WebCoreArgumentCoders.h"
43 #include "WebFrame.h"
44 #include "WebFrameLoaderClient.h"
45 #include "WebFullScreenManager.h"
46 #include "WebHitTestResultData.h"
47 #include "WebImage.h"
48 #include "WebOpenPanelResultListener.h"
49 #include "WebPage.h"
50 #include "WebPageCreationParameters.h"
51 #include "WebPageProxyMessages.h"
52 #include "WebPopupMenu.h"
53 #include "WebProcess.h"
54 #include "WebProcessPoolMessages.h"
55 #include "WebProcessProxyMessages.h"
56 #include "WebSearchPopupMenu.h"
57 #include <WebCore/ApplicationCacheStorage.h>
58 #include <WebCore/AXObjectCache.h>
59 #include <WebCore/ColorChooser.h>
60 #include <WebCore/DatabaseTracker.h>
61 #include <WebCore/DocumentLoader.h>
62 #include <WebCore/FileChooser.h>
63 #include <WebCore/FileIconLoader.h>
64 #include <WebCore/FrameLoadRequest.h>
65 #include <WebCore/FrameLoader.h>
66 #include <WebCore/FrameView.h>
67 #include <WebCore/HTMLInputElement.h>
68 #include <WebCore/HTMLNames.h>
69 #include <WebCore/HTMLParserIdioms.h>
70 #include <WebCore/HTMLPlugInImageElement.h>
71 #include <WebCore/Icon.h>
72 #include <WebCore/MainFrame.h>
73 #include <WebCore/NotImplemented.h>
74 #include <WebCore/Page.h>
75 #include <WebCore/ScriptController.h>
76 #include <WebCore/SecurityOrigin.h>
77 #include <WebCore/SecurityOriginData.h>
78 #include <WebCore/Settings.h>
79
80 #if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
81 #include "PlaybackSessionManager.h"
82 #include "VideoFullscreenManager.h"
83 #endif
84
85 #if ENABLE(ASYNC_SCROLLING)
86 #include "RemoteScrollingCoordinator.h"
87 #endif
88
89 #if PLATFORM(GTK)
90 #include "PrinterListGtk.h"
91 #endif
92
93 using namespace WebCore;
94 using namespace HTMLNames;
95
96 namespace WebKit {
97
98 static double area(WebFrame* frame)
99 {
100     IntSize size = frame->visibleContentBoundsExcludingScrollbars().size();
101     return static_cast<double>(size.height()) * size.width();
102 }
103
104 static WebFrame* findLargestFrameInFrameSet(WebPage& page)
105 {
106     // Approximate what a user could consider a default target frame for application menu operations.
107
108     WebFrame* mainFrame = page.mainWebFrame();
109     if (!mainFrame || !mainFrame->isFrameSet())
110         return nullptr;
111
112     WebFrame* largestSoFar = nullptr;
113
114     Ref<API::Array> frameChildren = mainFrame->childFrames();
115     size_t count = frameChildren->size();
116     for (size_t i = 0; i < count; ++i) {
117         auto* childFrame = frameChildren->at<WebFrame>(i);
118         if (!largestSoFar || area(childFrame) > area(largestSoFar))
119             largestSoFar = childFrame;
120     }
121
122     return largestSoFar;
123 }
124
125 WebChromeClient::WebChromeClient(WebPage& page)
126     : m_page(page)
127 {
128 }
129
130 inline WebChromeClient::~WebChromeClient()
131 {
132 }
133
134 void WebChromeClient::chromeDestroyed()
135 {
136     delete this;
137 }
138
139 void WebChromeClient::setWindowRect(const FloatRect& windowFrame)
140 {
141     m_page.sendSetWindowFrame(windowFrame);
142 }
143
144 FloatRect WebChromeClient::windowRect()
145 {
146 #if PLATFORM(IOS)
147     return FloatRect();
148 #else
149 #if PLATFORM(MAC)
150     if (m_page.hasCachedWindowFrame())
151         return m_page.windowFrameInUnflippedScreenCoordinates();
152 #endif
153
154     FloatRect newWindowFrame;
155
156     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetWindowFrame(), Messages::WebPageProxy::GetWindowFrame::Reply(newWindowFrame), m_page.pageID()))
157         return FloatRect();
158
159     return newWindowFrame;
160 #endif
161 }
162
163 FloatRect WebChromeClient::pageRect()
164 {
165     return FloatRect(FloatPoint(), m_page.size());
166 }
167
168 void WebChromeClient::focus()
169 {
170     m_page.send(Messages::WebPageProxy::SetFocus(true));
171 }
172
173 void WebChromeClient::unfocus()
174 {
175     m_page.send(Messages::WebPageProxy::SetFocus(false));
176 }
177
178 #if PLATFORM(COCOA)
179
180 void WebChromeClient::elementDidFocus(Element& element)
181 {
182     m_page.elementDidFocus(&element);
183 }
184
185 void WebChromeClient::elementDidBlur(Element& element)
186 {
187     m_page.elementDidBlur(&element);
188 }
189
190 void WebChromeClient::makeFirstResponder()
191 {
192     m_page.send(Messages::WebPageProxy::MakeFirstResponder());
193 }
194
195 #endif    
196
197 bool WebChromeClient::canTakeFocus(FocusDirection)
198 {
199     notImplemented();
200     return true;
201 }
202
203 void WebChromeClient::takeFocus(FocusDirection direction)
204 {
205     m_page.send(Messages::WebPageProxy::TakeFocus(direction));
206 }
207
208 void WebChromeClient::focusedElementChanged(Element* element)
209 {
210     if (!is<HTMLInputElement>(element))
211         return;
212
213     HTMLInputElement& inputElement = downcast<HTMLInputElement>(*element);
214     if (!inputElement.isText())
215         return;
216
217     WebFrame* webFrame = WebFrame::fromCoreFrame(*element->document().frame());
218     ASSERT(webFrame);
219     m_page.injectedBundleFormClient().didFocusTextField(&m_page, &inputElement, webFrame);
220 }
221
222 void WebChromeClient::focusedFrameChanged(Frame* frame)
223 {
224     WebFrame* webFrame = frame ? WebFrame::fromCoreFrame(*frame) : nullptr;
225
226     WebProcess::singleton().parentProcessConnection()->send(Messages::WebPageProxy::FocusedFrameChanged(webFrame ? webFrame->frameID() : 0), m_page.pageID());
227 }
228
229 Page* WebChromeClient::createWindow(Frame& frame, const FrameLoadRequest& request, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
230 {
231 #if ENABLE(FULLSCREEN_API)
232     if (frame.document() && frame.document()->webkitCurrentFullScreenElement())
233         frame.document()->webkitCancelFullScreen();
234 #endif
235
236     auto& webProcess = WebProcess::singleton();
237
238     NavigationActionData navigationActionData;
239     navigationActionData.navigationType = navigationAction.type();
240     navigationActionData.modifiers = InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction);
241     navigationActionData.mouseButton = InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction);
242     navigationActionData.syntheticClickType = InjectedBundleNavigationAction::syntheticClickTypeForNavigationAction(navigationAction);
243     navigationActionData.clickLocationInRootViewCoordinates = InjectedBundleNavigationAction::clickLocationInRootViewCoordinatesForNavigationAction(navigationAction);
244     navigationActionData.userGestureTokenIdentifier = webProcess.userGestureTokenIdentifier(navigationAction.userGestureToken());
245     navigationActionData.canHandleRequest = m_page.canHandleRequest(request.resourceRequest());
246     navigationActionData.shouldOpenExternalURLsPolicy = navigationAction.shouldOpenExternalURLsPolicy();
247     navigationActionData.downloadAttribute = navigationAction.downloadAttribute();
248
249     WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
250
251     uint64_t newPageID = 0;
252     WebPageCreationParameters parameters;
253     if (!webProcess.parentProcessConnection()->sendSync(Messages::WebPageProxy::CreateNewPage(webFrame->info(), webFrame->page()->pageID(), request.resourceRequest(), windowFeatures, navigationActionData), Messages::WebPageProxy::CreateNewPage::Reply(newPageID, parameters), m_page.pageID()))
254         return nullptr;
255
256     if (!newPageID)
257         return nullptr;
258
259     webProcess.createWebPage(newPageID, WTFMove(parameters));
260     return webProcess.webPage(newPageID)->corePage();
261 }
262
263 void WebChromeClient::show()
264 {
265     m_page.show();
266 }
267
268 bool WebChromeClient::canRunModal()
269 {
270     return m_page.canRunModal();
271 }
272
273 void WebChromeClient::runModal()
274 {
275     m_page.runModal();
276 }
277
278 void WebChromeClient::reportProcessCPUTime(Seconds cpuTime, ActivityStateForCPUSampling activityState)
279 {
280     WebProcess::singleton().send(Messages::WebProcessPool::ReportWebContentCPUTime(cpuTime, static_cast<uint64_t>(activityState)), 0);
281 }
282
283 void WebChromeClient::setToolbarsVisible(bool toolbarsAreVisible)
284 {
285     m_page.send(Messages::WebPageProxy::SetToolbarsAreVisible(toolbarsAreVisible));
286 }
287
288 bool WebChromeClient::toolbarsVisible()
289 {
290     API::InjectedBundle::PageUIClient::UIElementVisibility toolbarsVisibility = m_page.injectedBundleUIClient().toolbarsAreVisible(&m_page);
291     if (toolbarsVisibility != API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown)
292         return toolbarsVisibility == API::InjectedBundle::PageUIClient::UIElementVisibility::Visible;
293     
294     bool toolbarsAreVisible = true;
295     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetToolbarsAreVisible(), Messages::WebPageProxy::GetToolbarsAreVisible::Reply(toolbarsAreVisible), m_page.pageID()))
296         return true;
297
298     return toolbarsAreVisible;
299 }
300
301 void WebChromeClient::setStatusbarVisible(bool statusBarIsVisible)
302 {
303     m_page.send(Messages::WebPageProxy::SetStatusBarIsVisible(statusBarIsVisible));
304 }
305
306 bool WebChromeClient::statusbarVisible()
307 {
308     API::InjectedBundle::PageUIClient::UIElementVisibility statusbarVisibility = m_page.injectedBundleUIClient().statusBarIsVisible(&m_page);
309     if (statusbarVisibility != API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown)
310         return statusbarVisibility == API::InjectedBundle::PageUIClient::UIElementVisibility::Visible;
311
312     bool statusBarIsVisible = true;
313     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetStatusBarIsVisible(), Messages::WebPageProxy::GetStatusBarIsVisible::Reply(statusBarIsVisible), m_page.pageID()))
314         return true;
315
316     return statusBarIsVisible;
317 }
318
319 void WebChromeClient::setScrollbarsVisible(bool)
320 {
321     notImplemented();
322 }
323
324 bool WebChromeClient::scrollbarsVisible()
325 {
326     notImplemented();
327     return true;
328 }
329
330 void WebChromeClient::setMenubarVisible(bool menuBarVisible)
331 {
332     m_page.send(Messages::WebPageProxy::SetMenuBarIsVisible(menuBarVisible));
333 }
334
335 bool WebChromeClient::menubarVisible()
336 {
337     API::InjectedBundle::PageUIClient::UIElementVisibility menubarVisibility = m_page.injectedBundleUIClient().menuBarIsVisible(&m_page);
338     if (menubarVisibility != API::InjectedBundle::PageUIClient::UIElementVisibility::Unknown)
339         return menubarVisibility == API::InjectedBundle::PageUIClient::UIElementVisibility::Visible;
340     
341     bool menuBarIsVisible = true;
342     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::GetMenuBarIsVisible(), Messages::WebPageProxy::GetMenuBarIsVisible::Reply(menuBarIsVisible), m_page.pageID()))
343         return true;
344
345     return menuBarIsVisible;
346 }
347
348 void WebChromeClient::setResizable(bool resizable)
349 {
350     m_page.send(Messages::WebPageProxy::SetIsResizable(resizable));
351 }
352
353 void WebChromeClient::addMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, unsigned columnNumber, const String& sourceID)
354 {
355     // Notify the bundle client.
356     m_page.injectedBundleUIClient().willAddMessageToConsole(&m_page, source, level, message, lineNumber, columnNumber, sourceID);
357 }
358
359 bool WebChromeClient::canRunBeforeUnloadConfirmPanel()
360 {
361     return m_page.canRunBeforeUnloadConfirmPanel();
362 }
363
364 bool WebChromeClient::runBeforeUnloadConfirmPanel(const String& message, Frame& frame)
365 {
366     WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
367
368     bool shouldClose = false;
369
370     HangDetectionDisabler hangDetectionDisabler;
371
372     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunBeforeUnloadConfirmPanel(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message), Messages::WebPageProxy::RunBeforeUnloadConfirmPanel::Reply(shouldClose), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend))
373         return false;
374
375     return shouldClose;
376 }
377
378 void WebChromeClient::closeWindowSoon()
379 {
380     // FIXME: This code assumes that the client will respond to a close page
381     // message by actually closing the page. Safari does this, but there is
382     // no guarantee that other applications will, which will leave this page
383     // half detached. This approach is an inherent limitation making parts of
384     // a close execute synchronously as part of window.close, but other parts
385     // later on.
386
387     m_page.corePage()->setGroupName(String());
388
389     if (WebFrame* frame = m_page.mainWebFrame()) {
390         if (Frame* coreFrame = frame->coreFrame())
391             coreFrame->loader().stopForUserCancel();
392     }
393
394     m_page.sendClose();
395 }
396
397 static bool shouldSuppressJavaScriptDialogs(Frame& frame)
398 {
399     if (frame.loader().opener() && frame.loader().stateMachine().isDisplayingInitialEmptyDocument() && frame.loader().provisionalDocumentLoader())
400         return true;
401
402     return false;
403 }
404
405 void WebChromeClient::runJavaScriptAlert(Frame& frame, const String& alertText)
406 {
407     if (shouldSuppressJavaScriptDialogs(frame))
408         return;
409
410     WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
411     ASSERT(webFrame);
412
413     // Notify the bundle client.
414     m_page.injectedBundleUIClient().willRunJavaScriptAlert(&m_page, alertText, webFrame);
415
416     HangDetectionDisabler hangDetectionDisabler;
417
418     WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptAlert(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), alertText), Messages::WebPageProxy::RunJavaScriptAlert::Reply(), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
419 }
420
421 bool WebChromeClient::runJavaScriptConfirm(Frame& frame, const String& message)
422 {
423     if (shouldSuppressJavaScriptDialogs(frame))
424         return false;
425
426     WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
427     ASSERT(webFrame);
428
429     // Notify the bundle client.
430     m_page.injectedBundleUIClient().willRunJavaScriptConfirm(&m_page, message, webFrame);
431
432     HangDetectionDisabler hangDetectionDisabler;
433
434     bool result = false;
435     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptConfirm(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message), Messages::WebPageProxy::RunJavaScriptConfirm::Reply(result), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend))
436         return false;
437
438     return result;
439 }
440
441 bool WebChromeClient::runJavaScriptPrompt(Frame& frame, const String& message, const String& defaultValue, String& result)
442 {
443     if (shouldSuppressJavaScriptDialogs(frame))
444         return false;
445
446     WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
447     ASSERT(webFrame);
448
449     // Notify the bundle client.
450     m_page.injectedBundleUIClient().willRunJavaScriptPrompt(&m_page, message, defaultValue, webFrame);
451
452     HangDetectionDisabler hangDetectionDisabler;
453
454     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::RunJavaScriptPrompt(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), message, defaultValue), Messages::WebPageProxy::RunJavaScriptPrompt::Reply(result), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend))
455         return false;
456
457     return !result.isNull();
458 }
459
460 void WebChromeClient::setStatusbarText(const String& statusbarText)
461 {
462     // Notify the bundle client.
463     m_page.injectedBundleUIClient().willSetStatusbarText(&m_page, statusbarText);
464
465     m_page.send(Messages::WebPageProxy::SetStatusText(statusbarText));
466 }
467
468 KeyboardUIMode WebChromeClient::keyboardUIMode()
469 {
470     return m_page.keyboardUIMode();
471 }
472
473 #if ENABLE(POINTER_LOCK)
474
475 bool WebChromeClient::requestPointerLock()
476 {
477     m_page.send(Messages::WebPageProxy::RequestPointerLock());
478     return true;
479 }
480
481 void WebChromeClient::requestPointerUnlock()
482 {
483     m_page.send(Messages::WebPageProxy::RequestPointerUnlock());
484 }
485
486 #endif
487
488 void WebChromeClient::invalidateRootView(const IntRect&)
489 {
490     // Do nothing here, there's no concept of invalidating the window in the web process.
491 }
492
493 void WebChromeClient::invalidateContentsAndRootView(const IntRect& rect)
494 {
495     if (Document* document = m_page.corePage()->mainFrame().document()) {
496         if (document->printing())
497             return;
498     }
499
500     m_page.drawingArea()->setNeedsDisplayInRect(rect);
501 }
502
503 void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect)
504 {
505     if (Document* document = m_page.corePage()->mainFrame().document()) {
506         if (document->printing())
507             return;
508     }
509
510     m_page.pageDidScroll();
511 #if USE(COORDINATED_GRAPHICS)
512     FrameView* frameView = m_page.mainFrame()->view();
513     if (frameView && frameView->delegatesScrolling()) {
514         m_page.drawingArea()->scroll(rect, IntSize());
515         return;
516     }
517 #endif
518     m_page.drawingArea()->setNeedsDisplayInRect(rect);
519 }
520
521 void WebChromeClient::scroll(const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect& clipRect)
522 {
523     m_page.pageDidScroll();
524     m_page.drawingArea()->scroll(intersection(scrollRect, clipRect), scrollDelta);
525 }
526
527 #if USE(COORDINATED_GRAPHICS)
528 void WebChromeClient::delegatedScrollRequested(const IntPoint& scrollOffset)
529 {
530     m_page.pageDidRequestScroll(scrollOffset);
531 }
532
533 void WebChromeClient::resetUpdateAtlasForTesting()
534 {
535     m_page.drawingArea()->resetUpdateAtlasForTesting();
536 }
537 #endif
538
539 IntPoint WebChromeClient::screenToRootView(const IntPoint& point) const
540 {
541     return m_page.screenToRootView(point);
542 }
543
544 IntRect WebChromeClient::rootViewToScreen(const IntRect& rect) const
545 {
546     return m_page.rootViewToScreen(rect);
547 }
548     
549 #if PLATFORM(IOS)
550 IntPoint WebChromeClient::accessibilityScreenToRootView(const IntPoint& point) const
551 {
552     return m_page.accessibilityScreenToRootView(point);
553 }
554
555 IntRect WebChromeClient::rootViewToAccessibilityScreen(const IntRect& rect) const
556 {
557     return m_page.rootViewToAccessibilityScreen(rect);
558 }
559 #endif
560
561 PlatformPageClient WebChromeClient::platformPageClient() const
562 {
563     notImplemented();
564     return 0;
565 }
566
567 void WebChromeClient::contentsSizeChanged(Frame& frame, const IntSize& size) const
568 {
569     if (m_page.corePage()->settings().frameFlattening() == FrameFlatteningDisabled) {
570         WebFrame* largestFrame = findLargestFrameInFrameSet(m_page);
571         if (largestFrame != m_cachedFrameSetLargestFrame.get()) {
572             m_cachedFrameSetLargestFrame = largestFrame;
573             m_page.send(Messages::WebPageProxy::FrameSetLargestFrameChanged(largestFrame ? largestFrame->frameID() : 0));
574         }
575     }
576
577     if (&frame.page()->mainFrame() != &frame)
578         return;
579
580     m_page.send(Messages::WebPageProxy::DidChangeContentSize(size));
581
582     m_page.drawingArea()->mainFrameContentSizeChanged(size);
583
584     FrameView* frameView = frame.view();
585     if (frameView && !frameView->delegatesScrolling())  {
586         bool hasHorizontalScrollbar = frameView->horizontalScrollbar();
587         bool hasVerticalScrollbar = frameView->verticalScrollbar();
588
589         if (hasHorizontalScrollbar != m_cachedMainFrameHasHorizontalScrollbar || hasVerticalScrollbar != m_cachedMainFrameHasVerticalScrollbar) {
590             m_page.send(Messages::WebPageProxy::DidChangeScrollbarsForMainFrame(hasHorizontalScrollbar, hasVerticalScrollbar));
591
592             m_cachedMainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
593             m_cachedMainFrameHasVerticalScrollbar = hasVerticalScrollbar;
594         }
595     }
596 }
597
598 void WebChromeClient::scrollRectIntoView(const IntRect&) const
599 {
600     notImplemented();
601 }
602
603 bool WebChromeClient::shouldUnavailablePluginMessageBeButton(RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
604 {
605     switch (pluginUnavailabilityReason) {
606     case RenderEmbeddedObject::PluginMissing:
607         // FIXME: <rdar://problem/8794397> We should only return true when there is a
608         // missingPluginButtonClicked callback defined on the Page UI client.
609     case RenderEmbeddedObject::InsecurePluginVersion:
610         return true;
611
612
613     case RenderEmbeddedObject::PluginCrashed:
614     case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy:
615         return false;
616     }
617
618     ASSERT_NOT_REACHED();
619     return false;
620 }
621     
622 void WebChromeClient::unavailablePluginButtonClicked(Element& element, RenderEmbeddedObject::PluginUnavailabilityReason pluginUnavailabilityReason) const
623 {
624 #if ENABLE(NETSCAPE_PLUGIN_API)
625     ASSERT(element.hasTagName(objectTag) || element.hasTagName(embedTag) || element.hasTagName(appletTag));
626     ASSERT(pluginUnavailabilityReason == RenderEmbeddedObject::PluginMissing || pluginUnavailabilityReason == RenderEmbeddedObject::InsecurePluginVersion || pluginUnavailabilityReason);
627
628     auto& pluginElement = downcast<HTMLPlugInImageElement>(element);
629
630     String frameURLString = pluginElement.document().frame()->loader().documentLoader()->responseURL().string();
631     String pageURLString = m_page.mainFrame()->loader().documentLoader()->responseURL().string();
632     String pluginURLString = pluginElement.document().completeURL(pluginElement.url()).string();
633     URL pluginspageAttributeURL = pluginElement.document().completeURL(stripLeadingAndTrailingHTMLSpaces(pluginElement.attributeWithoutSynchronization(pluginspageAttr)));
634     if (!pluginspageAttributeURL.protocolIsInHTTPFamily())
635         pluginspageAttributeURL = URL();
636     m_page.send(Messages::WebPageProxy::UnavailablePluginButtonClicked(pluginUnavailabilityReason, pluginElement.serviceType(), pluginURLString, pluginspageAttributeURL.string(), frameURLString, pageURLString));
637 #else
638     UNUSED_PARAM(element);
639     UNUSED_PARAM(pluginUnavailabilityReason);
640 #endif // ENABLE(NETSCAPE_PLUGIN_API)
641 }
642
643 void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult, unsigned modifierFlags)
644 {
645     RefPtr<API::Object> userData;
646
647     // Notify the bundle client.
648     m_page.injectedBundleUIClient().mouseDidMoveOverElement(&m_page, hitTestResult, static_cast<WebEvent::Modifiers>(modifierFlags), userData);
649
650     // Notify the UIProcess.
651     WebHitTestResultData webHitTestResultData(hitTestResult);
652     m_page.send(Messages::WebPageProxy::MouseDidMoveOverElement(webHitTestResultData, modifierFlags, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
653 }
654
655 void WebChromeClient::setToolTip(const String& toolTip, TextDirection)
656 {
657     // Only send a tool tip to the WebProcess if it has changed since the last time this function was called.
658
659     if (toolTip == m_cachedToolTip)
660         return;
661     m_cachedToolTip = toolTip;
662
663     m_page.send(Messages::WebPageProxy::SetToolTip(m_cachedToolTip));
664 }
665
666 void WebChromeClient::print(Frame& frame)
667 {
668     WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
669     ASSERT(webFrame);
670
671 #if PLATFORM(GTK) && HAVE(GTK_UNIX_PRINTING)
672     // When printing synchronously in GTK+ we need to make sure that we have a list of Printers before starting the print operation.
673     // Getting the list of printers is done synchronously by GTK+, but using a nested main loop that might process IPC messages
674     // comming from the UI process like EndPrinting. When the EndPriting message is received while the printer list is being populated,
675     // the print operation is finished unexpectely and the web process crashes, see https://bugs.webkit.org/show_bug.cgi?id=126979.
676     // The PrinterListGtk class gets the list of printers in the constructor so we just need to ensure there's an instance alive
677     // during the synchronous print operation.
678     RefPtr<PrinterListGtk> printerList = PrinterListGtk::getOrCreate();
679     if (!printerList) {
680         // PrinterListGtk::getOrCreate() returns nullptr when called while a printers enumeration is ongoing.
681         // This can happen if a synchronous print is started by a JavaScript and another one is inmeditaley started
682         // from a JavaScript event listener. The second print operation is handled by the nested main loop used by GTK+
683         // to enumerate the printers, and we end up here trying to get a reference of an object that is being constructed.
684         // It's very unlikely that the user wants to print twice in a row, and other browsers don't do two print operations
685         // in this particular case either. So, the safest solution is to return early here and ignore the second print.
686         // See https://bugs.webkit.org/show_bug.cgi?id=141035
687         return;
688     }
689 #endif
690
691     m_page.sendSync(Messages::WebPageProxy::PrintFrame(webFrame->frameID()), Messages::WebPageProxy::PrintFrame::Reply(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
692 }
693
694 void WebChromeClient::exceededDatabaseQuota(Frame& frame, const String& databaseName, DatabaseDetails details)
695 {
696     WebFrame* webFrame = WebFrame::fromCoreFrame(frame);
697     ASSERT(webFrame);
698     
699     auto& origin = frame.document()->securityOrigin();
700     auto originData = SecurityOriginData::fromSecurityOrigin(origin);
701     auto& tracker = DatabaseTracker::singleton();
702     auto currentQuota = tracker.quota(originData);
703     auto currentOriginUsage = tracker.usage(originData);
704     uint64_t newQuota = 0;
705     RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier())->securityOrigin());
706     newQuota = m_page.injectedBundleUIClient().didExceedDatabaseQuota(&m_page, securityOrigin.get(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage());
707
708     if (!newQuota) {
709         WebProcess::singleton().parentProcessConnection()->sendSync(
710             Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
711             Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
712     }
713
714     tracker.setQuota(originData, newQuota);
715 }
716
717 void WebChromeClient::reachedMaxAppCacheSize(int64_t)
718 {
719     notImplemented();
720 }
721
722 void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin& origin, int64_t totalBytesNeeded)
723 {
724     RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::createFromString(origin.toString());
725     if (m_page.injectedBundleUIClient().didReachApplicationCacheOriginQuota(&m_page, securityOrigin.get(), totalBytesNeeded))
726         return;
727
728     auto& cacheStorage = m_page.corePage()->applicationCacheStorage();
729     int64_t currentQuota = 0;
730     if (!cacheStorage.calculateQuotaForOrigin(origin, currentQuota))
731         return;
732
733     uint64_t newQuota = 0;
734     WebProcess::singleton().parentProcessConnection()->sendSync(
735         Messages::WebPageProxy::ReachedApplicationCacheOriginQuota(SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier(), currentQuota, totalBytesNeeded),
736         Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::Reply(newQuota), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
737
738     cacheStorage.storeUpdatedQuotaForOrigin(&origin, newQuota);
739 }
740
741 #if ENABLE(DASHBOARD_SUPPORT)
742
743 void WebChromeClient::annotatedRegionsChanged()
744 {
745     notImplemented();
746 }
747
748 #endif
749
750 bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
751 {
752     generatedFilename = m_page.injectedBundleUIClient().shouldGenerateFileForUpload(&m_page, path);
753     return !generatedFilename.isNull();
754 }
755
756 String WebChromeClient::generateReplacementFile(const String& path)
757 {
758     return m_page.injectedBundleUIClient().generateFileForUpload(&m_page, path);
759 }
760
761 #if ENABLE(INPUT_TYPE_COLOR)
762
763 std::unique_ptr<ColorChooser> WebChromeClient::createColorChooser(ColorChooserClient& client, const Color& initialColor)
764 {
765     return std::make_unique<WebColorChooser>(&m_page, &client, initialColor);
766 }
767
768 #endif
769
770 void WebChromeClient::runOpenPanel(Frame& frame, FileChooser& fileChooser)
771 {
772     if (m_page.activeOpenPanelResultListener())
773         return;
774
775     m_page.setActiveOpenPanelResultListener(WebOpenPanelResultListener::create(m_page, fileChooser));
776
777     auto* webFrame = WebFrame::fromCoreFrame(frame);
778     ASSERT(webFrame);
779     m_page.send(Messages::WebPageProxy::RunOpenPanel(webFrame->frameID(), SecurityOriginData::fromFrame(&frame), fileChooser.settings()));
780 }
781
782 void WebChromeClient::loadIconForFiles(const Vector<String>& filenames, FileIconLoader& loader)
783 {
784     loader.iconLoaded(createIconForFiles(filenames));
785 }
786
787 #if !PLATFORM(IOS)
788
789 void WebChromeClient::setCursor(const Cursor& cursor)
790 {
791     m_page.send(Messages::WebPageProxy::SetCursor(cursor));
792 }
793
794 void WebChromeClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
795 {
796     m_page.send(Messages::WebPageProxy::SetCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves));
797 }
798
799 RefPtr<Icon> WebChromeClient::createIconForFiles(const Vector<String>& filenames)
800 {
801     return Icon::createIconForFiles(filenames);
802 }
803
804 #endif
805
806 void WebChromeClient::didAssociateFormControls(const Vector<RefPtr<Element>>& elements)
807 {
808     return m_page.injectedBundleFormClient().didAssociateFormControls(&m_page, elements);
809 }
810
811 bool WebChromeClient::shouldNotifyOnFormChanges()
812 {
813     return m_page.injectedBundleFormClient().shouldNotifyOnFormChanges(&m_page);
814 }
815
816 bool WebChromeClient::selectItemWritingDirectionIsNatural()
817 {
818     return false;
819 }
820
821 bool WebChromeClient::selectItemAlignmentFollowsMenuWritingDirection()
822 {
823     return true;
824 }
825
826 RefPtr<PopupMenu> WebChromeClient::createPopupMenu(PopupMenuClient& client) const
827 {
828     return WebPopupMenu::create(&m_page, &client);
829 }
830
831 RefPtr<SearchPopupMenu> WebChromeClient::createSearchPopupMenu(PopupMenuClient& client) const
832 {
833     return WebSearchPopupMenu::create(&m_page, &client);
834 }
835
836 GraphicsLayerFactory* WebChromeClient::graphicsLayerFactory() const
837 {
838     if (auto drawingArea = m_page.drawingArea())
839         return drawingArea->graphicsLayerFactory();
840     return nullptr;
841 }
842
843 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
844
845 RefPtr<DisplayRefreshMonitor> WebChromeClient::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
846 {
847     return m_page.drawingArea()->createDisplayRefreshMonitor(displayID);
848 }
849
850 #endif
851
852 void WebChromeClient::attachRootGraphicsLayer(Frame&, GraphicsLayer* layer)
853 {
854     if (layer)
855         m_page.enterAcceleratedCompositingMode(layer);
856     else
857         m_page.exitAcceleratedCompositingMode();
858 }
859
860 void WebChromeClient::attachViewOverlayGraphicsLayer(Frame& frame, GraphicsLayer* graphicsLayer)
861 {
862     if (auto drawingArea = m_page.drawingArea())
863         drawingArea->attachViewOverlayGraphicsLayer(&frame, graphicsLayer);
864 }
865
866 void WebChromeClient::setNeedsOneShotDrawingSynchronization()
867 {
868     notImplemented();
869 }
870
871 void WebChromeClient::scheduleCompositingLayerFlush()
872 {
873     if (m_page.drawingArea())
874         m_page.drawingArea()->scheduleCompositingLayerFlush();
875 }
876
877 void WebChromeClient::contentRuleListNotification(const URL& url, const HashSet<std::pair<String, String>>& notificationPairs)
878 {
879     Vector<String> identifiers;
880     Vector<String> notifications;
881     identifiers.reserveInitialCapacity(notificationPairs.size());
882     notifications.reserveInitialCapacity(notificationPairs.size());
883     for (auto& notification : notificationPairs) {
884         identifiers.uncheckedAppend(notification.first);
885         notifications.uncheckedAppend(notification.second);
886     }
887
888     m_page.send(Messages::WebPageProxy::ContentRuleListNotification(url, identifiers, notifications));
889 }
890
891 bool WebChromeClient::adjustLayerFlushThrottling(LayerFlushThrottleState::Flags flags)
892 {
893     return m_page.drawingArea() && m_page.drawingArea()->adjustLayerFlushThrottling(flags);
894 }
895
896 bool WebChromeClient::layerTreeStateIsFrozen() const
897 {
898     if (m_page.drawingArea())
899         return m_page.drawingArea()->layerTreeStateIsFrozen();
900
901     return false;
902 }
903
904 #if ENABLE(ASYNC_SCROLLING)
905
906 RefPtr<ScrollingCoordinator> WebChromeClient::createScrollingCoordinator(Page& page) const
907 {
908     ASSERT_UNUSED(page, m_page.corePage() == &page);
909     if (m_page.drawingArea()->type() != DrawingAreaTypeRemoteLayerTree)
910         return nullptr;
911     return RemoteScrollingCoordinator::create(&m_page);
912 }
913
914 #endif
915
916 #if (PLATFORM(IOS) && HAVE(AVKIT)) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
917
918 bool WebChromeClient::supportsVideoFullscreen(HTMLMediaElementEnums::VideoFullscreenMode mode)
919 {
920     return m_page.videoFullscreenManager().supportsVideoFullscreen(mode);
921 }
922
923 void WebChromeClient::setUpPlaybackControlsManager(HTMLMediaElement& mediaElement)
924 {
925     m_page.playbackSessionManager().setUpPlaybackControlsManager(mediaElement);
926 }
927
928 void WebChromeClient::clearPlaybackControlsManager()
929 {
930     m_page.playbackSessionManager().clearPlaybackControlsManager();
931 }
932
933 void WebChromeClient::enterVideoFullscreenForVideoElement(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode mode)
934 {
935     ASSERT(mode != HTMLMediaElementEnums::VideoFullscreenModeNone);
936     m_page.videoFullscreenManager().enterVideoFullscreenForVideoElement(videoElement, mode);
937 }
938
939 void WebChromeClient::exitVideoFullscreenForVideoElement(HTMLVideoElement& videoElement)
940 {
941     m_page.videoFullscreenManager().exitVideoFullscreenForVideoElement(videoElement);
942 }
943
944 #endif
945
946 #if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
947
948 void WebChromeClient::exitVideoFullscreenToModeWithoutAnimation(HTMLVideoElement& videoElement, HTMLMediaElementEnums::VideoFullscreenMode targetMode)
949 {
950     m_page.videoFullscreenManager().exitVideoFullscreenToModeWithoutAnimation(videoElement, targetMode);
951 }
952
953 #endif
954
955 #if ENABLE(FULLSCREEN_API)
956
957 bool WebChromeClient::supportsFullScreenForElement(const Element&, bool withKeyboard)
958 {
959     return m_page.fullScreenManager()->supportsFullScreen(withKeyboard);
960 }
961
962 void WebChromeClient::enterFullScreenForElement(Element& element)
963 {
964     m_page.fullScreenManager()->enterFullScreenForElement(&element);
965 }
966
967 void WebChromeClient::exitFullScreenForElement(Element* element)
968 {
969     m_page.fullScreenManager()->exitFullScreenForElement(element);
970 }
971
972 #endif
973
974 #if PLATFORM(IOS)
975
976 FloatSize WebChromeClient::screenSize() const
977 {
978     return m_page.screenSize();
979 }
980
981 FloatSize WebChromeClient::availableScreenSize() const
982 {
983     return m_page.availableScreenSize();
984 }
985
986 #endif
987
988 void WebChromeClient::dispatchViewportPropertiesDidChange(const ViewportArguments& viewportArguments) const
989 {
990     m_page.viewportPropertiesDidChange(viewportArguments);
991 }
992
993 void WebChromeClient::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
994 {
995     m_page.send(Messages::WebPageProxy::NotifyScrollerThumbIsVisibleInRect(scrollerThumb));
996 }
997
998 void WebChromeClient::recommendedScrollbarStyleDidChange(ScrollbarStyle newStyle)
999 {
1000     m_page.send(Messages::WebPageProxy::RecommendedScrollbarStyleDidChange(static_cast<int32_t>(newStyle)));
1001 }
1002
1003 std::optional<ScrollbarOverlayStyle> WebChromeClient::preferredScrollbarOverlayStyle()
1004 {
1005     return m_page.scrollbarOverlayStyle();
1006 }
1007
1008 Color WebChromeClient::underlayColor() const
1009 {
1010     return m_page.underlayColor();
1011 }
1012
1013 void WebChromeClient::pageExtendedBackgroundColorDidChange(Color backgroundColor) const
1014 {
1015 #if PLATFORM(MAC)
1016     m_page.send(Messages::WebPageProxy::PageExtendedBackgroundColorDidChange(backgroundColor));
1017 #else
1018     UNUSED_PARAM(backgroundColor);
1019 #endif
1020 }
1021
1022 void WebChromeClient::wheelEventHandlersChanged(bool hasHandlers)
1023 {
1024     m_page.wheelEventHandlersChanged(hasHandlers);
1025 }
1026
1027 String WebChromeClient::plugInStartLabelTitle(const String& mimeType) const
1028 {
1029     return m_page.injectedBundleUIClient().plugInStartLabelTitle(mimeType);
1030 }
1031
1032 String WebChromeClient::plugInStartLabelSubtitle(const String& mimeType) const
1033 {
1034     return m_page.injectedBundleUIClient().plugInStartLabelSubtitle(mimeType);
1035 }
1036
1037 String WebChromeClient::plugInExtraStyleSheet() const
1038 {
1039     return m_page.injectedBundleUIClient().plugInExtraStyleSheet();
1040 }
1041
1042 String WebChromeClient::plugInExtraScript() const
1043 {
1044     return m_page.injectedBundleUIClient().plugInExtraScript();
1045 }
1046
1047 void WebChromeClient::enableSuddenTermination()
1048 {
1049     m_page.send(Messages::WebProcessProxy::EnableSuddenTermination());
1050 }
1051
1052 void WebChromeClient::disableSuddenTermination()
1053 {
1054     m_page.send(Messages::WebProcessProxy::DisableSuddenTermination());
1055 }
1056
1057 void WebChromeClient::didAddHeaderLayer(GraphicsLayer& headerParent)
1058 {
1059 #if ENABLE(RUBBER_BANDING)
1060     if (PageBanner* banner = m_page.headerPageBanner())
1061         banner->didAddParentLayer(&headerParent);
1062 #else
1063     UNUSED_PARAM(headerParent);
1064 #endif
1065 }
1066
1067 void WebChromeClient::didAddFooterLayer(GraphicsLayer& footerParent)
1068 {
1069 #if ENABLE(RUBBER_BANDING)
1070     if (PageBanner* banner = m_page.footerPageBanner())
1071         banner->didAddParentLayer(&footerParent);
1072 #else
1073     UNUSED_PARAM(footerParent);
1074 #endif
1075 }
1076
1077 bool WebChromeClient::shouldUseTiledBackingForFrameView(const FrameView& frameView) const
1078 {
1079     return m_page.drawingArea()->shouldUseTiledBackingForFrameView(frameView);
1080 }
1081
1082 void WebChromeClient::isPlayingMediaDidChange(MediaProducer::MediaStateFlags state, uint64_t sourceElementID)
1083 {
1084     m_page.send(Messages::WebPageProxy::IsPlayingMediaDidChange(state, sourceElementID));
1085 }
1086
1087 void WebChromeClient::handleAutoplayEvent(AutoplayEvent event, OptionSet<AutoplayEventFlags> flags)
1088 {
1089     m_page.send(Messages::WebPageProxy::HandleAutoplayEvent(event, flags));
1090 }
1091
1092 #if ENABLE(MEDIA_SESSION)
1093
1094 void WebChromeClient::hasMediaSessionWithActiveMediaElementsDidChange(bool state)
1095 {
1096     m_page.send(Messages::WebPageProxy::HasMediaSessionWithActiveMediaElementsDidChange(state));
1097 }
1098
1099 void WebChromeClient::mediaSessionMetadataDidChange(const MediaSessionMetadata& metadata)
1100 {
1101     m_page.send(Messages::WebPageProxy::MediaSessionMetadataDidChange(metadata));
1102 }
1103
1104 void WebChromeClient::focusedContentMediaElementDidChange(uint64_t elementID)
1105 {
1106     m_page.send(Messages::WebPageProxy::FocusedContentMediaElementDidChange(elementID));
1107 }
1108
1109 #endif
1110
1111 #if ENABLE(SUBTLE_CRYPTO)
1112
1113 bool WebChromeClient::wrapCryptoKey(const Vector<uint8_t>& key, Vector<uint8_t>& wrappedKey) const
1114 {
1115     bool succeeded;
1116     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::WrapCryptoKey(key), Messages::WebPageProxy::WrapCryptoKey::Reply(succeeded, wrappedKey), m_page.pageID()))
1117         return false;
1118     return succeeded;
1119 }
1120
1121 bool WebChromeClient::unwrapCryptoKey(const Vector<uint8_t>& wrappedKey, Vector<uint8_t>& key) const
1122 {
1123     bool succeeded;
1124     if (!WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPageProxy::UnwrapCryptoKey(wrappedKey), Messages::WebPageProxy::UnwrapCryptoKey::Reply(succeeded, key), m_page.pageID()))
1125         return false;
1126     return succeeded;
1127 }
1128
1129 #endif
1130
1131 #if ENABLE(TELEPHONE_NUMBER_DETECTION) && PLATFORM(MAC)
1132
1133 void WebChromeClient::handleTelephoneNumberClick(const String& number, const IntPoint& point)
1134 {
1135     m_page.handleTelephoneNumberClick(number, point);
1136 }
1137
1138 #endif
1139
1140 #if ENABLE(SERVICE_CONTROLS)
1141
1142 void WebChromeClient::handleSelectionServiceClick(FrameSelection& selection, const Vector<String>& telephoneNumbers, const IntPoint& point)
1143 {
1144     m_page.handleSelectionServiceClick(selection, telephoneNumbers, point);
1145 }
1146
1147 bool WebChromeClient::hasRelevantSelectionServices(bool isTextOnly) const
1148 {
1149     return (isTextOnly && WebProcess::singleton().hasSelectionServices()) || WebProcess::singleton().hasRichContentServices();
1150 }
1151
1152 #endif
1153
1154 bool WebChromeClient::shouldDispatchFakeMouseMoveEvents() const
1155 {
1156     return m_page.shouldDispatchFakeMouseMoveEvents();
1157 }
1158
1159 void WebChromeClient::handleAutoFillButtonClick(HTMLInputElement& inputElement)
1160 {
1161     RefPtr<API::Object> userData;
1162
1163     // Notify the bundle client.
1164     auto nodeHandle = InjectedBundleNodeHandle::getOrCreate(inputElement);
1165     m_page.injectedBundleUIClient().didClickAutoFillButton(m_page, nodeHandle.get(), userData);
1166
1167     // Notify the UIProcess.
1168     m_page.send(Messages::WebPageProxy::HandleAutoFillButtonClick(UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
1169 }
1170
1171 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
1172
1173 void WebChromeClient::addPlaybackTargetPickerClient(uint64_t contextId)
1174 {
1175     m_page.send(Messages::WebPageProxy::AddPlaybackTargetPickerClient(contextId));
1176 }
1177
1178 void WebChromeClient::removePlaybackTargetPickerClient(uint64_t contextId)
1179 {
1180     m_page.send(Messages::WebPageProxy::RemovePlaybackTargetPickerClient(contextId));
1181 }
1182
1183 void WebChromeClient::showPlaybackTargetPicker(uint64_t contextId, const IntPoint& position, bool isVideo)
1184 {
1185     FrameView* frameView = m_page.mainFrame()->view();
1186     FloatRect rect(frameView->contentsToRootView(frameView->windowToContents(position)), FloatSize());
1187     m_page.send(Messages::WebPageProxy::ShowPlaybackTargetPicker(contextId, rect, isVideo));
1188 }
1189
1190 void WebChromeClient::playbackTargetPickerClientStateDidChange(uint64_t contextId, MediaProducer::MediaStateFlags state)
1191 {
1192     m_page.send(Messages::WebPageProxy::PlaybackTargetPickerClientStateDidChange(contextId, state));
1193 }
1194
1195 void WebChromeClient::setMockMediaPlaybackTargetPickerEnabled(bool enabled)
1196 {
1197     m_page.send(Messages::WebPageProxy::SetMockMediaPlaybackTargetPickerEnabled(enabled));
1198 }
1199
1200 void WebChromeClient::setMockMediaPlaybackTargetPickerState(const String& name, MediaPlaybackTargetContext::State state)
1201 {
1202     m_page.send(Messages::WebPageProxy::SetMockMediaPlaybackTargetPickerState(name, state));
1203 }
1204
1205 #endif
1206
1207 void WebChromeClient::imageOrMediaDocumentSizeChanged(const IntSize& newSize)
1208 {
1209     m_page.imageOrMediaDocumentSizeChanged(newSize);
1210 }
1211
1212 #if ENABLE(VIDEO) && USE(GSTREAMER)
1213
1214 void WebChromeClient::requestInstallMissingMediaPlugins(const String& details, const String& description, MediaPlayerRequestInstallMissingPluginsCallback& callback)
1215 {
1216     m_page.requestInstallMissingMediaPlugins(details, description, callback);
1217 }
1218
1219 #endif
1220
1221 void WebChromeClient::didInvalidateDocumentMarkerRects()
1222 {
1223     m_page.findController().didInvalidateDocumentMarkerRects();
1224 }
1225
1226 void WebChromeClient::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, WTF::Function<void (bool)>&& callback)
1227 {
1228     m_page.requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), WTFMove(callback));
1229 }
1230
1231 } // namespace WebKit