2 * Copyright (C) 2010, 2011, 2015 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Corporation. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
28 #include "WebPageProxy.h"
31 #include "APIContextMenuClient.h"
32 #include "APIFindClient.h"
33 #include "APIFindMatchesClient.h"
34 #include "APIFormClient.h"
35 #include "APIFrameInfo.h"
36 #include "APIGeometry.h"
37 #include "APIHistoryClient.h"
38 #include "APIHitTestResult.h"
39 #include "APILegacyContextHistoryClient.h"
40 #include "APILoaderClient.h"
41 #include "APINavigation.h"
42 #include "APINavigationAction.h"
43 #include "APINavigationClient.h"
44 #include "APINavigationResponse.h"
45 #include "APIPageConfiguration.h"
46 #include "APIPolicyClient.h"
47 #include "APISecurityOrigin.h"
48 #include "APIUIClient.h"
49 #include "APIURLRequest.h"
50 #include "AuthenticationChallengeProxy.h"
51 #include "AuthenticationDecisionListener.h"
52 #include "DataReference.h"
53 #include "DownloadProxy.h"
54 #include "DrawingAreaProxy.h"
55 #include "DrawingAreaProxyMessages.h"
56 #include "EventDispatcherMessages.h"
58 #include "NativeWebGestureEvent.h"
59 #include "NativeWebKeyboardEvent.h"
60 #include "NativeWebMouseEvent.h"
61 #include "NativeWebWheelEvent.h"
62 #include "NavigationActionData.h"
63 #include "NetworkProcessMessages.h"
64 #include "NotificationPermissionRequest.h"
65 #include "NotificationPermissionRequestManager.h"
66 #include "PageClient.h"
67 #include "PluginInformation.h"
68 #include "PluginProcessManager.h"
69 #include "PrintInfo.h"
70 #include "TextChecker.h"
71 #include "TextCheckerState.h"
72 #include "UserMediaPermissionRequestProxy.h"
73 #include "WKContextPrivate.h"
74 #include "WebBackForwardList.h"
75 #include "WebBackForwardListItem.h"
76 #include "WebCertificateInfo.h"
77 #include "WebContextMenuItem.h"
78 #include "WebContextMenuProxy.h"
79 #include "WebCoreArgumentCoders.h"
80 #include "WebEditCommandProxy.h"
82 #include "WebEventConversion.h"
83 #include "WebFormSubmissionListenerProxy.h"
84 #include "WebFramePolicyListenerProxy.h"
85 #include "WebFullScreenManagerProxy.h"
86 #include "WebFullScreenManagerProxyMessages.h"
88 #include "WebInspectorProxy.h"
89 #include "WebInspectorProxyMessages.h"
90 #include "WebNavigationState.h"
91 #include "WebNotificationManagerProxy.h"
92 #include "WebOpenPanelParameters.h"
93 #include "WebOpenPanelResultListenerProxy.h"
94 #include "WebPageCreationParameters.h"
95 #include "WebPageGroup.h"
96 #include "WebPageGroupData.h"
97 #include "WebPageMessages.h"
98 #include "WebPageProxyMessages.h"
99 #include "WebPopupItem.h"
100 #include "WebPopupMenuProxy.h"
101 #include "WebPreferences.h"
102 #include "WebProcessMessages.h"
103 #include "WebProcessPool.h"
104 #include "WebProcessProxy.h"
105 #include "WebProtectionSpace.h"
106 #include "WebUserContentControllerProxy.h"
107 #include "WebsiteDataStore.h"
108 #include <WebCore/BitmapImage.h>
109 #include <WebCore/DiagnosticLoggingClient.h>
110 #include <WebCore/DragController.h>
111 #include <WebCore/DragData.h>
112 #include <WebCore/FloatRect.h>
113 #include <WebCore/FocusDirection.h>
114 #include <WebCore/JSDOMBinding.h>
115 #include <WebCore/MIMETypeRegistry.h>
116 #include <WebCore/RenderEmbeddedObject.h>
117 #include <WebCore/SerializedCryptoKeyWrap.h>
118 #include <WebCore/TextCheckerClient.h>
119 #include <WebCore/TextIndicator.h>
120 #include <WebCore/URL.h>
121 #include <WebCore/WindowFeatures.h>
123 #include <wtf/NeverDestroyed.h>
124 #include <wtf/text/StringView.h>
126 #if ENABLE(ASYNC_SCROLLING)
127 #include "RemoteScrollingCoordinatorProxy.h"
130 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
131 #include "CoordinatedLayerTreeHostProxyMessages.h"
134 #if ENABLE(VIBRATION)
135 #include "WebVibrationProxy.h"
139 #include <wtf/RefCountedLeakCounter.h>
143 #include "RemoteLayerTreeDrawingAreaProxy.h"
144 #include "RemoteLayerTreeScrollingPerformanceData.h"
145 #include "ViewSnapshotStore.h"
146 #include <WebCore/MachSendRight.h>
147 #include <WebCore/RunLoopObserver.h>
148 #include <WebCore/TextIndicatorWindow.h>
152 #include "WebVideoFullscreenManagerProxy.h"
153 #include "WebVideoFullscreenManagerProxyMessages.h"
157 #include <WebCore/CairoUtilities.h>
160 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
161 #include <WebCore/MediaPlaybackTarget.h>
162 #include <WebCore/WebMediaSessionManager.h>
165 #if ENABLE(MEDIA_SESSION)
166 #include "WebMediaSessionFocusManager.h"
167 #include "WebMediaSessionMetadata.h"
168 #include <WebCore/MediaSessionMetadata.h>
171 // This controls what strategy we use for mouse wheel coalescing.
172 #define MERGE_WHEEL_EVENTS 1
174 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection())
175 #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
177 using namespace WebCore;
179 // Represents the number of wheel events we can hold in the queue before we start pushing them preemptively.
180 static const unsigned wheelEventQueueSizeThreshold = 10;
184 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageProxyCounter, ("WebPageProxy"));
186 class ExceededDatabaseQuotaRecords {
187 WTF_MAKE_NONCOPYABLE(ExceededDatabaseQuotaRecords); WTF_MAKE_FAST_ALLOCATED;
188 friend class NeverDestroyed<ExceededDatabaseQuotaRecords>;
192 String originIdentifier;
195 uint64_t currentQuota;
196 uint64_t currentOriginUsage;
197 uint64_t currentDatabaseUsage;
198 uint64_t expectedUsage;
199 RefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply;
202 static ExceededDatabaseQuotaRecords& singleton();
204 std::unique_ptr<Record> createRecord(uint64_t frameID, String originIdentifier,
205 String databaseName, String displayName, uint64_t currentQuota,
206 uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage,
207 PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
209 void add(std::unique_ptr<Record>);
210 bool areBeingProcessed() const { return !!m_currentRecord; }
214 ExceededDatabaseQuotaRecords() { }
215 ~ExceededDatabaseQuotaRecords() { }
217 Deque<std::unique_ptr<Record>> m_records;
218 std::unique_ptr<Record> m_currentRecord;
221 ExceededDatabaseQuotaRecords& ExceededDatabaseQuotaRecords::singleton()
223 static NeverDestroyed<ExceededDatabaseQuotaRecords> records;
227 std::unique_ptr<ExceededDatabaseQuotaRecords::Record> ExceededDatabaseQuotaRecords::createRecord(
228 uint64_t frameID, String originIdentifier, String databaseName, String displayName,
229 uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage,
230 uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply)
232 auto record = std::make_unique<Record>();
233 record->frameID = frameID;
234 record->originIdentifier = originIdentifier;
235 record->databaseName = databaseName;
236 record->displayName = displayName;
237 record->currentQuota = currentQuota;
238 record->currentOriginUsage = currentOriginUsage;
239 record->currentDatabaseUsage = currentDatabaseUsage;
240 record->expectedUsage = expectedUsage;
241 record->reply = reply;
242 return WTF::move(record);
245 void ExceededDatabaseQuotaRecords::add(std::unique_ptr<ExceededDatabaseQuotaRecords::Record> record)
247 m_records.append(WTF::move(record));
250 ExceededDatabaseQuotaRecords::Record* ExceededDatabaseQuotaRecords::next()
252 m_currentRecord = nullptr;
253 if (!m_records.isEmpty())
254 m_currentRecord = m_records.takeFirst();
255 return m_currentRecord.get();
259 static const char* webKeyboardEventTypeString(WebEvent::Type type)
262 case WebEvent::KeyDown:
265 case WebEvent::KeyUp:
268 case WebEvent::RawKeyDown:
275 ASSERT_NOT_REACHED();
279 #endif // !LOG_DISABLED
281 class PageClientProtector {
282 WTF_MAKE_NONCOPYABLE(PageClientProtector);
284 PageClientProtector(PageClient& pageClient)
285 : m_pageClient(pageClient)
287 m_pageClient.refView();
290 ~PageClientProtector()
292 m_pageClient.derefView();
296 PageClient& m_pageClient;
299 Ref<WebPageProxy> WebPageProxy::create(PageClient& pageClient, WebProcessProxy& process, uint64_t pageID, Ref<API::PageConfiguration>&& configuration)
301 return adoptRef(*new WebPageProxy(pageClient, process, pageID, WTF::move(configuration)));
304 WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uint64_t pageID, Ref<API::PageConfiguration>&& configuration)
305 : m_pageClient(pageClient)
306 , m_configuration(WTF::move(configuration))
307 , m_loaderClient(std::make_unique<API::LoaderClient>())
308 , m_policyClient(std::make_unique<API::PolicyClient>())
309 , m_formClient(std::make_unique<API::FormClient>())
310 , m_uiClient(std::make_unique<API::UIClient>())
311 , m_findClient(std::make_unique<API::FindClient>())
312 , m_findMatchesClient(std::make_unique<API::FindMatchesClient>())
313 , m_diagnosticLoggingClient(std::make_unique<API::DiagnosticLoggingClient>())
314 #if ENABLE(CONTEXT_MENUS)
315 , m_contextMenuClient(std::make_unique<API::ContextMenuClient>())
317 , m_navigationState(std::make_unique<WebNavigationState>())
319 , m_pageGroup(*m_configuration->pageGroup())
320 , m_preferences(*m_configuration->preferences())
321 , m_userContentController(m_configuration->userContentController())
322 , m_visitedLinkStore(*m_configuration->visitedLinkStore())
323 , m_websiteDataStore(m_configuration->websiteDataStore()->websiteDataStore())
324 , m_mainFrame(nullptr)
325 , m_userAgent(standardUserAgent())
326 , m_treatsSHA1CertificatesAsInsecure(m_configuration->treatsSHA1SignedCertificatesAsInsecure())
328 , m_hasReceivedLayerTreeTransactionAfterDidCommitLoad(true)
329 , m_firstLayerTreeTransactionIdAfterDidCommitLoad(0)
330 , m_deviceOrientation(0)
331 , m_dynamicViewportSizeUpdateWaitingForTarget(false)
332 , m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit(false)
333 , m_dynamicViewportSizeUpdateLayerTreeTransactionID(0)
334 , m_layerTreeTransactionIdAtLastTouchStart(0)
335 , m_hasNetworkRequestsOnSuspended(false)
337 , m_geolocationPermissionRequestManager(*this)
338 , m_notificationPermissionRequestManager(*this)
339 , m_userMediaPermissionRequestManager(*this)
340 , m_viewState(ViewState::NoFlags)
341 , m_viewWasEverInWindow(false)
343 , m_alwaysRunsAtForegroundPriority(m_configuration->alwaysRunsAtForegroundPriority())
345 , m_backForwardList(WebBackForwardList::create(*this))
346 , m_maintainsInactiveSelection(false)
347 , m_isEditable(false)
348 #if PLATFORM(MAC) && !USE(ASYNC_NSTEXTINPUTCLIENT)
349 , m_temporarilyClosedComposition(false)
351 , m_textZoomFactor(1)
352 , m_pageZoomFactor(1)
353 , m_pageScaleFactor(1)
354 , m_pluginZoomFactor(1)
355 , m_pluginScaleFactor(1)
356 , m_intrinsicDeviceScaleFactor(1)
357 , m_customDeviceScaleFactor(0)
358 , m_topContentInset(0)
359 , m_layerHostingMode(LayerHostingMode::InProcess)
360 , m_drawsBackground(true)
361 , m_useFixedLayout(false)
362 , m_suppressScrollbarAnimations(false)
363 , m_paginationMode(Pagination::Unpaginated)
364 , m_paginationBehavesLikeColumns(false)
366 , m_gapBetweenPages(0)
369 , m_canRunModal(false)
370 , m_isInPrintingMode(false)
371 , m_isPerformingDOMPrintOperation(false)
372 , m_inDecidePolicyForResponseSync(false)
373 , m_decidePolicyForResponseRequest(0)
374 , m_syncMimeTypePolicyActionIsValid(false)
375 , m_syncMimeTypePolicyAction(PolicyUse)
376 , m_syncMimeTypePolicyDownloadID(0)
377 , m_inDecidePolicyForNavigationAction(false)
378 , m_syncNavigationActionPolicyActionIsValid(false)
379 , m_syncNavigationActionPolicyAction(PolicyUse)
380 , m_syncNavigationActionPolicyDownloadID(0)
381 , m_processingMouseMoveEvent(false)
382 #if ENABLE(TOUCH_EVENTS)
383 , m_isTrackingTouchEvents(false)
386 , m_sessionID(m_configuration->sessionID())
387 , m_isPageSuspended(false)
388 , m_addsVisitedLinks(true)
389 #if ENABLE(REMOTE_INSPECTOR)
390 , m_allowsRemoteInspection(true)
393 , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
396 , m_backgroundColor(Color::white)
398 , m_spellDocumentTag(0)
399 , m_hasSpellDocumentTag(false)
400 , m_pendingLearnOrIgnoreWordMessageCount(0)
401 , m_mainFrameHasCustomContentProvider(false)
402 #if ENABLE(DRAG_SUPPORT)
403 , m_currentDragOperation(DragOperationNone)
404 , m_currentDragIsOverFileInput(false)
405 , m_currentDragNumberOfFilesToBeAccepted(0)
407 , m_pageLoadState(*this)
408 , m_delegatesScrolling(false)
409 , m_mainFrameHasHorizontalScrollbar(false)
410 , m_mainFrameHasVerticalScrollbar(false)
411 , m_canShortCircuitHorizontalWheelEvents(true)
412 , m_mainFrameIsPinnedToLeftSide(true)
413 , m_mainFrameIsPinnedToRightSide(true)
414 , m_mainFrameIsPinnedToTopSide(true)
415 , m_mainFrameIsPinnedToBottomSide(true)
416 , m_shouldUseImplicitRubberBandControl(false)
417 , m_rubberBandsAtLeft(true)
418 , m_rubberBandsAtRight(true)
419 , m_rubberBandsAtTop(true)
420 , m_rubberBandsAtBottom(true)
421 , m_enableVerticalRubberBanding(true)
422 , m_enableHorizontalRubberBanding(true)
423 , m_backgroundExtendsBeyondPage(false)
424 , m_shouldRecordNavigationSnapshots(false)
425 , m_isShowingNavigationGestureSnapshot(false)
427 , m_renderTreeSize(0)
428 , m_sessionRestorationRenderTreeSize(0)
429 , m_wantsSessionRestorationRenderTreeSizeThresholdEvent(false)
430 , m_hitRenderTreeSizeThreshold(false)
431 , m_suppressVisibilityUpdates(false)
432 , m_autoSizingShouldExpandToViewHeight(false)
435 , m_mayStartMediaWhenInWindow(true)
436 , m_waitingForDidUpdateViewState(false)
438 , m_scrollPerformanceDataCollectionEnabled(false)
440 , m_scrollPinningBehavior(DoNotPin)
442 , m_configurationPreferenceValues(m_configuration->preferenceValues())
443 , m_potentiallyChangedViewStateFlags(ViewState::NoFlags)
444 , m_viewStateChangeWantsSynchronousReply(false)
446 m_webProcessLifetimeTracker.addObserver(m_visitedLinkStore);
447 m_webProcessLifetimeTracker.addObserver(m_websiteDataStore);
449 if (m_process->state() == WebProcessProxy::State::Running) {
450 if (m_userContentController)
451 m_process->addWebUserContentControllerProxy(*m_userContentController);
452 m_process->addVisitedLinkStore(m_visitedLinkStore);
456 updateActivityToken();
457 updateProccessSuppressionState();
459 #if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
460 m_layerHostingMode = m_viewState & ViewState::IsInWindow ? m_pageClient.viewLayerHostingMode() : LayerHostingMode::OutOfProcess;
463 platformInitialize();
466 webPageProxyCounter.increment();
469 WebProcessPool::statistics().wkPageCount++;
471 m_preferences->addPage(*this);
472 m_pageGroup->addPage(this);
474 m_inspector = WebInspectorProxy::create(this);
475 #if ENABLE(FULLSCREEN_API)
476 m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
479 m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this);
481 #if ENABLE(VIBRATION)
482 m_vibration = WebVibrationProxy::create(this);
485 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
487 if (m_sessionID.isEphemeral())
488 m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::EnsurePrivateBrowsingSession(m_sessionID));
491 const CFIndex viewStateChangeRunLoopOrder = (CFIndex)RunLoopObserver::WellKnownRunLoopOrders::CoreAnimationCommit - 1;
492 m_viewStateChangeDispatcher = RunLoopObserver::create(viewStateChangeRunLoopOrder, [this] {
493 this->dispatchViewStateChange();
498 WebPageProxy::~WebPageProxy()
500 ASSERT(m_process->webPage(m_pageID) != this);
502 for (WebPageProxy* page : m_process->pages())
503 ASSERT(page != this);
509 WebProcessPool::statistics().wkPageCount--;
511 if (m_hasSpellDocumentTag)
512 TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
514 m_preferences->removePage(*this);
515 m_pageGroup->removePage(this);
518 webPageProxyCounter.decrement();
522 const API::PageConfiguration& WebPageProxy::configuration() const
524 return m_configuration.get();
527 PlatformProcessIdentifier WebPageProxy::processIdentifier() const
532 return m_process->processIdentifier();
535 bool WebPageProxy::isValid() const
537 // A page that has been explicitly closed is never valid.
544 void WebPageProxy::setPreferences(WebPreferences& preferences)
546 if (&preferences == m_preferences.ptr())
549 m_preferences->removePage(*this);
550 m_preferences = preferences;
551 m_preferences->addPage(*this);
553 preferencesDidChange();
556 void WebPageProxy::setHistoryClient(std::unique_ptr<API::HistoryClient> historyClient)
558 m_historyClient = WTF::move(historyClient);
561 void WebPageProxy::setNavigationClient(std::unique_ptr<API::NavigationClient> navigationClient)
563 m_navigationClient = WTF::move(navigationClient);
566 void WebPageProxy::setLoaderClient(std::unique_ptr<API::LoaderClient> loaderClient)
569 m_loaderClient = std::make_unique<API::LoaderClient>();
573 m_loaderClient = WTF::move(loaderClient);
576 void WebPageProxy::setPolicyClient(std::unique_ptr<API::PolicyClient> policyClient)
579 m_policyClient = std::make_unique<API::PolicyClient>();
583 m_policyClient = WTF::move(policyClient);
586 void WebPageProxy::setFormClient(std::unique_ptr<API::FormClient> formClient)
589 m_formClient = std::make_unique<API::FormClient>();
593 m_formClient = WTF::move(formClient);
596 void WebPageProxy::setUIClient(std::unique_ptr<API::UIClient> uiClient)
599 m_uiClient = std::make_unique<API::UIClient>();
603 m_uiClient = WTF::move(uiClient);
608 m_process->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient->canRunBeforeUnloadConfirmPanel()), m_pageID);
609 setCanRunModal(m_uiClient->canRunModal());
612 void WebPageProxy::setFindClient(std::unique_ptr<API::FindClient> findClient)
615 m_findClient = std::make_unique<API::FindClient>();
619 m_findClient = WTF::move(findClient);
622 void WebPageProxy::setFindMatchesClient(std::unique_ptr<API::FindMatchesClient> findMatchesClient)
624 if (!findMatchesClient) {
625 m_findMatchesClient = std::make_unique<API::FindMatchesClient>();
629 m_findMatchesClient = WTF::move(findMatchesClient);
632 void WebPageProxy::setDiagnosticLoggingClient(std::unique_ptr<API::DiagnosticLoggingClient> diagnosticLoggingClient)
634 if (!diagnosticLoggingClient) {
635 m_diagnosticLoggingClient = std::make_unique<API::DiagnosticLoggingClient>();
639 m_diagnosticLoggingClient = WTF::move(diagnosticLoggingClient);
642 #if ENABLE(CONTEXT_MENUS)
643 void WebPageProxy::setContextMenuClient(std::unique_ptr<API::ContextMenuClient> contextMenuClient)
645 if (!contextMenuClient) {
646 m_contextMenuClient = std::make_unique<API::ContextMenuClient>();
650 m_contextMenuClient = WTF::move(contextMenuClient);
654 void WebPageProxy::setInjectedBundleClient(const WKPageInjectedBundleClientBase* client)
657 m_injectedBundleClient = nullptr;
661 m_injectedBundleClient = std::make_unique<WebPageInjectedBundleClient>();
662 m_injectedBundleClient->initialize(client);
665 void WebPageProxy::handleMessage(IPC::Connection& connection, const String& messageName, const WebKit::UserData& messageBody)
667 auto* webProcessProxy = WebProcessProxy::fromConnection(&connection);
668 if (!webProcessProxy || !m_injectedBundleClient)
670 m_injectedBundleClient->didReceiveMessageFromInjectedBundle(this, messageName, webProcessProxy->transformHandlesToObjects(messageBody.object()).get());
673 void WebPageProxy::handleSynchronousMessage(IPC::Connection& connection, const String& messageName, const UserData& messageBody, UserData& returnUserData)
675 if (!WebProcessProxy::fromConnection(&connection) || !m_injectedBundleClient)
678 RefPtr<API::Object> returnData;
679 m_injectedBundleClient->didReceiveSynchronousMessageFromInjectedBundle(this, messageName, WebProcessProxy::fromConnection(&connection)->transformHandlesToObjects(messageBody.object()).get(), returnData);
680 returnUserData = UserData(WebProcessProxy::fromConnection(&connection)->transformObjectsToHandles(returnData.get()));
684 void WebPageProxy::reattachToWebProcess()
688 ASSERT(m_process->state() == WebProcessProxy::State::Terminated);
691 m_process->removeWebPage(m_pageID);
692 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
694 if (m_process->processPool().processModel() == ProcessModelSharedSecondaryProcess)
695 m_process = m_process->processPool().ensureSharedWebProcess();
697 m_process = m_process->processPool().createNewWebProcessRespectingProcessCountLimit();
699 ASSERT(m_process->state() != ChildProcessProxy::State::Terminated);
700 if (m_process->state() == ChildProcessProxy::State::Running)
701 processDidFinishLaunching();
702 m_process->addExistingWebPage(this, m_pageID);
703 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
706 updateActivityToken();
708 m_inspector = WebInspectorProxy::create(this);
709 #if ENABLE(FULLSCREEN_API)
710 m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
713 m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this);
718 m_pageClient.didRelaunchProcess();
719 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
722 RefPtr<API::Navigation> WebPageProxy::reattachToWebProcessForReload()
728 reattachToWebProcess();
730 if (!m_backForwardList->currentItem())
733 auto navigation = m_navigationState->createReloadNavigation();
735 // We allow stale content when reloading a WebProcess that's been killed or crashed.
736 m_process->send(Messages::WebPage::GoToBackForwardItem(navigation->navigationID(), m_backForwardList->currentItem()->itemID()), m_pageID);
737 m_process->responsivenessTimer().start();
739 return WTF::move(navigation);
742 RefPtr<API::Navigation> WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
747 if (item && item != m_backForwardList->currentItem())
748 m_backForwardList->goToItem(item);
751 reattachToWebProcess();
756 auto navigation = m_navigationState->createBackForwardNavigation();
758 m_process->send(Messages::WebPage::GoToBackForwardItem(navigation->navigationID(), item->itemID()), m_pageID);
759 m_process->responsivenessTimer().start();
761 return WTF::move(navigation);
764 void WebPageProxy::setSessionID(SessionID sessionID)
769 m_sessionID = sessionID;
770 m_process->send(Messages::WebPage::SetSessionID(sessionID), m_pageID);
772 if (sessionID.isEphemeral())
773 m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::EnsurePrivateBrowsingSession(sessionID));
776 void WebPageProxy::initializeWebPage()
780 BackForwardListItemVector items = m_backForwardList->entries();
781 for (size_t i = 0; i < items.size(); ++i)
782 m_process->registerNewWebBackForwardListItem(items[i].get());
784 m_drawingArea = m_pageClient.createDrawingAreaProxy();
785 ASSERT(m_drawingArea);
787 #if ENABLE(ASYNC_SCROLLING)
788 if (m_drawingArea->type() == DrawingAreaTypeRemoteLayerTree) {
789 m_scrollingCoordinatorProxy = std::make_unique<RemoteScrollingCoordinatorProxy>(*this);
791 // On iOS, main frame scrolls are sent in terms of visible rect updates.
792 m_scrollingCoordinatorProxy->setPropagatesMainFrameScrolls(false);
797 #if ENABLE(INSPECTOR_SERVER)
798 if (m_preferences->developerExtrasEnabled())
799 inspector()->enableRemoteInspection();
802 process().send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
805 send(Messages::WebPage::SetSmartInsertDeleteEnabled(m_isSmartInsertDeleteEnabled));
809 void WebPageProxy::close()
816 if (m_activePopupMenu)
817 m_activePopupMenu->cancelTracking();
819 #if ENABLE(CONTEXT_MENUS)
820 m_activeContextMenu = nullptr;
823 m_backForwardList->pageClosed();
824 m_pageClient.pageClosed();
826 m_process->disconnectFramesFromPage(this);
828 resetState(ResetStateReason::PageInvalidated);
830 m_loaderClient = std::make_unique<API::LoaderClient>();
831 m_policyClient = std::make_unique<API::PolicyClient>();
832 m_formClient = std::make_unique<API::FormClient>();
833 m_uiClient = std::make_unique<API::UIClient>();
835 m_uiPopupMenuClient.initialize(nullptr);
837 m_findClient = std::make_unique<API::FindClient>();
838 m_findMatchesClient = std::make_unique<API::FindMatchesClient>();
839 m_diagnosticLoggingClient = std::make_unique<API::DiagnosticLoggingClient>();
840 #if ENABLE(CONTEXT_MENUS)
841 m_contextMenuClient = std::make_unique<API::ContextMenuClient>();
844 m_webProcessLifetimeTracker.pageWasInvalidated();
846 m_process->send(Messages::WebPage::Close(), m_pageID);
847 m_process->removeWebPage(m_pageID);
848 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
849 m_process->processPool().supplement<WebNotificationManagerProxy>()->clearNotifications(this);
852 bool WebPageProxy::tryClose()
857 // Close without delay if the process allows it. Our goal is to terminate
858 // the process, so we check a per-process status bit.
859 if (m_process->isSuddenTerminationEnabled())
862 m_process->send(Messages::WebPage::TryClose(), m_pageID);
863 m_process->responsivenessTimer().start();
867 bool WebPageProxy::maybeInitializeSandboxExtensionHandle(const URL& url, SandboxExtension::Handle& sandboxExtensionHandle)
869 if (!url.isLocalFile())
872 if (m_process->hasAssumedReadAccessToURL(url))
875 // Inspector resources are in a directory with assumed access.
876 ASSERT_WITH_SECURITY_IMPLICATION(!WebInspectorProxy::isInspectorPage(*this));
878 SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
882 RefPtr<API::Navigation> WebPageProxy::loadRequest(const ResourceRequest& request, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, API::Object* userData)
887 auto navigation = m_navigationState->createLoadRequestNavigation(request);
889 auto transaction = m_pageLoadState.transaction();
891 m_pageLoadState.setPendingAPIRequestURL(transaction, request.url());
894 reattachToWebProcess();
896 SandboxExtension::Handle sandboxExtensionHandle;
897 bool createdExtension = maybeInitializeSandboxExtensionHandle(request.url(), sandboxExtensionHandle);
898 if (createdExtension)
899 m_process->willAcquireUniversalFileReadSandboxExtension();
900 m_process->send(Messages::WebPage::LoadRequest(navigation->navigationID(), request, sandboxExtensionHandle, (uint64_t)shouldOpenExternalURLsPolicy, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
901 m_process->responsivenessTimer().start();
903 return WTF::move(navigation);
906 RefPtr<API::Navigation> WebPageProxy::loadFile(const String& fileURLString, const String& resourceDirectoryURLString, API::Object* userData)
912 reattachToWebProcess();
914 URL fileURL = URL(URL(), fileURLString);
915 if (!fileURL.isLocalFile())
918 URL resourceDirectoryURL;
919 if (resourceDirectoryURLString.isNull())
920 resourceDirectoryURL = URL(ParsedURLString, ASCIILiteral("file:///"));
922 resourceDirectoryURL = URL(URL(), resourceDirectoryURLString);
923 if (!resourceDirectoryURL.isLocalFile())
927 auto navigation = m_navigationState->createLoadRequestNavigation(ResourceRequest(fileURL));
929 auto transaction = m_pageLoadState.transaction();
931 m_pageLoadState.setPendingAPIRequestURL(transaction, fileURLString);
933 String resourceDirectoryPath = resourceDirectoryURL.fileSystemPath();
935 SandboxExtension::Handle sandboxExtensionHandle;
936 SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::ReadOnly, sandboxExtensionHandle);
937 m_process->assumeReadAccessToBaseURL(resourceDirectoryURL);
938 m_process->send(Messages::WebPage::LoadRequest(navigation->navigationID(), fileURL, sandboxExtensionHandle, (uint64_t)ShouldOpenExternalURLsPolicy::ShouldNotAllow, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
939 m_process->responsivenessTimer().start();
941 return WTF::move(navigation);
944 RefPtr<API::Navigation> WebPageProxy::loadData(API::Data* data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData)
949 auto navigation = m_navigationState->createLoadDataNavigation();
951 auto transaction = m_pageLoadState.transaction();
953 m_pageLoadState.setPendingAPIRequestURL(transaction, !baseURL.isEmpty() ? baseURL : ASCIILiteral("about:blank"));
956 reattachToWebProcess();
958 m_process->assumeReadAccessToBaseURL(baseURL);
959 m_process->send(Messages::WebPage::LoadData(navigation->navigationID(), data->dataReference(), MIMEType, encoding, baseURL, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
960 m_process->responsivenessTimer().start();
962 return WTF::move(navigation);
965 // FIXME: Get rid of loadHTMLString and just use loadData instead.
966 RefPtr<API::Navigation> WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL, API::Object* userData)
971 auto navigation = m_navigationState->createLoadDataNavigation();
973 auto transaction = m_pageLoadState.transaction();
975 m_pageLoadState.setPendingAPIRequestURL(transaction, !baseURL.isEmpty() ? baseURL : ASCIILiteral("about:blank"));
978 reattachToWebProcess();
980 m_process->assumeReadAccessToBaseURL(baseURL);
981 m_process->send(Messages::WebPage::LoadHTMLString(navigation->navigationID(), htmlString, baseURL, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
982 m_process->responsivenessTimer().start();
984 return WTF::move(navigation);
987 void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, API::Object* userData)
993 reattachToWebProcess();
995 auto transaction = m_pageLoadState.transaction();
997 m_pageLoadState.setUnreachableURL(transaction, unreachableURL);
1000 m_mainFrame->setUnreachableURL(unreachableURL);
1002 m_process->assumeReadAccessToBaseURL(baseURL);
1003 m_process->assumeReadAccessToBaseURL(unreachableURL);
1004 m_process->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL, m_failingProvisionalLoadURL, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
1005 m_process->responsivenessTimer().start();
1008 void WebPageProxy::loadPlainTextString(const String& string, API::Object* userData)
1014 reattachToWebProcess();
1016 m_process->send(Messages::WebPage::LoadPlainTextString(string, UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
1017 m_process->responsivenessTimer().start();
1020 void WebPageProxy::loadWebArchiveData(API::Data* webArchiveData, API::Object* userData)
1026 reattachToWebProcess();
1028 m_process->send(Messages::WebPage::LoadWebArchiveData(webArchiveData->dataReference(), UserData(process().transformObjectsToHandles(userData).get())), m_pageID);
1029 m_process->responsivenessTimer().start();
1032 void WebPageProxy::navigateToPDFLinkWithSimulatedClick(const String& url, IntPoint documentPoint, IntPoint screenPoint)
1037 if (WebCore::protocolIsJavaScript(url))
1041 reattachToWebProcess();
1043 m_process->send(Messages::WebPage::NavigateToPDFLinkWithSimulatedClick(url, documentPoint, screenPoint), m_pageID);
1044 m_process->responsivenessTimer().start();
1047 void WebPageProxy::stopLoading()
1052 m_process->send(Messages::WebPage::StopLoading(), m_pageID);
1053 m_process->responsivenessTimer().start();
1056 RefPtr<API::Navigation> WebPageProxy::reload(bool reloadFromOrigin, bool contentBlockersEnabled)
1058 SandboxExtension::Handle sandboxExtensionHandle;
1060 if (m_backForwardList->currentItem()) {
1061 String url = m_backForwardList->currentItem()->url();
1062 auto transaction = m_pageLoadState.transaction();
1063 m_pageLoadState.setPendingAPIRequestURL(transaction, url);
1065 // We may not have an extension yet if back/forward list was reinstated after a WebProcess crash or a browser relaunch
1066 bool createdExtension = maybeInitializeSandboxExtensionHandle(URL(URL(), url), sandboxExtensionHandle);
1067 if (createdExtension)
1068 m_process->willAcquireUniversalFileReadSandboxExtension();
1072 return reattachToWebProcessForReload();
1074 auto navigation = m_navigationState->createReloadNavigation();
1076 m_process->send(Messages::WebPage::Reload(navigation->navigationID(), reloadFromOrigin, contentBlockersEnabled, sandboxExtensionHandle), m_pageID);
1077 m_process->responsivenessTimer().start();
1079 return WTF::move(navigation);
1082 void WebPageProxy::recordNavigationSnapshot()
1084 if (WebBackForwardListItem* item = m_backForwardList->currentItem())
1085 recordNavigationSnapshot(*item);
1088 void WebPageProxy::recordNavigationSnapshot(WebBackForwardListItem& item)
1090 if (!m_shouldRecordNavigationSnapshots || m_suppressNavigationSnapshotting)
1094 ViewSnapshotStore::singleton().recordSnapshot(*this, item);
1100 RefPtr<API::Navigation> WebPageProxy::goForward()
1102 WebBackForwardListItem* forwardItem = m_backForwardList->forwardItem();
1106 auto transaction = m_pageLoadState.transaction();
1108 m_pageLoadState.setPendingAPIRequestURL(transaction, forwardItem->url());
1111 return reattachToWebProcessWithItem(forwardItem);
1113 RefPtr<API::Navigation> navigation;
1114 if (!m_backForwardList->currentItem()->itemIsInSameDocument(*forwardItem))
1115 navigation = m_navigationState->createBackForwardNavigation();
1117 m_process->send(Messages::WebPage::GoForward(navigation ? navigation->navigationID() : 0, forwardItem->itemID()), m_pageID);
1118 m_process->responsivenessTimer().start();
1123 RefPtr<API::Navigation> WebPageProxy::goBack()
1125 WebBackForwardListItem* backItem = m_backForwardList->backItem();
1129 auto transaction = m_pageLoadState.transaction();
1131 m_pageLoadState.setPendingAPIRequestURL(transaction, backItem->url());
1134 return reattachToWebProcessWithItem(backItem);
1136 RefPtr<API::Navigation> navigation;
1137 if (!m_backForwardList->currentItem()->itemIsInSameDocument(*backItem))
1138 navigation = m_navigationState->createBackForwardNavigation();
1140 m_process->send(Messages::WebPage::GoBack(navigation ? navigation->navigationID() : 0, backItem->itemID()), m_pageID);
1141 m_process->responsivenessTimer().start();
1146 RefPtr<API::Navigation> WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
1149 return reattachToWebProcessWithItem(item);
1151 auto transaction = m_pageLoadState.transaction();
1153 m_pageLoadState.setPendingAPIRequestURL(transaction, item->url());
1155 RefPtr<API::Navigation> navigation;
1156 if (!m_backForwardList->currentItem()->itemIsInSameDocument(*item))
1157 navigation = m_navigationState->createBackForwardNavigation();
1159 m_process->send(Messages::WebPage::GoToBackForwardItem(navigation ? navigation->navigationID() : 0, item->itemID()), m_pageID);
1160 m_process->responsivenessTimer().start();
1165 void WebPageProxy::tryRestoreScrollPosition()
1170 m_process->send(Messages::WebPage::TryRestoreScrollPosition(), m_pageID);
1173 void WebPageProxy::didChangeBackForwardList(WebBackForwardListItem* added, Vector<RefPtr<WebBackForwardListItem>> removed)
1175 PageClientProtector protector(m_pageClient);
1177 m_loaderClient->didChangeBackForwardList(*this, added, WTF::move(removed));
1179 auto transaction = m_pageLoadState.transaction();
1181 m_pageLoadState.setCanGoBack(transaction, m_backForwardList->backItem());
1182 m_pageLoadState.setCanGoForward(transaction, m_backForwardList->forwardItem());
1185 void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, const UserData& userData)
1187 PageClientProtector protector(m_pageClient);
1189 if (WebBackForwardListItem* item = m_process->webBackForwardItem(itemID))
1190 m_loaderClient->willGoToBackForwardListItem(*this, item, m_process->transformHandlesToObjects(userData.object()).get());
1193 bool WebPageProxy::shouldKeepCurrentBackForwardListItemInList(WebBackForwardListItem* item)
1195 PageClientProtector protector(m_pageClient);
1197 return m_loaderClient->shouldKeepCurrentBackForwardListItemInList(*this, item);
1200 bool WebPageProxy::canShowMIMEType(const String& mimeType)
1202 if (MIMETypeRegistry::canShowMIMEType(mimeType))
1205 #if ENABLE(NETSCAPE_PLUGIN_API)
1206 String newMimeType = mimeType;
1207 PluginModuleInfo plugin = m_process->processPool().pluginInfoStore().findPlugin(newMimeType, URL());
1208 if (!plugin.path.isNull() && m_preferences->pluginsEnabled())
1210 #endif // ENABLE(NETSCAPE_PLUGIN_API)
1213 // On Mac, we can show PDFs.
1214 if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(mimeType) && !WebProcessPool::omitPDFSupport())
1216 #endif // PLATFORM(COCOA)
1221 #if ENABLE(REMOTE_INSPECTOR)
1222 void WebPageProxy::setAllowsRemoteInspection(bool allow)
1224 if (m_allowsRemoteInspection == allow)
1227 m_allowsRemoteInspection = allow;
1230 m_process->send(Messages::WebPage::SetAllowsRemoteInspection(allow), m_pageID);
1233 void WebPageProxy::setRemoteInspectionNameOverride(const String& name)
1235 if (m_remoteInspectionNameOverride == name)
1238 m_remoteInspectionNameOverride = name;
1241 m_process->send(Messages::WebPage::SetRemoteInspectionNameOverride(m_remoteInspectionNameOverride), m_pageID);
1246 void WebPageProxy::setDrawsBackground(bool drawsBackground)
1248 if (m_drawsBackground == drawsBackground)
1251 m_drawsBackground = drawsBackground;
1254 m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
1257 void WebPageProxy::setTopContentInset(float contentInset)
1259 if (m_topContentInset == contentInset)
1262 m_topContentInset = contentInset;
1265 m_process->send(Messages::WebPage::SetTopContentInset(contentInset), m_pageID);
1268 void WebPageProxy::setUnderlayColor(const Color& color)
1270 if (m_underlayColor == color)
1273 m_underlayColor = color;
1276 m_process->send(Messages::WebPage::SetUnderlayColor(color), m_pageID);
1279 void WebPageProxy::viewWillStartLiveResize()
1283 #if ENABLE(INPUT_TYPE_COLOR_POPOVER) && ENABLE(INPUT_TYPE_COLOR)
1287 m_process->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID);
1290 void WebPageProxy::viewWillEndLiveResize()
1294 m_process->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
1297 void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
1299 m_pageClient.setViewNeedsDisplay(rect);
1302 void WebPageProxy::displayView()
1304 m_pageClient.displayView();
1307 bool WebPageProxy::canScrollView()
1309 return m_pageClient.canScrollView();
1312 void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
1314 m_pageClient.scrollView(scrollRect, scrollOffset);
1317 void WebPageProxy::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, bool isProgrammaticScroll)
1319 m_pageClient.requestScroll(scrollPosition, scrollOrigin, isProgrammaticScroll);
1322 void WebPageProxy::setSuppressVisibilityUpdates(bool flag)
1324 if (m_suppressVisibilityUpdates == flag)
1326 m_suppressVisibilityUpdates = flag;
1328 if (!m_suppressVisibilityUpdates) {
1330 m_viewStateChangeDispatcher->schedule();
1332 dispatchViewStateChange();
1337 void WebPageProxy::updateViewState(ViewState::Flags flagsToUpdate)
1339 m_viewState &= ~flagsToUpdate;
1340 if (flagsToUpdate & ViewState::IsFocused && m_pageClient.isViewFocused())
1341 m_viewState |= ViewState::IsFocused;
1342 if (flagsToUpdate & ViewState::WindowIsActive && m_pageClient.isViewWindowActive())
1343 m_viewState |= ViewState::WindowIsActive;
1344 if (flagsToUpdate & ViewState::IsVisible && m_pageClient.isViewVisible())
1345 m_viewState |= ViewState::IsVisible;
1346 if (flagsToUpdate & ViewState::IsVisibleOrOccluded && m_pageClient.isViewVisibleOrOccluded())
1347 m_viewState |= ViewState::IsVisibleOrOccluded;
1348 if (flagsToUpdate & ViewState::IsInWindow && m_pageClient.isViewInWindow())
1349 m_viewState |= ViewState::IsInWindow;
1350 if (flagsToUpdate & ViewState::IsVisuallyIdle && m_pageClient.isVisuallyIdle())
1351 m_viewState |= ViewState::IsVisuallyIdle;
1354 void WebPageProxy::viewStateDidChange(ViewState::Flags mayHaveChanged, bool wantsSynchronousReply, ViewStateChangeDispatchMode dispatchMode)
1356 m_potentiallyChangedViewStateFlags |= mayHaveChanged;
1357 m_viewStateChangeWantsSynchronousReply = m_viewStateChangeWantsSynchronousReply || wantsSynchronousReply;
1359 if (m_suppressVisibilityUpdates && dispatchMode != ViewStateChangeDispatchMode::Immediate)
1363 bool isNewlyInWindow = !isInWindow() && (mayHaveChanged & ViewState::IsInWindow) && m_pageClient.isViewInWindow();
1364 if (dispatchMode == ViewStateChangeDispatchMode::Immediate || isNewlyInWindow) {
1365 dispatchViewStateChange();
1368 m_viewStateChangeDispatcher->schedule();
1370 UNUSED_PARAM(dispatchMode);
1371 dispatchViewStateChange();
1375 void WebPageProxy::viewDidLeaveWindow()
1377 #if ENABLE(INPUT_TYPE_COLOR_POPOVER) && ENABLE(INPUT_TYPE_COLOR)
1378 // When leaving the current page, close the popover color well.
1383 // When leaving the current page, close the video fullscreen.
1384 if (m_videoFullscreenManager)
1385 m_videoFullscreenManager->requestHideAndExitFullscreen();
1389 void WebPageProxy::viewDidEnterWindow()
1391 LayerHostingMode layerHostingMode = m_pageClient.viewLayerHostingMode();
1392 if (m_layerHostingMode != layerHostingMode) {
1393 m_layerHostingMode = layerHostingMode;
1394 m_process->send(Messages::WebPage::SetLayerHostingMode(static_cast<unsigned>(layerHostingMode)), m_pageID);
1398 void WebPageProxy::dispatchViewStateChange()
1401 m_viewStateChangeDispatcher->invalidate();
1407 // If the visibility state may have changed, then so may the visually idle & occluded agnostic state.
1408 if (m_potentiallyChangedViewStateFlags & ViewState::IsVisible)
1409 m_potentiallyChangedViewStateFlags |= ViewState::IsVisibleOrOccluded | ViewState::IsVisuallyIdle;
1411 // Record the prior view state, update the flags that may have changed,
1412 // and check which flags have actually changed.
1413 ViewState::Flags previousViewState = m_viewState;
1414 updateViewState(m_potentiallyChangedViewStateFlags);
1415 ViewState::Flags changed = m_viewState ^ previousViewState;
1417 bool isNowInWindow = (changed & ViewState::IsInWindow) && isInWindow();
1418 // We always want to wait for the Web process to reply if we've been in-window before and are coming back in-window.
1419 if (m_viewWasEverInWindow && isNowInWindow && m_drawingArea->hasVisibleContent())
1420 m_viewStateChangeWantsSynchronousReply = true;
1422 // Don't wait synchronously if the view state is not visible. (This matters in particular on iOS, where a hidden page may be suspended.)
1423 if (!(m_viewState & ViewState::IsVisible))
1424 m_viewStateChangeWantsSynchronousReply = false;
1426 if (changed || m_viewStateChangeWantsSynchronousReply || !m_nextViewStateChangeCallbacks.isEmpty())
1427 m_process->send(Messages::WebPage::SetViewState(m_viewState, m_viewStateChangeWantsSynchronousReply, m_nextViewStateChangeCallbacks), m_pageID);
1429 m_nextViewStateChangeCallbacks.clear();
1431 // This must happen after the SetViewState message is sent, to ensure the page visibility event can fire.
1432 updateActivityToken();
1434 // If we've started the responsiveness timer as part of telling the web process to update the backing store
1435 // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we
1436 // stop the unresponsiveness timer here.
1437 if ((changed & ViewState::IsVisible) && !isViewVisible())
1438 m_process->responsivenessTimer().stop();
1440 if (changed & ViewState::IsInWindow) {
1442 viewDidEnterWindow();
1444 viewDidLeaveWindow();
1447 updateBackingStoreDiscardableState();
1449 if (m_viewStateChangeWantsSynchronousReply)
1450 waitForDidUpdateViewState();
1452 m_potentiallyChangedViewStateFlags = ViewState::NoFlags;
1453 m_viewStateChangeWantsSynchronousReply = false;
1454 m_viewWasEverInWindow |= isNowInWindow;
1457 void WebPageProxy::updateActivityToken()
1459 if (m_viewState & ViewState::IsVisuallyIdle)
1460 m_pageIsUserObservableCount = nullptr;
1461 else if (!m_pageIsUserObservableCount)
1462 m_pageIsUserObservableCount = m_process->processPool().userObservablePageCount();
1465 if (!isViewVisible() && !m_alwaysRunsAtForegroundPriority)
1466 m_activityToken = nullptr;
1467 else if (!m_activityToken)
1468 m_activityToken = m_process->throttler().foregroundActivityToken();
1472 void WebPageProxy::updateProccessSuppressionState()
1474 if (m_preferences->pageVisibilityBasedProcessSuppressionEnabled())
1475 m_preventProcessSuppressionCount = nullptr;
1476 else if (!m_preventProcessSuppressionCount)
1477 m_preventProcessSuppressionCount = m_process->processPool().processSuppressionDisabledForPageCount();
1480 void WebPageProxy::layerHostingModeDidChange()
1485 LayerHostingMode layerHostingMode = m_pageClient.viewLayerHostingMode();
1486 if (m_layerHostingMode == layerHostingMode)
1489 m_layerHostingMode = layerHostingMode;
1490 m_process->send(Messages::WebPage::SetLayerHostingMode(static_cast<unsigned>(layerHostingMode)), m_pageID);
1493 void WebPageProxy::waitForDidUpdateViewState()
1498 if (m_process->state() != WebProcessProxy::State::Running)
1501 // If we have previously timed out with no response from the WebProcess, don't block the UIProcess again until it starts responding.
1502 if (m_waitingForDidUpdateViewState)
1506 // Hail Mary check. Should not be possible (dispatchViewStateChange should force async if not visible,
1507 // and if visible we should be holding an assertion) - but we should never block on a suspended process.
1508 if (!m_activityToken) {
1509 ASSERT_NOT_REACHED();
1514 m_waitingForDidUpdateViewState = true;
1516 m_drawingArea->waitForDidUpdateViewState();
1519 IntSize WebPageProxy::viewSize() const
1521 return m_pageClient.viewSize();
1524 void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent, std::function<void (CallbackBase::Error)> callbackFunction)
1527 callbackFunction(CallbackBase::Error::OwnerWasInvalidated);
1531 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
1532 m_process->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent, callbackID), m_pageID);
1535 void WebPageProxy::clearSelection()
1539 m_process->send(Messages::WebPage::ClearSelection(), m_pageID);
1542 void WebPageProxy::restoreSelectionInFocusedEditableElement()
1546 m_process->send(Messages::WebPage::RestoreSelectionInFocusedEditableElement(), m_pageID);
1549 void WebPageProxy::validateCommand(const String& commandName, std::function<void (const String&, bool, int32_t, CallbackBase::Error)> callbackFunction)
1552 callbackFunction(String(), false, 0, CallbackBase::Error::Unknown);
1556 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
1557 m_process->send(Messages::WebPage::ValidateCommand(commandName, callbackID), m_pageID);
1560 void WebPageProxy::setMaintainsInactiveSelection(bool newValue)
1562 m_maintainsInactiveSelection = newValue;
1565 void WebPageProxy::executeEditCommand(const String& commandName, const String& argument)
1567 static NeverDestroyed<String> ignoreSpellingCommandName(ASCIILiteral("ignoreSpelling"));
1572 if (commandName == ignoreSpellingCommandName)
1573 ++m_pendingLearnOrIgnoreWordMessageCount;
1575 m_process->send(Messages::WebPage::ExecuteEditCommand(commandName, argument), m_pageID);
1578 void WebPageProxy::setEditable(bool editable)
1580 if (editable == m_isEditable)
1585 m_isEditable = editable;
1586 m_process->send(Messages::WebPage::SetEditable(editable), m_pageID);
1590 void WebPageProxy::didCommitLayerTree(const RemoteLayerTreeTransaction&)
1595 #if ENABLE(DRAG_SUPPORT)
1596 void WebPageProxy::dragEntered(DragData& dragData, const String& dragStorageName)
1598 SandboxExtension::Handle sandboxExtensionHandle;
1599 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1600 performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1603 void WebPageProxy::dragUpdated(DragData& dragData, const String& dragStorageName)
1605 SandboxExtension::Handle sandboxExtensionHandle;
1606 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1607 performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1610 void WebPageProxy::dragExited(DragData& dragData, const String& dragStorageName)
1612 SandboxExtension::Handle sandboxExtensionHandle;
1613 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1614 performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1617 void WebPageProxy::performDragOperation(DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1619 performDragControllerAction(DragControllerActionPerformDragOperation, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionsForUpload);
1622 void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1627 UNUSED_PARAM(dragStorageName);
1628 UNUSED_PARAM(sandboxExtensionHandle);
1629 UNUSED_PARAM(sandboxExtensionsForUpload);
1631 String url = dragData.asURL();
1633 m_process->assumeReadAccessToBaseURL(url);
1634 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData), m_pageID);
1636 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), dragStorageName, dragData.flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
1640 void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted)
1642 MESSAGE_CHECK(dragOperation <= DragOperationDelete);
1644 m_currentDragOperation = static_cast<DragOperation>(dragOperation);
1645 m_currentDragIsOverFileInput = mouseIsOverFileInput;
1646 m_currentDragNumberOfFilesToBeAccepted = numberOfItemsToBeAccepted;
1650 void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle)
1652 RefPtr<ShareableBitmap> dragImage = 0;
1653 if (!dragImageHandle.isNull()) {
1654 dragImage = ShareableBitmap::create(dragImageHandle);
1659 m_pageClient.startDrag(dragData, dragImage.release());
1663 void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
1667 m_process->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID);
1669 #endif // ENABLE(DRAG_SUPPORT)
1671 void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
1676 // NOTE: This does not start the responsiveness timer because mouse move should not indicate interaction.
1677 if (event.type() != WebEvent::MouseMove)
1678 m_process->responsivenessTimer().start();
1680 if (m_processingMouseMoveEvent) {
1681 m_nextMouseMoveEvent = std::make_unique<NativeWebMouseEvent>(event);
1685 m_processingMouseMoveEvent = true;
1688 // <https://bugs.webkit.org/show_bug.cgi?id=57904> We need to keep track of the mouse down event in the case where we
1689 // display a popup menu for select elements. When the user changes the selected item,
1690 // we fake a mouse up event by using this stored down event. This event gets cleared
1691 // when the mouse up message is received from WebProcess.
1692 if (event.type() == WebEvent::MouseDown)
1693 m_currentlyProcessedMouseDownEvent = std::make_unique<NativeWebMouseEvent>(event);
1695 m_process->send(Messages::WebPage::MouseEvent(event), m_pageID);
1698 #if MERGE_WHEEL_EVENTS
1699 static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1701 if (a.position() != b.position())
1703 if (a.globalPosition() != b.globalPosition())
1705 if (a.modifiers() != b.modifiers())
1707 if (a.granularity() != b.granularity())
1710 if (a.phase() != b.phase())
1712 if (a.momentumPhase() != b.momentumPhase())
1714 if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
1721 static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1723 ASSERT(canCoalesce(a, b));
1725 FloatSize mergedDelta = a.delta() + b.delta();
1726 FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
1729 FloatSize mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
1731 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.directionInvertedFromDevice(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.scrollCount(), mergedUnacceleratedScrollingDelta, b.modifiers(), b.timestamp());
1733 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
1736 #endif // MERGE_WHEEL_EVENTS
1738 static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
1740 ASSERT(!queue.isEmpty());
1741 ASSERT(coalescedEvents.isEmpty());
1743 #if MERGE_WHEEL_EVENTS
1744 NativeWebWheelEvent firstEvent = queue.takeFirst();
1745 coalescedEvents.append(firstEvent);
1747 WebWheelEvent event = firstEvent;
1748 while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
1749 NativeWebWheelEvent firstEvent = queue.takeFirst();
1750 coalescedEvents.append(firstEvent);
1751 event = coalesce(event, firstEvent);
1756 while (!queue.isEmpty())
1757 coalescedEvents.append(queue.takeFirst());
1758 return coalescedEvents.last();
1762 void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
1764 #if ENABLE(ASYNC_SCROLLING)
1765 if (m_scrollingCoordinatorProxy && m_scrollingCoordinatorProxy->handleWheelEvent(platform(event)))
1772 if (!m_currentlyProcessedWheelEvents.isEmpty()) {
1773 m_wheelEventQueue.append(event);
1774 if (m_wheelEventQueue.size() < wheelEventQueueSizeThreshold)
1776 // The queue has too many wheel events, so push a new event.
1779 if (!m_wheelEventQueue.isEmpty()) {
1780 processNextQueuedWheelEvent();
1784 auto coalescedWheelEvent = std::make_unique<Vector<NativeWebWheelEvent>>();
1785 coalescedWheelEvent->append(event);
1786 m_currentlyProcessedWheelEvents.append(WTF::move(coalescedWheelEvent));
1787 sendWheelEvent(event);
1790 void WebPageProxy::processNextQueuedWheelEvent()
1792 auto nextCoalescedEvent = std::make_unique<Vector<NativeWebWheelEvent>>();
1793 WebWheelEvent nextWheelEvent = coalescedWheelEvent(m_wheelEventQueue, *nextCoalescedEvent.get());
1794 m_currentlyProcessedWheelEvents.append(WTF::move(nextCoalescedEvent));
1795 sendWheelEvent(nextWheelEvent);
1798 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
1800 m_process->responsivenessTimer().start();
1803 Messages::EventDispatcher::WheelEvent(
1806 shouldUseImplicitRubberBandControl() ? !m_backForwardList->backItem() : rubberBandsAtLeft(),
1807 shouldUseImplicitRubberBandControl() ? !m_backForwardList->forwardItem() : rubberBandsAtRight(),
1809 rubberBandsAtBottom()
1813 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
1818 LOG(KeyHandling, "WebPageProxy::handleKeyboardEvent: %s", webKeyboardEventTypeString(event.type()));
1820 m_keyEventQueue.append(event);
1822 m_process->responsivenessTimer().start();
1823 if (m_keyEventQueue.size() == 1) // Otherwise, sent from DidReceiveEvent message handler.
1824 m_process->send(Messages::WebPage::KeyEvent(event), m_pageID);
1827 WebPreferencesStore WebPageProxy::preferencesStore() const
1829 if (m_configurationPreferenceValues.isEmpty())
1830 return m_preferences->store();
1832 WebPreferencesStore store = m_preferences->store();
1833 for (const auto& preference : m_configurationPreferenceValues)
1834 store.m_values.set(preference.key, preference.value);
1839 #if ENABLE(NETSCAPE_PLUGIN_API)
1840 void WebPageProxy::findPlugin(const String& mimeType, uint32_t processType, const String& urlString, const String& frameURLString, const String& pageURLString, bool allowOnlyApplicationPlugins, uint64_t& pluginProcessToken, String& newMimeType, uint32_t& pluginLoadPolicy, String& unavailabilityDescription)
1842 PageClientProtector protector(m_pageClient);
1844 MESSAGE_CHECK_URL(urlString);
1846 newMimeType = mimeType.lower();
1847 pluginLoadPolicy = PluginModuleLoadNormally;
1849 PluginData::AllowedPluginTypes allowedPluginTypes = allowOnlyApplicationPlugins ? PluginData::OnlyApplicationPlugins : PluginData::AllPlugins;
1850 PluginModuleInfo plugin = m_process->processPool().pluginInfoStore().findPlugin(newMimeType, URL(URL(), urlString), allowedPluginTypes);
1852 pluginProcessToken = 0;
1856 pluginLoadPolicy = PluginInfoStore::defaultLoadPolicyForPlugin(plugin);
1859 RefPtr<API::Dictionary> pluginInformation = createPluginInformationDictionary(plugin, frameURLString, String(), pageURLString, String(), String());
1860 if (m_navigationClient)
1861 pluginLoadPolicy = m_navigationClient->decidePolicyForPluginLoad(*this, static_cast<PluginModuleLoadPolicy>(pluginLoadPolicy), pluginInformation.get(), unavailabilityDescription);
1863 pluginLoadPolicy = m_loaderClient->pluginLoadPolicy(*this, static_cast<PluginModuleLoadPolicy>(pluginLoadPolicy), pluginInformation.get(), unavailabilityDescription);
1865 UNUSED_PARAM(frameURLString);
1866 UNUSED_PARAM(pageURLString);
1867 UNUSED_PARAM(unavailabilityDescription);
1870 PluginProcessSandboxPolicy pluginProcessSandboxPolicy = PluginProcessSandboxPolicyNormal;
1871 switch (pluginLoadPolicy) {
1872 case PluginModuleLoadNormally:
1873 pluginProcessSandboxPolicy = PluginProcessSandboxPolicyNormal;
1875 case PluginModuleLoadUnsandboxed:
1876 pluginProcessSandboxPolicy = PluginProcessSandboxPolicyUnsandboxed;
1879 case PluginModuleBlockedForSecurity:
1880 case PluginModuleBlockedForCompatibility:
1881 pluginProcessToken = 0;
1885 pluginProcessToken = PluginProcessManager::singleton().pluginProcessToken(plugin, static_cast<PluginProcessType>(processType), pluginProcessSandboxPolicy);
1888 #endif // ENABLE(NETSCAPE_PLUGIN_API)
1890 #if ENABLE(TOUCH_EVENTS)
1892 bool WebPageProxy::shouldStartTrackingTouchEvents(const WebTouchEvent& touchStartEvent) const
1894 #if ENABLE(ASYNC_SCROLLING)
1895 for (auto& touchPoint : touchStartEvent.touchPoints()) {
1896 if (m_scrollingCoordinatorProxy->isPointInNonFastScrollableRegion(touchPoint.location()))
1902 UNUSED_PARAM(touchStartEvent);
1903 #endif // ENABLE(ASYNC_SCROLLING)
1909 #if ENABLE(MAC_GESTURE_EVENTS)
1910 void WebPageProxy::handleGestureEvent(const NativeWebGestureEvent& event)
1915 m_gestureEventQueue.append(event);
1916 // FIXME: Consider doing some coalescing here.
1917 m_process->responsivenessTimer().start();
1919 m_process->send(Messages::EventDispatcher::GestureEvent(m_pageID, event), 0);
1923 #if ENABLE(IOS_TOUCH_EVENTS)
1924 void WebPageProxy::handleTouchEventSynchronously(const NativeWebTouchEvent& event)
1929 if (event.type() == WebEvent::TouchStart) {
1930 m_isTrackingTouchEvents = shouldStartTrackingTouchEvents(event);
1931 m_layerTreeTransactionIdAtLastTouchStart = downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea()).lastCommittedLayerTreeTransactionID();
1934 if (!m_isTrackingTouchEvents)
1937 m_process->responsivenessTimer().start();
1938 bool handled = false;
1939 m_process->sendSync(Messages::WebPage::TouchEventSync(event), Messages::WebPage::TouchEventSync::Reply(handled), m_pageID);
1940 didReceiveEvent(event.type(), handled);
1941 m_pageClient.doneWithTouchEvent(event, handled);
1942 m_process->responsivenessTimer().stop();
1944 if (event.allTouchPointsAreReleased())
1945 m_isTrackingTouchEvents = false;
1948 void WebPageProxy::handleTouchEventAsynchronously(const NativeWebTouchEvent& event)
1953 if (!m_isTrackingTouchEvents)
1956 m_process->send(Messages::EventDispatcher::TouchEvent(m_pageID, event), 0);
1958 if (event.allTouchPointsAreReleased())
1959 m_isTrackingTouchEvents = false;
1962 #elif ENABLE(TOUCH_EVENTS)
1963 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
1968 if (event.type() == WebEvent::TouchStart)
1969 m_isTrackingTouchEvents = shouldStartTrackingTouchEvents(event);
1971 if (!m_isTrackingTouchEvents)
1974 // If the page is suspended, which should be the case during panning, pinching
1975 // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
1976 // we do not send any of the events to the page even if is has listeners.
1977 if (!m_isPageSuspended) {
1978 m_touchEventQueue.append(event);
1979 m_process->responsivenessTimer().start();
1980 m_process->send(Messages::WebPage::TouchEvent(event), m_pageID);
1982 if (m_touchEventQueue.isEmpty()) {
1983 bool isEventHandled = false;
1984 m_pageClient.doneWithTouchEvent(event, isEventHandled);
1986 // We attach the incoming events to the newest queued event so that all
1987 // the events are delivered in the correct order when the event is dequed.
1988 QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
1989 lastEvent.deferredTouchEvents.append(event);
1993 if (event.allTouchPointsAreReleased())
1994 m_isTrackingTouchEvents = false;
1996 #endif // ENABLE(TOUCH_EVENTS)
1998 void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
2003 m_process->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
2006 void WebPageProxy::centerSelectionInVisibleArea()
2011 m_process->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
2014 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID, API::Navigation* navigation)
2019 auto transaction = m_pageLoadState.transaction();
2021 if (action == PolicyIgnore)
2022 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2024 uint64_t downloadID = 0;
2025 if (action == PolicyDownload) {
2026 // Create a download proxy.
2027 // FIXME: We should ensure that the downloadRequest is never empty.
2028 const ResourceRequest& downloadRequest = m_decidePolicyForResponseRequest ? *m_decidePolicyForResponseRequest : ResourceRequest();
2029 DownloadProxy* download = m_process->processPool().createDownloadProxy(downloadRequest);
2030 downloadID = download->downloadID();
2031 handleDownloadRequest(download);
2034 // If we received a policy decision while in decidePolicyForResponse the decision will
2035 // be sent back to the web process by decidePolicyForResponse.
2036 if (m_inDecidePolicyForResponseSync) {
2037 m_syncMimeTypePolicyActionIsValid = true;
2038 m_syncMimeTypePolicyAction = action;
2039 m_syncMimeTypePolicyDownloadID = downloadID;
2043 // If we received a policy decision while in decidePolicyForNavigationAction the decision will
2044 // be sent back to the web process by decidePolicyForNavigationAction.
2045 if (m_inDecidePolicyForNavigationAction) {
2046 m_syncNavigationActionPolicyActionIsValid = true;
2047 m_syncNavigationActionPolicyAction = action;
2048 m_syncNavigationActionPolicyDownloadID = downloadID;
2052 m_process->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, navigation ? navigation->navigationID() : 0, downloadID), m_pageID);
2055 void WebPageProxy::setUserAgent(const String& userAgent)
2057 if (m_userAgent == userAgent)
2059 m_userAgent = userAgent;
2063 m_process->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
2066 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
2068 if (m_applicationNameForUserAgent == applicationName)
2071 m_applicationNameForUserAgent = applicationName;
2072 if (!m_customUserAgent.isEmpty())
2075 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
2078 void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
2080 if (m_customUserAgent == customUserAgent)
2083 m_customUserAgent = customUserAgent;
2085 if (m_customUserAgent.isEmpty()) {
2086 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
2090 setUserAgent(m_customUserAgent);
2093 void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
2095 if (!isValid() || !m_isPageSuspended)
2098 m_isPageSuspended = false;
2100 m_process->send(Messages::WebPage::ResumeActiveDOMObjectsAndAnimations(), m_pageID);
2103 void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
2105 if (!isValid() || m_isPageSuspended)
2108 m_isPageSuspended = true;
2110 m_process->send(Messages::WebPage::SuspendActiveDOMObjectsAndAnimations(), m_pageID);
2113 bool WebPageProxy::supportsTextEncoding() const
2115 // FIXME (118840): We should probably only support this for text documents, not all non-image documents.
2116 return m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
2119 void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
2121 if (m_customTextEncodingName == encodingName)
2123 m_customTextEncodingName = encodingName;
2127 m_process->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
2130 void WebPageProxy::terminateProcess()
2132 // requestTermination() is a no-op for launching processes, so we get into an inconsistent state by calling resetStateAfterProcessExited().
2133 // FIXME: A client can terminate the page at any time, so we should do something more meaningful than assert and fall apart in release builds.
2134 // See also <https://bugs.webkit.org/show_bug.cgi?id=136012>.
2135 ASSERT(m_process->state() != WebProcessProxy::State::Launching);
2137 // NOTE: This uses a check of m_isValid rather than calling isValid() since
2138 // we want this to run even for pages being closed or that already closed.
2142 m_process->requestTermination();
2143 resetStateAfterProcessExited();
2146 SessionState WebPageProxy::sessionState(const std::function<bool (WebBackForwardListItem&)>& filter) const
2148 SessionState sessionState;
2150 sessionState.backForwardListState = m_backForwardList->backForwardListState(filter);
2152 String provisionalURLString = m_pageLoadState.pendingAPIRequestURL();
2153 if (provisionalURLString.isEmpty())
2154 provisionalURLString = m_pageLoadState.provisionalURL();
2156 if (!provisionalURLString.isEmpty())
2157 sessionState.provisionalURL = URL(URL(), provisionalURLString);
2159 sessionState.renderTreeSize = renderTreeSize();
2160 return sessionState;
2163 RefPtr<API::Navigation> WebPageProxy::restoreFromSessionState(SessionState sessionState, bool navigate)
2165 m_sessionRestorationRenderTreeSize = 0;
2166 m_hitRenderTreeSizeThreshold = false;
2168 bool hasBackForwardList = !!sessionState.backForwardListState.currentIndex;
2170 if (hasBackForwardList) {
2171 m_backForwardList->restoreFromState(WTF::move(sessionState.backForwardListState));
2173 for (const auto& entry : m_backForwardList->entries())
2174 process().registerNewWebBackForwardListItem(entry.get());
2176 process().send(Messages::WebPage::RestoreSession(m_backForwardList->itemStates()), m_pageID);
2178 // The back / forward list was restored from a sessionState so we don't want to snapshot the current
2179 // page when navigating away. Suppress navigation snapshotting until the next load has committed.
2180 m_suppressNavigationSnapshotting = true;
2183 // FIXME: Navigating should be separate from state restoration.
2185 m_sessionRestorationRenderTreeSize = sessionState.renderTreeSize;
2186 if (!m_sessionRestorationRenderTreeSize)
2187 m_hitRenderTreeSizeThreshold = true; // If we didn't get data on renderTreeSize, just don't fire the milestone.
2189 if (!sessionState.provisionalURL.isNull())
2190 return loadRequest(sessionState.provisionalURL);
2192 if (hasBackForwardList) {
2193 // FIXME: Do we have to null check the back forward list item here?
2194 if (WebBackForwardListItem* item = m_backForwardList->currentItem())
2195 return goToBackForwardItem(item);
2202 bool WebPageProxy::supportsTextZoom() const
2204 // FIXME (118840): This should also return false for standalone media and plug-in documents.
2205 if (!m_mainFrame || m_mainFrame->isDisplayingStandaloneImageDocument())
2211 void WebPageProxy::setTextZoomFactor(double zoomFactor)
2216 if (m_textZoomFactor == zoomFactor)
2219 m_textZoomFactor = zoomFactor;
2220 m_process->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID);
2223 void WebPageProxy::setPageZoomFactor(double zoomFactor)
2228 if (m_pageZoomFactor == zoomFactor)
2231 m_pageZoomFactor = zoomFactor;
2232 m_process->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID);
2235 void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
2240 if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
2243 m_pageZoomFactor = pageZoomFactor;
2244 m_textZoomFactor = textZoomFactor;
2245 m_process->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID);
2248 double WebPageProxy::pageZoomFactor() const
2250 // Zoom factor for non-PDF pages persists across page loads. We maintain a separate member variable for PDF
2251 // zoom which ensures that we don't use the PDF zoom for a normal page.
2252 if (m_mainFramePluginHandlesPageScaleGesture)
2253 return m_pluginZoomFactor;
2254 return m_pageZoomFactor;
2257 double WebPageProxy::pageScaleFactor() const
2259 // PDF documents use zoom and scale factors to size themselves appropriately in the window. We store them
2260 // separately but decide which to return based on the main frame.
2261 if (m_mainFramePluginHandlesPageScaleGesture)
2262 return m_pluginScaleFactor;
2263 return m_pageScaleFactor;
2266 void WebPageProxy::scalePage(double scale, const IntPoint& origin)
2273 m_pageScaleFactor = scale;
2274 m_process->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
2277 void WebPageProxy::scalePageInViewCoordinates(double scale, const IntPoint& centerInViewCoordinates)
2284 m_pageScaleFactor = scale;
2285 m_process->send(Messages::WebPage::ScalePageInViewCoordinates(scale, centerInViewCoordinates), m_pageID);
2288 void WebPageProxy::scaleView(double scale)
2295 m_viewScaleFactor = scale;
2296 m_process->send(Messages::WebPage::ScaleView(scale), m_pageID);
2299 void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
2301 if (m_intrinsicDeviceScaleFactor == scaleFactor)
2304 m_intrinsicDeviceScaleFactor = scaleFactor;
2307 m_drawingArea->deviceScaleFactorDidChange();
2310 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
2315 m_process->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID);
2318 float WebPageProxy::deviceScaleFactor() const
2320 if (m_customDeviceScaleFactor)
2321 return m_customDeviceScaleFactor;
2322 return m_intrinsicDeviceScaleFactor;
2325 void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
2330 // FIXME: Remove this once we bump cairo requirements to support HiDPI.
2331 // https://bugs.webkit.org/show_bug.cgi?id=133378
2332 #if USE(CAIRO) && !HAVE(CAIRO_SURFACE_SET_DEVICE_SCALE)
2336 if (m_customDeviceScaleFactor == customScaleFactor)
2339 float oldScaleFactor = deviceScaleFactor();
2341 m_customDeviceScaleFactor = customScaleFactor;
2343 if (deviceScaleFactor() != oldScaleFactor)
2344 m_drawingArea->deviceScaleFactorDidChange();
2347 void WebPageProxy::setUseFixedLayout(bool fixed)
2352 // This check is fine as the value is initialized in the web
2353 // process as part of the creation parameters.
2354 if (fixed == m_useFixedLayout)
2357 m_useFixedLayout = fixed;
2359 m_fixedLayoutSize = IntSize();
2360 m_process->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
2363 void WebPageProxy::setFixedLayoutSize(const IntSize& size)
2368 if (size == m_fixedLayoutSize)
2371 m_fixedLayoutSize = size;
2372 m_process->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
2375 void WebPageProxy::listenForLayoutMilestones(WebCore::LayoutMilestones milestones)
2380 m_wantsSessionRestorationRenderTreeSizeThresholdEvent = milestones & WebCore::ReachedSessionRestorationRenderTreeSizeThreshold;
2382 m_process->send(Messages::WebPage::ListenForLayoutMilestones(milestones), m_pageID);
2385 void WebPageProxy::setSuppressScrollbarAnimations(bool suppressAnimations)
2390 if (suppressAnimations == m_suppressScrollbarAnimations)
2393 m_suppressScrollbarAnimations = suppressAnimations;
2394 m_process->send(Messages::WebPage::SetSuppressScrollbarAnimations(suppressAnimations), m_pageID);
2397 bool WebPageProxy::rubberBandsAtLeft() const
2399 return m_rubberBandsAtLeft;
2402 void WebPageProxy::setRubberBandsAtLeft(bool rubberBandsAtLeft)
2404 m_rubberBandsAtLeft = rubberBandsAtLeft;
2407 bool WebPageProxy::rubberBandsAtRight() const
2409 return m_rubberBandsAtRight;
2412 void WebPageProxy::setRubberBandsAtRight(bool rubberBandsAtRight)
2414 m_rubberBandsAtRight = rubberBandsAtRight;
2417 bool WebPageProxy::rubberBandsAtTop() const
2419 return m_rubberBandsAtTop;
2422 void WebPageProxy::setRubberBandsAtTop(bool rubberBandsAtTop)
2424 m_rubberBandsAtTop = rubberBandsAtTop;
2427 bool WebPageProxy::rubberBandsAtBottom() const
2429 return m_rubberBandsAtBottom;
2432 void WebPageProxy::setRubberBandsAtBottom(bool rubberBandsAtBottom)
2434 m_rubberBandsAtBottom = rubberBandsAtBottom;
2437 void WebPageProxy::setEnableVerticalRubberBanding(bool enableVerticalRubberBanding)
2439 if (enableVerticalRubberBanding == m_enableVerticalRubberBanding)
2442 m_enableVerticalRubberBanding = enableVerticalRubberBanding;
2446 m_process->send(Messages::WebPage::SetEnableVerticalRubberBanding(enableVerticalRubberBanding), m_pageID);
2449 bool WebPageProxy::verticalRubberBandingIsEnabled() const
2451 return m_enableVerticalRubberBanding;
2454 void WebPageProxy::setEnableHorizontalRubberBanding(bool enableHorizontalRubberBanding)
2456 if (enableHorizontalRubberBanding == m_enableHorizontalRubberBanding)
2459 m_enableHorizontalRubberBanding = enableHorizontalRubberBanding;
2463 m_process->send(Messages::WebPage::SetEnableHorizontalRubberBanding(enableHorizontalRubberBanding), m_pageID);
2466 bool WebPageProxy::horizontalRubberBandingIsEnabled() const
2468 return m_enableHorizontalRubberBanding;
2471 void WebPageProxy::setBackgroundExtendsBeyondPage(bool backgroundExtendsBeyondPage)
2473 if (backgroundExtendsBeyondPage == m_backgroundExtendsBeyondPage)
2476 m_backgroundExtendsBeyondPage = backgroundExtendsBeyondPage;
2480 m_process->send(Messages::WebPage::SetBackgroundExtendsBeyondPage(backgroundExtendsBeyondPage), m_pageID);
2483 bool WebPageProxy::backgroundExtendsBeyondPage() const
2485 return m_backgroundExtendsBeyondPage;
2488 void WebPageProxy::setPaginationMode(WebCore::Pagination::Mode mode)
2490 if (mode == m_paginationMode)
2493 m_paginationMode = mode;
2497 m_process->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
2500 void WebPageProxy::setPaginationBehavesLikeColumns(bool behavesLikeColumns)
2502 if (behavesLikeColumns == m_paginationBehavesLikeColumns)
2505 m_paginationBehavesLikeColumns = behavesLikeColumns;
2509 m_process->send(Messages::WebPage::SetPaginationBehavesLikeColumns(behavesLikeColumns), m_pageID);
2512 void WebPageProxy::setPageLength(double pageLength)
2514 if (pageLength == m_pageLength)
2517 m_pageLength = pageLength;
2521 m_process->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
2524 void WebPageProxy::setGapBetweenPages(double gap)
2526 if (gap == m_gapBetweenPages)
2529 m_gapBetweenPages = gap;
2533 m_process->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
2536 void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
2538 m_pageScaleFactor = scaleFactor;
2541 void WebPageProxy::pluginScaleFactorDidChange(double pluginScaleFactor)
2543 m_pluginScaleFactor = pluginScaleFactor;
2546 void WebPageProxy::pluginZoomFactorDidChange(double pluginZoomFactor)
2548 m_pluginZoomFactor = pluginZoomFactor;
2551 void WebPageProxy::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
2553 if (string.isEmpty()) {
2554 didFindStringMatches(string, Vector<Vector<WebCore::IntRect>> (), 0);
2558 m_process->send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount), m_pageID);
2561 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
2563 m_process->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
2566 void WebPageProxy::getImageForFindMatch(int32_t matchIndex)
2568 m_process->send(Messages::WebPage::GetImageForFindMatch(matchIndex), m_pageID);
2571 void WebPageProxy::selectFindMatch(int32_t matchIndex)
2573 m_process->send(Messages::WebPage::SelectFindMatch(matchIndex), m_pageID);
2576 void WebPageProxy::hideFindUI()
2578 m_process->send(Messages::WebPage::HideFindUI(), m_pageID);
2581 void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
2586 m_process->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
2589 void WebPageProxy::runJavaScriptInMainFrame(const String& script, std::function<void (API::SerializedScriptValue*, bool hadException, const ExceptionDetails&, CallbackBase::Error)> callbackFunction)
2592 callbackFunction(nullptr, false, { }, CallbackBase::Error::Unknown);
2596 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2597 m_process->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
2600 void WebPageProxy::getRenderTreeExternalRepresentation(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2603 callbackFunction(String(), CallbackBase::Error::Unknown);
2607 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2608 m_process->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
2611 void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2614 callbackFunction(String(), CallbackBase::Error::Unknown);
2618 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2619 m_loadDependentStringCallbackIDs.add(callbackID);
2620 m_process->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
2623 void WebPageProxy::getContentsAsString(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2626 callbackFunction(String(), CallbackBase::Error::Unknown);
2630 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2631 m_loadDependentStringCallbackIDs.add(callbackID);
2632 m_process->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
2635 void WebPageProxy::getBytecodeProfile(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2638 callbackFunction(String(), CallbackBase::Error::Unknown);
2642 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2643 m_loadDependentStringCallbackIDs.add(callbackID);
2644 m_process->send(Messages::WebPage::GetBytecodeProfile(callbackID), m_pageID);
2648 void WebPageProxy::getContentsAsMHTMLData(std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2651 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2655 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2656 m_process->send(Messages::WebPage::GetContentsAsMHTMLData(callbackID), m_pageID);
2660 void WebPageProxy::getSelectionOrContentsAsString(std::function<void (const String&, CallbackBase::Error)> callbackFunction)
2663 callbackFunction(String(), CallbackBase::Error::Unknown);
2667 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2668 m_process->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
2671 void WebPageProxy::getSelectionAsWebArchiveData(std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2674 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2678 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2679 m_process->send(Messages::WebPage::GetSelectionAsWebArchiveData(callbackID), m_pageID);
2682 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2684 if (!isValid() || !frame) {
2685 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2689 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2690 m_process->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
2693 void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, API::URL* resourceURL, std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2696 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2700 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2701 m_process->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID);
2704 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, std::function<void (API::Data*, CallbackBase::Error)> callbackFunction)
2707 callbackFunction(nullptr, CallbackBase::Error::Unknown);
2711 uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
2712 m_process->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
2715 void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
2717 RefPtr<VoidCallback> callback = prpCallback;
2719 // FIXME: If the page is invalid we should not call the callback. It'd be better to just return false from forceRepaint.
2720 callback->invalidate(CallbackBase::Error::OwnerWasInvalidated);
2724 uint64_t callbackID = callback->callbackID();
2725 m_callbacks.put(callback);
2726 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
2727 m_process->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID);
2730 void WebPageProxy::preferencesDidChange()
2735 #if ENABLE(INSPECTOR_SERVER)
2736 if (m_preferences->developerExtrasEnabled())
2737 inspector()->enableRemoteInspection();
2740 updateProccessSuppressionState();
2742 m_pageClient.preferencesDidChange();
2744 // FIXME: It probably makes more sense to send individual preference changes.
2745 // However, WebKitTestRunner depends on getting a preference change notification
2746 // even if nothing changed in UI process, so that overrides get removed.
2748 // Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
2749 m_process->send(Messages::WebPage::PreferencesDidChange(preferencesStore()), m_pageID, m_isPerformingDOMPrintOperation ? IPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
2752 void WebPageProxy::didCreateMainFrame(uint64_t frameID)
2754 PageClientProtector protector(m_pageClient);
2756 MESSAGE_CHECK(!m_mainFrame);
2757 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2759 m_mainFrame = WebFrameProxy::create(this, frameID);
2761 // Add the frame to the process wide map.
2762 m_process->frameCreated(frameID, m_mainFrame.get());
2765 void WebPageProxy::didCreateSubframe(uint64_t frameID)
2767 PageClientProtector protector(m_pageClient);
2769 MESSAGE_CHECK(m_mainFrame);
2770 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2772 RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
2774 // Add the frame to the process wide map.
2775 m_process->frameCreated(frameID, subFrame.get());
2778 double WebPageProxy::estimatedProgress() const
2780 return m_pageLoadState.estimatedProgress();
2783 void WebPageProxy::didStartProgress()
2785 PageClientProtector protector(m_pageClient);
2787 auto transaction = m_pageLoadState.transaction();
2788 m_pageLoadState.didStartProgress(transaction);
2790 m_pageLoadState.commitChanges();
2791 m_loaderClient->didStartProgress(*this);
2794 void WebPageProxy::didChangeProgress(double value)
2796 PageClientProtector protector(m_pageClient);
2798 auto transaction = m_pageLoadState.transaction();
2799 m_pageLoadState.didChangeProgress(transaction, value);
2801 m_pageLoadState.commitChanges();
2802 m_loaderClient->didChangeProgress(*this);
2805 void WebPageProxy::didFinishProgress()
2807 PageClientProtector protector(m_pageClient);
2809 auto transaction = m_pageLoadState.transaction();
2810 m_pageLoadState.didFinishProgress(transaction);
2812 m_pageLoadState.commitChanges();
2813 m_loaderClient->didFinishProgress(*this);
2816 void WebPageProxy::setNetworkRequestsInProgress(bool networkRequestsInProgress)
2818 auto transaction = m_pageLoadState.transaction();
2819 m_pageLoadState.setNetworkRequestsInProgress(transaction, networkRequestsInProgress);
2822 void WebPageProxy::didDestroyNavigation(uint64_t navigationID)
2824 PageClientProtector protector(m_pageClient);
2826 // FIXME: Message check the navigationID.
2827 m_navigationState->didDestroyNavigation(navigationID);
2830 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const String& unreachableURL, const UserData& userData)
2832 PageClientProtector protector(m_pageClient);
2834 auto transaction = m_pageLoadState.transaction();
2836 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2838 WebFrameProxy* frame = m_process->webFrame(frameID);
2839 MESSAGE_CHECK(frame);
2840 MESSAGE_CHECK_URL(url);
2842 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
2843 RefPtr<API::Navigation> navigation;
2844 if (frame->isMainFrame() && navigationID)
2845 navigation = &navigationState().navigation(navigationID);
2847 if (frame->isMainFrame())
2848 m_pageLoadState.didStartProvisionalLoad(transaction, url, unreachableURL);
2850 frame->setUnreachableURL(unreachableURL);
2851 frame->didStartProvisionalLoad(url);
2853 m_pageLoadState.commitChanges();
2854 if (m_navigationClient) {
2855 if (frame->isMainFrame())
2856 m_navigationClient->didStartProvisionalNavigation(*this, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
2858 m_loaderClient->didStartProvisionalLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
2861 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const UserData& userData)
2863 PageClientProtector protector(m_pageClient);
2865 WebFrameProxy* frame = m_process->webFrame(frameID);
2866 MESSAGE_CHECK(frame);
2867 MESSAGE_CHECK_URL(url);
2869 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
2870 RefPtr<API::Navigation> navigation;
2871 if (frame->isMainFrame() && navigationID)
2872 navigation = &navigationState().navigation(navigationID);
2874 auto transaction = m_pageLoadState.transaction();
2876 if (frame->isMainFrame())
2877 m_pageLoadState.didReceiveServerRedirectForProvisionalLoad(transaction, url);
2879 frame->didReceiveServerRedirectForProvisionalLoad(url);
2881 m_pageLoadState.commitChanges();
2882 if (m_navigationClient) {
2883 if (frame->isMainFrame())
2884 m_navigationClient->didReceiveServerRedirectForProvisionalNavigation(*this, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
2886 m_loaderClient->didReceiveServerRedirectForProvisionalLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
2889 void WebPageProxy::didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t, const String& url)
2891 PageClientProtector protector(m_pageClient);
2893 WebFrameProxy* frame = m_process->webFrame(frameID);
2894 MESSAGE_CHECK(frame);
2895 MESSAGE_CHECK(frame->frameLoadState().state() == FrameLoadState::State::Provisional);
2896 MESSAGE_CHECK_URL(url);
2898 auto transaction = m_pageLoadState.transaction();
2900 // Internally, we handle this the same way we handle a server redirect. There are no client callbacks
2901 // for this, but if this is the main frame, clients may observe a change to the page's URL.
2902 if (frame->isMainFrame())
2903 m_pageLoadState.didReceiveServerRedirectForProvisionalLoad(transaction, url);
2905 frame->didReceiveServerRedirectForProvisionalLoad(url);
2908 void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const ResourceError& error, const UserData& userData)
2910 PageClientProtector protector(m_pageClient);
2912 WebFrameProxy* frame = m_process->webFrame(frameID);
2913 MESSAGE_CHECK(frame);
2915 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
2916 RefPtr<API::Navigation> navigation;
2917 if (frame->isMainFrame() && navigationID)
2918 navigation = navigationState().takeNavigation(navigationID);
2920 auto transaction = m_pageLoadState.transaction();
2922 if (frame->isMainFrame())
2923 m_pageLoadState.didFailProvisionalLoad(transaction);
2925 frame->didFailProvisionalLoad();
2927 m_pageLoadState.commitChanges();
2929 ASSERT(!m_failingProvisionalLoadURL);
2930 m_failingProvisionalLoadURL = provisionalURL;
2932 if (m_navigationClient) {
2933 if (frame->isMainFrame())
2934 m_navigationClient->didFailProvisionalNavigationWithError(*this, *frame, navigation.get(), error, m_process->transformHandlesToObjects(userData.object()).get());
2936 // FIXME: Get the main frame's current navigation.
2937 m_navigationClient->didFailProvisionalLoadInSubframeWithError(*this, *frame, frameSecurityOrigin, nullptr, error, m_process->transformHandlesToObjects(userData.object()).get());
2940 m_loaderClient->didFailProvisionalLoadWithErrorForFrame(*this, *frame, navigation.get(), error, m_process->transformHandlesToObjects(userData.object()).get());
2942 m_failingProvisionalLoadURL = { };
2945 void WebPageProxy::clearLoadDependentCallbacks()
2947 Vector<uint64_t> callbackIDsCopy;
2948 copyToVector(m_loadDependentStringCallbackIDs, callbackIDsCopy);
2949 m_loadDependentStringCallbackIDs.clear();
2951 for (size_t i = 0; i < callbackIDsCopy.size(); ++i) {
2952 auto callback = m_callbacks.take<StringCallback>(callbackIDsCopy[i]);
2954 callback->invalidate();
2958 void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, bool pluginHandlesPageScaleGesture, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo& certificateInfo, bool containsPluginDocument, const UserData& userData)
2960 PageClientProtector protector(m_pageClient);
2962 WebFrameProxy* frame = m_process->webFrame(frameID);
2963 MESSAGE_CHECK(frame);
2965 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
2966 RefPtr<API::Navigation> navigation;
2967 if (frame->isMainFrame() && navigationID)
2968 navigation = &navigationState().navigation(navigationID);
2971 if (frame->isMainFrame()) {
2972 m_hasReceivedLayerTreeTransactionAfterDidCommitLoad = false;
2973 m_firstLayerTreeTransactionIdAfterDidCommitLoad = downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea()).nextLayerTreeTransactionID();
2977 auto transaction = m_pageLoadState.transaction();
2978 bool markPageInsecure = m_treatsSHA1CertificatesAsInsecure && certificateInfo.containsNonRootSHA1SignedCertificate();
2979 Ref<WebCertificateInfo> webCertificateInfo = WebCertificateInfo::create(certificateInfo);
2980 if (frame->isMainFrame()) {
2981 m_pageLoadState.didCommitLoad(transaction, webCertificateInfo, markPageInsecure);
2982 m_suppressNavigationSnapshotting = false;
2983 } else if (markPageInsecure)
2984 m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
2987 // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
2988 // FIXME: A load going on in one frame shouldn't affect text editing in other frames on the page.
2989 m_pageClient.resetSecureInputState();
2990 m_pageClient.dismissContentRelativeChildWindows();
2993 clearLoadDependentCallbacks();
2995 frame->didCommitLoad(mimeType, webCertificateInfo, containsPluginDocument);
2997 if (frame->isMainFrame()) {
2998 m_mainFrameHasCustomContentProvider = frameHasCustomContentProvider;
3000 if (m_mainFrameHasCustomContentProvider) {
3001 // Always assume that the main frame is pinned here, since the custom representation view will handle
3002 // any wheel events and dispatch them to the WKView when necessary.
3003 m_mainFrameIsPinnedToLeftSide = true;
3004 m_mainFrameIsPinnedToRightSide = true;
3005 m_mainFrameIsPinnedToTopSide = true;
3006 m_mainFrameIsPinnedToBottomSide = true;
3008 m_uiClient->pinnedStateDidChange(*this);
3010 m_pageClient.didCommitLoadForMainFrame(mimeType, frameHasCustomContentProvider);
3013 // Even if WebPage has the default pageScaleFactor (and therefore doesn't reset it),
3014 // WebPageProxy's cache of the value can get out of sync (e.g. in the case where a
3015 // plugin is handling page scaling itself) so we should reset it to the default
3016 // for standard main frame loads.
3017 if (frame->isMainFrame()) {
3018 m_mainFramePluginHandlesPageScaleGesture = pluginHandlesPageScaleGesture;
3020 if (static_cast<FrameLoadType>(opaqueFrameLoadType) == FrameLoadType::Standard) {
3021 m_pageScaleFactor = 1;
3022 m_pluginScaleFactor = 1;
3026 m_pageLoadState.commitChanges();
3027 if (m_navigationClient) {
3028 if (frame->isMainFrame())
3029 m_navigationClient->didCommitNavigation(*this, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
3031 m_loaderClient->didCommitLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
3034 void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData& userData)
3036 PageClientProtector protector(m_pageClient);
3038 WebFrameProxy* frame = m_process->webFrame(frameID);
3039 MESSAGE_CHECK(frame);
3041 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
3042 RefPtr<API::Navigation> navigation;
3043 if (frame->isMainFrame() && navigationID)
3044 navigation = &navigationState().navigation(navigationID);
3046 if (m_navigationClient) {
3047 if (frame->isMainFrame())
3048 m_navigationClient->didFinishDocumentLoad(*this, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
3050 m_loaderClient->didFinishDocumentLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
3053 void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, const UserData& userData)
3055 PageClientProtector protector(m_pageClient);
3057 WebFrameProxy* frame = m_process->webFrame(frameID);
3058 MESSAGE_CHECK(frame);
3060 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
3061 RefPtr<API::Navigation> navigation;
3062 if (frame->isMainFrame() && navigationID)
3063 navigation = &navigationState().navigation(navigationID);
3065 auto transaction = m_pageLoadState.transaction();
3067 bool isMainFrame = frame->isMainFrame();
3069 m_pageLoadState.didFinishLoad(transaction);
3071 frame->didFinishLoad();
3073 m_pageLoadState.commitChanges();
3074 if (m_navigationClient) {
3076 m_navigationClient->didFinishNavigation(*this, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
3078 m_loaderClient->didFinishLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
3081 m_pageClient.didFinishLoadForMainFrame();
3084 void WebPageProxy::didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError& error, const UserData& userData)
3086 PageClientProtector protector(m_pageClient);
3088 WebFrameProxy* frame = m_process->webFrame(frameID);
3089 MESSAGE_CHECK(frame);
3091 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
3092 RefPtr<API::Navigation> navigation;
3093 if (frame->isMainFrame() && navigationID)
3094 navigation = &navigationState().navigation(navigationID);
3096 clearLoadDependentCallbacks();
3098 auto transaction = m_pageLoadState.transaction();
3100 bool isMainFrame = frame->isMainFrame();
3103 m_pageLoadState.didFailLoad(transaction);
3105 frame->didFailLoad();
3107 m_pageLoadState.commitChanges();
3108 if (m_navigationClient) {
3109 if (frame->isMainFrame())
3110 m_navigationClient->didFailNavigationWithError(*this, *frame, navigation.get(), error, m_process->transformHandlesToObjects(userData.object()).get());
3112 m_loaderClient->didFailLoadWithErrorForFrame(*this, *frame, navigation.get(), error, m_process->transformHandlesToObjects(userData.object()).get());
3115 m_pageClient.didFailLoadForMainFrame();
3118 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t opaqueSameDocumentNavigationType, const String& url, const UserData& userData)
3120 PageClientProtector protector(m_pageClient);
3122 WebFrameProxy* frame = m_process->webFrame(frameID);
3123 MESSAGE_CHECK(frame);
3124 MESSAGE_CHECK_URL(url);
3126 // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the page cache.
3127 RefPtr<API::Navigation> navigation;
3128 if (frame->isMainFrame() && navigationID)
3129 navigation = &navigationState().navigation(navigationID);
3131 auto transaction = m_pageLoadState.transaction();
3133 bool isMainFrame = frame->isMainFrame();
3135 m_pageLoadState.didSameDocumentNavigation(transaction, url);
3137 m_pageLoadState.clearPendingAPIRequestURL(transaction);
3138 frame->didSameDocumentNavigation(url);
3140 m_pageLoadState.commitChanges();
3142 SameDocumentNavigationType navigationType = static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType);
3143 if (m_navigationClient) {
3145 m_navigationClient->didSameDocumentNavigation(*this, navigation.get(), navigationType, m_process->transformHandlesToObjects(userData.object()).get());
3147 m_loaderClient->didSameDocumentNavigationForFrame(*this, *frame, navigation.get(), navigationType, m_process->transformHandlesToObjects(userData.object()).get());
3150 m_pageClient.didSameDocumentNavigationForMainFrame(navigationType);
3153 void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, const UserData& userData)
3155 PageClientProtector protector(m_pageClient);
3157 WebFrameProxy* frame = m_process->webFrame(frameID);
3158 MESSAGE_CHECK(frame);
3160 auto transaction = m_pageLoadState.transaction();
3162 if (frame->isMainFrame())
3163 m_pageLoadState.setTitle(transaction, title);
3165 frame->didChangeTitle(title);
3167 m_pageLoadState.commitChanges();
3168 m_loaderClient->didReceiveTitleForFrame(*this, title, *frame, m_process->transformHandlesToObjects(userData.object()).get());
3171 void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, const UserData& userData)
3173 PageClientProtector protector(m_pageClient);
3175 WebFrameProxy* frame = m_process->webFrame(frameID);
3176 MESSAGE_CHECK(frame);
3178 m_loaderClient->didFirstLayoutForFrame(*this, *frame, m_process->transformHandlesToObjects(userData.object()).get());
3181 void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, const UserData& userData)
3183 PageClientProtector protector(m_pageClient);
3185 WebFrameProxy* frame = m_process->webFrame(frameID);
3186 MESSAGE_CHECK(frame);
3188 m_loaderClient->didFirstVisuallyNonEmptyLayoutForFrame(*this, *frame, m_process->transformHandlesToObjects(userData.object()).get());
3190 if (frame->isMainFrame())
3191 m_pageClient.didFirstVisuallyNonEmptyLayoutForMainFrame();
3194 void WebPageProxy::didLayoutForCustomContentProvider()
3196 didLayout(DidFirstLayout | DidFirstVisuallyNonEmptyLayout | DidHitRelevantRepaintedObjectsAreaThreshold);
3199 void WebPageProxy::didLayout(uint32_t layoutMilestones)
3201 PageClientProtector protector(m_pageClient);
3203 if (m_navigationClient)
3204 m_navigationClient->renderingProgressDidChange(*this, static_cast<LayoutMilestones>(layoutMilestones));
3206 m_loaderClient->didLayout(*this, static_cast<LayoutMilestones>(layoutMilestones));
3209 void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, const UserData& userData)
3211 PageClientProtector protector(m_pageClient);
3213 WebFrameProxy* frame = m_process->webFrame(frameID);
3214 MESSAGE_CHECK(frame);
3216 auto transaction = m_pageLoadState.transaction();
3217 m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
3219 m_pageLoadState.commitChanges();
3220 m_loaderClient->didDisplayInsecureContentForFrame(*this, *frame, m_process->transformHandlesToObjects(userData.object()).get());
3223 void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, const UserData& userData)
3225 PageClientProtector protector(m_pageClient);
3227 WebFrameProxy* frame = m_process->webFrame(frameID);
3228 MESSAGE_CHECK(frame);
3230 auto transaction = m_pageLoadState.transaction();
3231 m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
3233 m_pageLoadState.commitChanges();
3234 m_loaderClient->didRunInsecureContentForFrame(*this, *frame, m_process->transformHandlesToObjects(userData.object()).get());
3237 void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, const UserData& userData)
3239 PageClientProtector protector(m_pageClient);
3241 WebFrameProxy* frame = m_process->webFrame(frameID);
3242 MESSAGE_CHECK(frame);
3244 m_loaderClient->didDetectXSSForFrame(*this, *frame, m_process->transformHandlesToObjects(userData.object()).get());
3247 void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
3249 PageClientProtector protector(m_pageClient);
3251 WebFrameProxy* frame = m_process->webFrame(frameID);
3252 MESSAGE_CHECK(frame);
3254 frame->setIsFrameSet(value);
3255 if (frame->isMainFrame())
3256 m_frameSetLargestFrame = value ? m_mainFrame : 0;
3259 void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const NavigationActionData& navigationActionData, uint64_t originatingFrameID, const SecurityOriginData& originatingFrameSecurityOrigin, const WebCore::ResourceRequest& originalRequest, const ResourceRequest& request, uint64_t listenerID, const UserData& userData, bool& receivedPolicyAction, uint64_t& newNavigationID, uint64_t& policyAction, uint64_t& downloadID)
3261 PageClientProtector protector(m_pageClient);
3263 auto transaction = m_pageLoadState.transaction();
3265 if (request.url() != m_pageLoadState.pendingAPIRequestURL())
3266 m_pageLoadState.clearPendingAPIRequestURL(transaction);
3268 WebFrameProxy* frame = m_process->webFrame(frameID);
3269 MESSAGE_CHECK(frame);
3270 MESSAGE_CHECK_URL(request.url());
3271 MESSAGE_CHECK_URL(originalRequest.url());
3273 WebFrameProxy* originatingFrame = m_process->webFrame(originatingFrameID);
3275 Ref<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
3276 if (!navigationID && frame->isMainFrame()) {
3277 auto navigation = m_navigationState->createLoadRequestNavigation(request);
3278 newNavigationID = navigation->navigationID();
3279 listener->setNavigation(WTF::move(navigation));
3282 #if ENABLE(CONTENT_FILTERING)
3283 if (frame->didHandleContentFilterUnblockNavigation(request)) {
3284 receivedPolicyAction = true;
3285 policyAction = PolicyIgnore;
3290 ASSERT(!m_inDecidePolicyForNavigationAction);
3292 m_inDecidePolicyForNavigationAction = true;
3293 m_syncNavigationActionPolicyActionIsValid = false;
3295 if (m_navigationClient) {
3296 RefPtr<API::FrameInfo> destinationFrameInfo;
3297 RefPtr<API::FrameInfo> sourceFrameInfo;
3300 destinationFrameInfo = API::FrameInfo::create(*frame, frameSecurityOrigin.securityOrigin());
3302 if (originatingFrame == frame)
3303 sourceFrameInfo = destinationFrameInfo;
3304 else if (originatingFrame)
3305 sourceFrameInfo = API::FrameInfo::create(*originatingFrame, originatingFrameSecurityOrigin.securityOrigin());
3307 bool shouldOpenAppLinks = !m_shouldSuppressAppLinksInNextNavigationPolicyDecision && (!destinationFrameInfo || destinationFrameInfo->isMainFrame()) && !hostsAreEqual(URL(ParsedURLString, m_mainFrame->url()), request.url());
3309 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.get(), destinationFrameInfo.get(), request, originalRequest.url(), shouldOpenAppLinks);
3311 m_navigationClient->decidePolicyForNavigationAction(*this, navigationAction.get(), WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get());
3313 m_policyClient->decidePolicyForNavigationAction(*this, frame, navigationActionData, originatingFrame, originalRequest, request, WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get());
3315 m_shouldSuppressAppLinksInNextNavigationPolicyDecision = false;
3316 m_inDecidePolicyForNavigationAction = false;
3318 // Check if we received a policy decision already. If we did, we can just pass it back.
3319 receivedPolicyAction = m_syncNavigationActionPolicyActionIsValid;
3320 if (m_syncNavigationActionPolicyActionIsValid) {
3321 policyAction = m_syncNavigationActionPolicyAction;
3322 downloadID = m_syncNavigationActionPolicyDownloadID;
3326 void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, const NavigationActionData& navigationActionData, const ResourceRequest& request, const String& frameName, uint64_t listenerID, const UserData& userData)
3328 PageClientProtector protector(m_pageClient);
3330 WebFrameProxy* frame = m_process->webFrame(frameID);
3331 MESSAGE_CHECK(frame);
3332 MESSAGE_CHECK_URL(request.url());
3334 Ref<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
3336 if (m_navigationClient) {
3337 RefPtr<API::FrameInfo> sourceFrameInfo;
3339 sourceFrameInfo = API::FrameInfo::create(*frame, frameSecurityOrigin.securityOrigin());
3341 bool shouldOpenAppLinks = !hostsAreEqual(URL(ParsedURLString, m_mainFrame->url()), request.url());
3342 auto navigationAction = API::NavigationAction::create(navigationActionData, sourceFrameInfo.get(), nullptr, request, request.url(), shouldOpenAppLinks);
3344 m_navigationClient->decidePolicyForNavigationAction(*this, navigationAction.get(), WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get());
3347 m_policyClient->decidePolicyForNewWindowAction(*this, *frame, navigationActionData, request, frameName, WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get());
3350 void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, uint64_t listenerID, const UserData& userData)
3352 PageClientProtector protector(m_pageClient);
3354 WebFrameProxy* frame = m_process->webFrame(frameID);
3355 MESSAGE_CHECK(frame);
3356 MESSAGE_CHECK_URL(request.url());
3357 MESSAGE_CHECK_URL(response.url());
3359 Ref<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
3361 if (m_navigationClient) {
3362 auto navigationResponse = API::NavigationResponse::create(API::FrameInfo::create(*frame, frameSecurityOrigin.securityOrigin()).get(), request, response, canShowMIMEType);
3363 m_navigationClient->decidePolicyForNavigationResponse(*this, navigationResponse.get(), WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get());
3365 m_policyClient->decidePolicyForResponse(*this, *frame, response, request, canShowMIMEType, WTF::move(listener), m_process->transformHandlesToObjects(userData.object()).get());
3368 void WebPageProxy::decidePolicyForResponseSync(uint64_t frameID, const SecurityOriginData& frameSecurityOrigin, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, uint64_t listenerID, const UserData& userData, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
3370 PageClientProtector protector(m_pageClient);
3372 ASSERT(!m_inDecidePolicyForResponseSync);
3374 m_inDecidePolicyForResponseSync = true;
3375 m_decidePolicyForResponseRequest = &request;
3376 m_syncMimeTypePolicyActionIsValid = false;
3378 decidePolicyForResponse(frameID, frameSecurityOrigin, response, request, canShowMIMEType, listenerID, userData);
3380 m_inDecidePolicyForResponseSync = false;
3381 m_decidePolicyForResponseRequest = 0;
3383 // Check if we received a policy decision already. If we did, we can just pass it back.
3384 receivedPolicyAction = m_syncMimeTypePolicyActionIsValid;
3385 if (m_syncMimeTypePolicyActionIsValid) {
3386 policyAction = m_syncMimeTypePolicyAction;
3387 downloadID = m_syncMimeTypePolicyDownloadID;
3391 void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError& error, const UserData& userData)
3393 PageClientProtector protector(m_pageClient);
3395 WebFrameProxy* frame = m_process->webFrame(frameID);
3396 MESSAGE_CHECK(frame);
3398 m_policyClient->unableToImplementPolicy(*this, *frame, error, m_process->transformHandlesToObjects(userData.object()).get());
3403 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, const UserData& userData)
3405 WebFrameProxy* frame = m_process->webFrame(frameID);
3406 MESSAGE_CHECK(frame);
3408 WebFrameProxy* sourceFrame = m_process->webFrame(sourceFrameID);
3409 MESSAGE_CHECK(sourceFrame);
3411 Ref<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
3412 m_formClient->willSubmitForm(*this, *frame, *sourceFrame, textFieldValues, m_process->transformHandlesToObjects(userData.object()).get(), listener.get());
3415 void WebPageProxy::didNavigateWithNavigationData(const WebNavigationDataStore& store, uint64_t frameID)
3417 PageClientProtector protector(m_pageClient);
3419 WebFrameProxy* frame = m_process->webFrame(frameID);
3420 MESSAGE_CHECK(frame);
3421 MESSAGE_CHECK(frame->page() == this);
3423 if (m_historyClient) {
3424 if (frame->isMainFrame())
3425 m_historyClient->didNavigateWithNavigationData(*this, store);
3427 m_loaderClient->didNavigateWithNavigationData(*this, store, *frame);
3428 process().processPool().historyClient().didNavigateWithNavigationData(process().processPool(), *this, store, *frame);
3431 void WebPageProxy::didPerformClientRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
3433 PageClientProtector protector(m_pageClient);
3435 if (sourceURLString.isEmpty() || destinationURLString.isEmpty())
3438 WebFrameProxy* frame = m_process->webFrame(frameID);
3439 MESSAGE_CHECK(frame);
3440 MESSAGE_CHECK(frame->page() == this);
3442 MESSAGE_CHECK_URL(sourceURLString);
3443 MESSAGE_CHECK_URL(destinationURLString);
3445 if (m_historyClient) {
3446 if (frame->isMainFrame())
3447 m_historyClient->didPerformClientRedirect(*this, sourceURLString, destinationURLString);
3449 m_loaderClient->didPerformClientRedirect(*this, sourceURLString, destinationURLString, *frame);
3450 process().processPool().historyClient().didPerformClientRedirect(process().processPool(), *this, sourceURLString, destinationURLString, *frame);
3453 void WebPageProxy::didPerformServerRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
3455 PageClientProtector protector(m_pageClient);
3457 if (sourceURLString.isEmpty() || destinationURLString.isEmpty())
3460 WebFrameProxy* frame = m_process->webFrame(frameID);
3461 MESSAGE_CHECK(frame);
3462 MESSAGE_CHECK(frame->page() == this);
3464 MESSAGE_CHECK_URL(sourceURLString);
3465 MESSAGE_CHECK_URL(destinationURLString);
3467 if (m_historyClient) {
3468 if (frame->isMainFrame())
3469 m_historyClient->didPerformServerRedirect(*this, sourceURLString, destinationURLString);
3471 m_loaderClient->didPerformServerRedirect(*this, sourceURLString, destinationURLString, *frame);
3472 process().processPool().historyClient().didPerformServerRedirect(process().processPool(), *this, sourceURLString, destinationURLString, *frame);
3475 void WebPageProxy::didUpdateHistoryTitle(const String& title, const String& url, uint64_t frameID)
3477 PageClientProtector protector(m_pageClient);
3479 WebFrameProxy* frame = m_process->webFrame(frameID);
3480 MESSAGE_CHECK(frame);
3481 MESSAGE_CHECK(frame->page() == this);
3483 MESSAGE_CHECK_URL(url);
3485 if (m_historyClient) {
3486 if (frame->isMainFrame())
3487 m_historyClient->didUpdateHistoryTitle(*this, title, url);
3489 m_loaderClient->didUpdateHistoryTitle(*this, title, url, *frame);
3490 process().processPool().historyClient().didUpdateHistoryTitle(process().processPool(), *this, title, url, *frame);
3495 void WebPageProxy::createNewPage(uint64_t frameID, const SecurityOriginData& securityOriginData, const ResourceRequest& request, const WindowFeatures& windowFeatures, const NavigationActionData& navigationActionData, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
3497 WebFrameProxy* frame = m_process->webFrame(frameID);
3498 MESSAGE_CHECK(frame);
3500 auto mainFrameURL = m_mainFrame->url();
3502 RefPtr<WebPageProxy> newPage = m_uiClient->createNewPage(this, frame, securityOriginData, request, windowFeatures, navigationActionData);
3508 newPageID = newPage->pageID();
3509 newPageParameters = newPage->creationParameters();
3511 WebsiteDataStore::cloneSessionData(*this, *newPage);
3512 newPage->m_shouldSuppressAppLinksInNextNavigationPolicyDecision = hostsAreEqual(URL(ParsedURLString, mainFrameURL), request.url());
3515 void WebPageProxy::showPage()
3517 m_uiClient->showPage(this);
3520 void WebPageProxy::fullscreenMayReturnToInline()
3522 m_uiClient->fullscreenMayReturnToInline(this);
3525 void WebPageProxy::didEnterFullscreen()
3527 m_uiClient->didEnterFullscreen(this);
3530 void WebPageProxy::didExitFullscreen()
3532 m_uiClient->didExitFullscreen(this);
3535 void WebPageProxy::closePage(bool stopResponsivenessTimer)
3537 if (stopResponsivenessTimer)
3538 m_process->responsivenessTimer().stop();
3540 m_pageClient.clearAllEditCommands();
3541 m_uiClient->close(this);
3544 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const SecurityOriginData& securityOrigin, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply> reply)
3546 WebFrameProxy* frame = m_process->webFrame(frameID);
3547 MESSAGE_CHECK(frame);
3549 // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
3550 m_process->responsivenessTimer().stop();
3552 m_uiClient->runJavaScriptAlert(this, message, frame, securityOrigin, [reply]{ reply->send(); });
3555 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const SecurityOriginData& securityOrigin, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply> reply)
3557 WebFrameProxy* frame = m_process->webFrame(frameID);
3558 MESSAGE_CHECK(frame);
3560 // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
3561 m_process->responsivenessTimer().stop();
3563 m_uiClient->runJavaScriptConfirm(this, message, frame, securityOrigin, [reply](bool result) { reply->send(result); });
3566 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const SecurityOriginData& securityOrigin, const String& message, const String& defaultValue, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
3568 WebFrameProxy* frame = m_process->webFrame(frameID);
3569 MESSAGE_CHECK(frame);
3571 // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
3572 m_process->responsivenessTimer().stop();
3574 m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame, securityOrigin, [reply](const String& result) { reply->send(result); });
3577 void WebPageProxy::setStatusText(const String& text)
3579 m_uiClient->setStatusText(this, text);
3582 void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResultData& hitTestResultData, uint32_t opaqueModifiers, const UserData& userData)
3584 m_lastMouseMoveHitTestResult = API::HitTestResult::create(hitTestResultData);
3586 WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
3588 m_uiClient->mouseDidMoveOverElement(this, hitTestResultData, modifiers, m_process->transformHandlesToObjects(userData.object()).get());
3591 void WebPageProxy::connectionWillOpen(IPC::Connection& connection)
3593 ASSERT(&connection == m_process->connection());
3595 m_webProcessLifetimeTracker.connectionWillOpen(connection);
3598 void WebPageProxy::webProcessWillShutDown()
3600 m_webProcessLifetimeTracker.webProcessWillShutDown();
3603 void WebPageProxy::processDidFinishLaunching()
3605 ASSERT(m_process->state() == WebProcessProxy::State::Running);
3607 if (m_userContentController)
3608 m_process->addWebUserContentControllerProxy(*m_userContentController);
3609 m_process->addVisitedLinkStore(m_visitedLinkStore);
3612 #if ENABLE(NETSCAPE_PLUGIN_API)
3613 void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& pluginURLString, const String& pluginspageAttributeURLString, const String& frameURLString, const String& pageURLString)
3615 MESSAGE_CHECK_URL(pluginURLString);
3616 MESSAGE_CHECK_URL(pluginspageAttributeURLString);
3617 MESSAGE_CHECK_URL(frameURLString);
3618 MESSAGE_CHECK_URL(pageURLString);
3620 RefPtr<API::Dictionary> pluginInformation;
3621 String newMimeType = mimeType;
3622 PluginModuleInfo plugin = m_process->processPool().pluginInfoStore().findPlugin(newMimeType, URL(URL(), pluginURLString));
3623 pluginInformation = createPluginInformationDictionary(plugin, frameURLString, mimeType, pageURLString, pluginspageAttributeURLString, pluginURLString);
3625 WKPluginUnavailabilityReason pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
3626 switch (static_cast<RenderEmbeddedObject::PluginUnavailabilityReason>(opaquePluginUnavailabilityReason)) {
3627 case RenderEmbeddedObject::PluginMissing:
3628 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
3630 case RenderEmbeddedObject::InsecurePluginVersion:
3631 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonInsecurePluginVersion;
3633 case RenderEmbeddedObject::PluginCrashed:
3634 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginCrashed;
3636 case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy:
3637 ASSERT_NOT_REACHED();
3640 m_uiClient->unavailablePluginButtonClicked(this, pluginUnavailabilityReason, pluginInformation.get());
3642 #endif // ENABLE(NETSCAPE_PLUGIN_API)
3645 void WebPageProxy::webGLPolicyForURL(const String& url, uint32_t& loadPolicy)
3647 loadPolicy = static_cast<uint32_t>(m_loaderClient->webGLLoadPolicy(*this, url));
3650 void WebPageProxy::resolveWebGLPolicyForURL(const String& url, uint32_t& loadPolicy)
3652 loadPolicy = static_cast<uint32_t>(m_loaderClient->resolveWebGLLoadPolicy(*this, url));
3654 #endif // ENABLE(WEBGL)
3656 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
3658 m_uiClient->setToolbarsAreVisible(this, toolbarsAreVisible);
3661 void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
3663 toolbarsAreVisible = m_uiClient->toolbarsAreVisible(this);
3666 void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
3668 m_uiClient->setMenuBarIsVisible(this, menuBarIsVisible);
3671 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
3673 menuBarIsVisible = m_uiClient->menuBarIsVisible(this);
3676 void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
3678 m_uiClient->setStatusBarIsVisible(this, statusBarIsVisible);
3681 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
3683 statusBarIsVisible = m_uiClient->statusBarIsVisible(this);
3686 void WebPageProxy::setIsResizable(bool isResizable)
3688 m_uiClient->setIsResizable(this, isResizable);
3691 void WebPageProxy::getIsResizable(bool& isResizable)
3693 isResizable = m_uiClient->isResizable(this);
3696 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
3698 m_uiClient->setWindowFrame(this, m_pageClient.convertToDeviceSpace(newWindowFrame));
3701 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
3703 newWindowFrame = m_pageClient.convertToUserSpace(m_uiClient->windowFrame(this));
3706 void WebPageProxy::screenToRootView(const IntPoint& screenPoint, IntPoint& windowPoint)
3708 windowPoint = m_pageClient.screenToRootView(screenPoint);
3711 void WebPageProxy::rootViewToScreen(const IntRect& viewRect, IntRect& result)
3713 result = m_pageClient.rootViewToScreen(viewRect);
3717 void WebPageProxy::accessibilityScreenToRootView(const IntPoint& screenPoint, IntPoint& windowPoint)
3719 windowPoint = m_pageClient.accessibilityScreenToRootView(screenPoint);
3722 void WebPageProxy::rootViewToAccessibilityScreen(const IntRect& viewRect, IntRect& result)
3724 result = m_pageClient.rootViewToAccessibilityScreen(viewRect);
3728 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
3730 WebFrameProxy* frame = m_process->webFrame(frameID);
3731 MESSAGE_CHECK(frame);
3733 // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
3734 m_process->responsivenessTimer().stop();
3736 shouldClose = m_uiClient->runBeforeUnloadConfirmPanel(this, message, frame);
3739 #if USE(COORDINATED_GRAPHICS_MULTIPROCESS)
3740 void WebPageProxy::pageDidRequestScroll(const IntPoint& point)
3742 m_pageClient.pageDidRequestScroll(point);
3745 void WebPageProxy::pageTransitionViewportReady()
3747 m_pageClient.pageTransitionViewportReady();
3750 void WebPageProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
3752 m_pageClient.didRenderFrame(contentsSize, coveredRect);
3755 void WebPageProxy::commitPageTransitionViewport()
3760 process().send(Messages::WebPage::CommitPageTransitionViewport(), m_pageID);
3764 void WebPageProxy::didChangeViewportProperties(const ViewportAttributes& attr)
3766 m_pageClient.didChangeViewportProperties(attr);
3769 void WebPageProxy::pageDidScroll()
3771 m_uiClient->pageDidScroll(this);
3774 void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
3776 if (m_openPanelResultListener) {
3777 m_openPanelResultListener->invalidate();
3778 m_openPanelResultListener = nullptr;
3781 WebFrameProxy* frame = m_process->webFrame(frameID);
3782 MESSAGE_CHECK(frame);
3784 RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
3785 m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
3787 // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
3788 m_process->responsivenessTimer().stop();
3790 if (!m_uiClient->runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get())) {
3791 if (!m_pageClient.handleRunOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
3792 didCancelForOpenPanel();
3796 void WebPageProxy::printFrame(uint64_t frameID)
3798 ASSERT(!m_isPerformingDOMPrintOperation);
3799 m_isPerformingDOMPrintOperation = true;
3801 WebFrameProxy* frame = m_process->webFrame(frameID);
3802 MESSAGE_CHECK(frame);
3804 m_uiClient->printFrame(this, frame);
3806 endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
3807 m_isPerformingDOMPrintOperation = false;
3810 void WebPageProxy::printMainFrame()
3812 printFrame(m_mainFrame->frameID());
3815 void WebPageProxy::setMediaVolume(float volume)
3817 if (volume == m_mediaVolume)
3820 m_mediaVolume = volume;
3825 m_process->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);
3828 void WebPageProxy::setMuted(bool muted)
3830 if (m_muted == muted)
3838 m_process->send(Messages::WebPage::SetMuted(muted), m_pageID);
3841 #if ENABLE(MEDIA_SESSION)
3842 void WebPageProxy::handleMediaEvent(MediaEventType eventType)
3847 m_process->send(Messages::WebPage::HandleMediaEvent(eventType), m_pageID);
3850 void WebPageProxy::setVolumeOfMediaElement(double volume, uint64_t elementID)
3855 m_process->send(Messages::WebPage::SetVolumeOfMediaElement(volume, elementID), m_pageID);
3859 void WebPageProxy::setMayStartMediaWhenInWindow(bool mayStartMedia)
3861 if (mayStartMedia == m_mayStartMediaWhenInWindow)
3864 m_mayStartMediaWhenInWindow = mayStartMedia;
3869 process().send(Messages::WebPage::SetMayStartMediaWhenInWindow(mayStartMedia), m_pageID);
3872 void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
3874 m_pageClient.handleDownloadRequest(download);
3877 void WebPageProxy::didChangeContentSize(const IntSize& size)
3879 m_pageClient.didChangeContentSize(size);
3882 #if ENABLE(INPUT_TYPE_COLOR)
3883 void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect)
3885 #if ENABLE(INPUT_TYPE_COLOR_POPOVER)
3886 // A new popover color well needs to be created (and the previous one destroyed) for
3887 // each activation of a color element.
3888 m_colorPicker = nullptr;
3891 m_colorPicker = m_pageClient.createColorPicker(this, initialColor, elementRect);
3892 m_colorPicker->showColorPicker(initialColor);
3895 void WebPageProxy::setColorPickerColor(const WebCore::Color& color)
3897 ASSERT(m_colorPicker);
3899 m_colorPicker->setSelectedColor(color);
3902 void WebPageProxy::endColorPicker()
3904 ASSERT(m_colorPicker);
3906 m_colorPicker->endPicker();
3909 void WebPageProxy::didChooseColor(const WebCore::Color& color)
3914 m_process->send(Messages::WebPage::DidChooseColor(color), m_pageID);
3917 void WebPageProxy::didEndColorPicker()
3922 #if ENABLE(INPUT_TYPE_COLOR)
3923 if (m_colorPicker) {
3924 m_colorPicker->invalidate();
3925 m_colorPicker = nullptr;
3929 m_process->send(Messages::WebPage::DidEndColorPicker(), m_pageID);
3934 WebInspectorProxy* WebPageProxy::inspector()
3936 if (isClosed() || !isValid())
3938 return m_inspector.get();
3941 #if ENABLE(FULLSCREEN_API)
3942 WebFullScreenManagerProxy* WebPageProxy::fullScreenManager()
3944 return m_fullScreenManager.get();
3949 RefPtr<WebVideoFullscreenManagerProxy> WebPageProxy::videoFullscreenManager()
3951 return m_videoFullscreenManager;
3954 bool WebPageProxy::allowsMediaDocumentInlinePlayback() const
3956 return m_allowsMediaDocumentInlinePlayback;
3959 void WebPageProxy::setAllowsMediaDocumentInlinePlayback(bool allows)
3961 if (m_allowsMediaDocumentInlinePlayback == allows)
3963 m_allowsMediaDocumentInlinePlayback = allows;
3965 m_process->send(Messages::WebPage::SetAllowsMediaDocumentInlinePlayback(allows), m_pageID);
3971 void WebPageProxy::backForwardAddItem(uint64_t itemID)
3973 m_backForwardList->addItem(m_process->webBackForwardItem(itemID));
3976 void WebPageProxy::backForwardGoToItem(uint64_t itemID, SandboxExtension::Handle& sandboxExtensionHandle)
3978 WebBackForwardListItem* item = m_process->webBackForwardItem(itemID);
3982 bool createdExtension = maybeInitializeSandboxExtensionHandle(URL(URL(), item->url()), sandboxExtensionHandle);
3983 if (createdExtension)
3984 m_process->willAcquireUniversalFileReadSandboxExtension();
3985 m_backForwardList->goToItem(item);
3988 void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
3990 WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
3991 itemID = item ? item->itemID() : 0;
3994 void WebPageProxy::backForwardBackListCount(int32_t& count)
3996 count = m_backForwardList->backListCount();
3999 void WebPageProxy::backForwardForwardListCount(int32_t& count)
4001 count = m_backForwardList->forwardListCount();
4004 void WebPageProxy::compositionWasCanceled(const EditorState& editorState)
4007 m_pageClient.notifyInputContextAboutDiscardedComposition();
4009 editorStateChanged(editorState);
4014 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
4016 registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
4019 void WebPageProxy::registerInsertionUndoGrouping()
4021 #if USE(INSERTION_UNDO_GROUPING)
4022 m_pageClient.registerInsertionUndoGrouping();
4026 void WebPageProxy::canUndoRedo(uint32_t action, bool& result)
4028 result = m_pageClient.canUndoRedo(static_cast<UndoOrRedo>(action));
4031 void WebPageProxy::executeUndoRedo(uint32_t action, bool& result)
4033 m_pageClient.executeUndoRedo(static_cast<UndoOrRedo>(action));
4037 void WebPageProxy::clearAllEditCommands()
4039 m_pageClient.clearAllEditCommands();
4042 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
4044 m_findClient->didCountStringMatches(this, string, matchCount);
4047 void WebPageProxy::didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex)
4049 m_findMatchesClient->didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex);
4052 void WebPageProxy::setTextIndicator(const TextIndicatorData& indicatorData, uint64_t lifetime)
4054 // FIXME: Make TextIndicatorWindow a platform-independent presentational thing ("TextIndicatorPresentation"?).
4056 m_pageClient.setTextIndicator(TextIndicator::create(indicatorData), static_cast<TextIndicatorWindowLifetime>(lifetime));
4058 ASSERT_NOT_REACHED();
4062 void WebPageProxy::clearTextIndicator()
4065 m_pageClient.clearTextIndicator(TextIndicatorWindowDismissalAnimation::FadeOut);
4067 ASSERT_NOT_REACHED();
4071 void WebPageProxy::setTextIndicatorAnimationProgress(float progress)
4074 m_pageClient.setTextIndicatorAnimationProgress(progress);
4076 ASSERT_NOT_REACHED();
4080 void WebPageProxy::didFindString(const String& string, const Vector<WebCore::IntRect>& matchRects, uint32_t matchCount, int32_t matchIndex)
4082 m_findClient->didFindString(this, string, matchRects, matchCount, matchIndex);
4085 void WebPageProxy::didFindStringMatches(const String& string, const Vector<Vector<WebCore::IntRect>>& matchRects, int32_t firstIndexAfterSelection)
4087 m_findMatchesClient->didFindStringMatches(this, string, matchRects, firstIndexAfterSelection);
4090 void WebPageProxy::didFailToFindString(const String& string)
4092 m_findClient->didFailToFindString(this, string);
4095 bool WebPageProxy::sendMessage(std::unique_ptr<IPC::MessageEncoder> encoder, unsigned messageSendFlags)
4097 return m_process->sendMessage(WTF::move(encoder), messageSendFlags);
4100 IPC::Connection* WebPageProxy::messageSenderConnection()
4102 return m_process->connection();
4105 uint64_t WebPageProxy::messageSenderDestinationID()
4110 void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
4112 m_process->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
4115 void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
4117 m_process->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
4120 NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent()
4122 return m_currentlyProcessedMouseDownEvent.get();
4125 void WebPageProxy::postMessageToInjectedBundle(const String& messageName, API::Object* messageBody)
4127 process().send(Messages::WebPage::PostInjectedBundleMessage(messageName, UserData(process().transformObjectsToHandles(messageBody).get())), m_pageID);
4131 void WebPageProxy::failedToShowPopupMenu()
4133 m_process->send(Messages::WebPage::FailedToShowPopupMenu(), m_pageID);
4137 void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
4139 if (m_activePopupMenu) {
4141 m_uiPopupMenuClient.hidePopupMenu(this);
4143 m_activePopupMenu->hidePopupMenu();
4145 m_activePopupMenu->invalidate();
4146 m_activePopupMenu = nullptr;
4149 m_activePopupMenu = m_pageClient.createPopupMenuProxy(*this);
4151 if (!m_activePopupMenu)
4154 // Since showPopupMenu() can spin a nested run loop we need to turn off the responsiveness timer.
4155 m_process->responsivenessTimer().stop();
4159 m_uiPopupMenuClient.showPopupMenu(this, m_activePopupMenu.get(), rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, selectedIndex);
4162 // Showing a popup menu runs a nested runloop, which can handle messages that cause |this| to get closed.
4163 Ref<WebPageProxy> protect(*this);
4164 m_activePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, data, selectedIndex);
4168 void WebPageProxy::hidePopupMenu()
4170 if (!m_activePopupMenu)
4174 m_uiPopupMenuClient.hidePopupMenu(this);
4176 m_activePopupMenu->hidePopupMenu();
4178 m_activePopupMenu->invalidate();
4179 m_activePopupMenu = nullptr;
4182 #if ENABLE(CONTEXT_MENUS)
4183 void WebPageProxy::showContextMenu(const ContextMenuContextData& contextMenuContextData, const UserData& userData)
4185 // Showing a context menu runs a nested runloop, which can handle messages that cause |this| to get closed.
4186 Ref<WebPageProxy> protect(*this);
4188 internalShowContextMenu(contextMenuContextData, userData);
4190 // No matter the result of internalShowContextMenu, always notify the WebProcess that the menu is hidden so it starts handling mouse events again.
4191 m_process->send(Messages::WebPage::ContextMenuHidden(), m_pageID);
4194 void WebPageProxy::internalShowContextMenu(const ContextMenuContextData& contextMenuContextData, const UserData& userData)
4196 m_activeContextMenuContextData = contextMenuContextData;
4198 m_activeContextMenu = m_pageClient.createContextMenuProxy(*this, contextMenuContextData, userData);
4199 if (!m_activeContextMenu)
4202 // Since showContextMenu() can spin a nested run loop we need to turn off the responsiveness timer.
4203 m_process->responsivenessTimer().stop();
4205 m_activeContextMenu->show();
4208 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
4210 // Application custom items don't need to round-trip through to WebCore in the WebProcess.
4211 if (item.action() >= ContextMenuItemBaseApplicationTag) {
4212 m_contextMenuClient->customContextMenuItemSelected(*this, item);
4217 if (item.action() == ContextMenuItemTagSmartCopyPaste) {
4218 setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
4221 if (item.action() == ContextMenuItemTagSmartQuotes) {
4222 TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
4223 m_process->updateTextCheckerState();
4226 if (item.action() == ContextMenuItemTagSmartDashes) {
4227 TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
4228 m_process->updateTextCheckerState();
4231 if (item.action() == ContextMenuItemTagSmartLinks) {
4232 TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
4233 m_process->updateTextCheckerState();
4236 if (item.action() == ContextMenuItemTagTextReplacement) {
4237 TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
4238 m_process->updateTextCheckerState();
4241 if (item.action() == ContextMenuItemTagCorrectSpellingAutomatically) {
4242 TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
4243 m_process->updateTextCheckerState();
4246 if (item.action() == ContextMenuItemTagShowSubstitutions) {
4247 TextChecker::toggleSubstitutionsPanelIsShowing();
4251 if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
4252 m_process->processPool().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteImageURL));
4255 if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
4256 m_process->processPool().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteLinkURL));
4259 if (item.action() == ContextMenuItemTagDownloadMediaToDisk) {
4260 m_process->processPool().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteMediaURL));
4263 if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) {
4264 TextChecker::setContinuousSpellCheckingEnabled(!TextChecker::state().isContinuousSpellCheckingEnabled);