2 * Copyright (C) 2010, 2011 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 "APILoaderClient.h"
32 #include "APIPolicyClient.h"
33 #include "APIUIClient.h"
34 #include "APIURLRequest.h"
35 #include "AuthenticationChallengeProxy.h"
36 #include "AuthenticationDecisionListener.h"
37 #include "DataReference.h"
38 #include "DownloadProxy.h"
39 #include "DrawingAreaProxy.h"
40 #include "DrawingAreaProxyMessages.h"
41 #include "EventDispatcherMessages.h"
42 #include "FindIndicator.h"
44 #include "NativeWebKeyboardEvent.h"
45 #include "NativeWebMouseEvent.h"
46 #include "NativeWebWheelEvent.h"
47 #include "NavigationActionData.h"
48 #include "NotificationPermissionRequest.h"
49 #include "NotificationPermissionRequestManager.h"
50 #include "PageClient.h"
51 #include "PluginInformation.h"
52 #include "PluginProcessManager.h"
53 #include "PrintInfo.h"
54 #include "SessionState.h"
55 #include "TextChecker.h"
56 #include "TextCheckerState.h"
57 #include "WKContextPrivate.h"
58 #include "WebBackForwardList.h"
59 #include "WebBackForwardListItem.h"
60 #include "WebCertificateInfo.h"
61 #include "WebContext.h"
62 #include "WebContextMenuProxy.h"
63 #include "WebContextUserMessageCoders.h"
64 #include "WebCoreArgumentCoders.h"
65 #include "WebEditCommandProxy.h"
67 #include "WebEventConversion.h"
68 #include "WebFormSubmissionListenerProxy.h"
69 #include "WebFramePolicyListenerProxy.h"
70 #include "WebFullScreenManagerProxy.h"
71 #include "WebFullScreenManagerProxyMessages.h"
72 #include "WebInspectorProxy.h"
73 #include "WebInspectorProxyMessages.h"
74 #include "WebNotificationManagerProxy.h"
75 #include "WebOpenPanelParameters.h"
76 #include "WebOpenPanelResultListenerProxy.h"
77 #include "WebPageCreationParameters.h"
78 #include "WebPageGroup.h"
79 #include "WebPageGroupData.h"
80 #include "WebPageMessages.h"
81 #include "WebPageProxyMessages.h"
82 #include "WebPopupItem.h"
83 #include "WebPopupMenuProxy.h"
84 #include "WebPreferences.h"
85 #include "WebProcessMessages.h"
86 #include "WebProcessProxy.h"
87 #include "WebProtectionSpace.h"
88 #include "WebSecurityOrigin.h"
89 #include <WebCore/DragController.h>
90 #include <WebCore/DragData.h>
91 #include <WebCore/DragSession.h>
92 #include <WebCore/FloatRect.h>
93 #include <WebCore/FocusDirection.h>
94 #include <WebCore/MIMETypeRegistry.h>
95 #include <WebCore/RenderEmbeddedObject.h>
96 #include <WebCore/SerializedCryptoKeyWrap.h>
97 #include <WebCore/TextCheckerClient.h>
98 #include <WebCore/WindowFeatures.h>
100 #include <wtf/NeverDestroyed.h>
101 #include <wtf/text/StringView.h>
103 #if ENABLE(ASYNC_SCROLLING)
104 #include "RemoteScrollingCoordinatorProxy.h"
107 #if USE(COORDINATED_GRAPHICS)
108 #include "CoordinatedLayerTreeHostProxyMessages.h"
112 #include "ArgumentCodersGtk.h"
115 #if USE(SOUP) && !ENABLE(CUSTOM_PROTOCOLS)
116 #include "WebSoupRequestManagerProxy.h"
119 #if ENABLE(VIBRATION)
120 #include "WebVibrationProxy.h"
124 #include <wtf/RefCountedLeakCounter.h>
127 #if ENABLE(NETWORK_PROCESS)
128 #include "NetworkProcessMessages.h"
132 #include "ViewSnapshotStore.h"
136 #include "WebVideoFullscreenManagerProxy.h"
137 #include "WebVideoFullscreenManagerProxyMessages.h"
140 // This controls what strategy we use for mouse wheel coalescing.
141 #define MERGE_WHEEL_EVENTS 1
143 #define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection())
144 #define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
146 using namespace WebCore;
148 // Represents the number of wheel events we can hold in the queue before we start pushing them preemptively.
149 static const unsigned wheelEventQueueSizeThreshold = 10;
153 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageProxyCounter, ("WebPageProxy"));
155 class ExceededDatabaseQuotaRecords {
156 WTF_MAKE_NONCOPYABLE(ExceededDatabaseQuotaRecords); WTF_MAKE_FAST_ALLOCATED;
157 friend class NeverDestroyed<ExceededDatabaseQuotaRecords>;
161 String originIdentifier;
164 uint64_t currentQuota;
165 uint64_t currentOriginUsage;
166 uint64_t currentDatabaseUsage;
167 uint64_t expectedUsage;
168 RefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply;
171 static ExceededDatabaseQuotaRecords& shared();
173 PassOwnPtr<Record> createRecord(uint64_t frameID, String originIdentifier,
174 String databaseName, String displayName, uint64_t currentQuota,
175 uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage,
176 PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
178 void add(PassOwnPtr<Record>);
179 bool areBeingProcessed() const { return m_currentRecord; }
183 ExceededDatabaseQuotaRecords() { }
184 ~ExceededDatabaseQuotaRecords() { }
186 Deque<OwnPtr<Record>> m_records;
187 OwnPtr<Record> m_currentRecord;
190 ExceededDatabaseQuotaRecords& ExceededDatabaseQuotaRecords::shared()
192 static NeverDestroyed<ExceededDatabaseQuotaRecords> records;
196 PassOwnPtr<ExceededDatabaseQuotaRecords::Record> ExceededDatabaseQuotaRecords::createRecord(
197 uint64_t frameID, String originIdentifier, String databaseName, String displayName,
198 uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage,
199 uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply> reply)
201 OwnPtr<Record> record = adoptPtr(new Record);
202 record->frameID = frameID;
203 record->originIdentifier = originIdentifier;
204 record->databaseName = databaseName;
205 record->displayName = displayName;
206 record->currentQuota = currentQuota;
207 record->currentOriginUsage = currentOriginUsage;
208 record->currentDatabaseUsage = currentDatabaseUsage;
209 record->expectedUsage = expectedUsage;
210 record->reply = reply;
211 return record.release();
214 void ExceededDatabaseQuotaRecords::add(PassOwnPtr<ExceededDatabaseQuotaRecords::Record> record)
216 m_records.append(record);
219 ExceededDatabaseQuotaRecords::Record* ExceededDatabaseQuotaRecords::next()
221 m_currentRecord.clear();
222 if (!m_records.isEmpty())
223 m_currentRecord = m_records.takeFirst();
224 return m_currentRecord.get();
228 static const char* webKeyboardEventTypeString(WebEvent::Type type)
231 case WebEvent::KeyDown:
234 case WebEvent::KeyUp:
237 case WebEvent::RawKeyDown:
244 ASSERT_NOT_REACHED();
248 #endif // !LOG_DISABLED
250 PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient& pageClient, WebProcessProxy& process, uint64_t pageID, const WebPageConfiguration& configuration)
252 return adoptRef(new WebPageProxy(pageClient, process, pageID, configuration));
255 WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uint64_t pageID, const WebPageConfiguration& configuration)
256 : m_pageClient(pageClient)
257 , m_loaderClient(std::make_unique<API::LoaderClient>())
258 , m_policyClient(std::make_unique<API::PolicyClient>())
259 , m_uiClient(std::make_unique<API::UIClient>())
261 , m_pageGroup(*configuration.pageGroup)
262 , m_preferences(*configuration.preferences)
263 , m_visitedLinkProvider(*configuration.visitedLinkProvider)
264 , m_mainFrame(nullptr)
265 , m_userAgent(standardUserAgent())
266 , m_geolocationPermissionRequestManager(*this)
267 , m_notificationPermissionRequestManager(*this)
268 , m_viewState(ViewState::NoFlags)
269 , m_backForwardList(WebBackForwardList::create(*this))
270 , m_loadStateAtProcessExit(FrameLoadState::State::Finished)
271 , m_temporarilyClosedComposition(false)
272 , m_textZoomFactor(1)
273 , m_pageZoomFactor(1)
274 , m_pageScaleFactor(1)
275 , m_intrinsicDeviceScaleFactor(1)
276 , m_customDeviceScaleFactor(0)
277 , m_topContentInset(0)
278 , m_layerHostingMode(LayerHostingMode::InProcess)
279 , m_drawsBackground(true)
280 , m_drawsTransparentBackground(false)
281 , m_areMemoryCacheClientCallsEnabled(true)
282 , m_useFixedLayout(false)
283 , m_suppressScrollbarAnimations(false)
284 , m_paginationMode(Pagination::Unpaginated)
285 , m_paginationBehavesLikeColumns(false)
287 , m_gapBetweenPages(0)
290 , m_canRunModal(false)
291 , m_isInPrintingMode(false)
292 , m_isPerformingDOMPrintOperation(false)
293 , m_inDecidePolicyForResponseSync(false)
294 , m_decidePolicyForResponseRequest(0)
295 , m_syncMimeTypePolicyActionIsValid(false)
296 , m_syncMimeTypePolicyAction(PolicyUse)
297 , m_syncMimeTypePolicyDownloadID(0)
298 , m_inDecidePolicyForNavigationAction(false)
299 , m_syncNavigationActionPolicyActionIsValid(false)
300 , m_syncNavigationActionPolicyAction(PolicyUse)
301 , m_syncNavigationActionPolicyDownloadID(0)
302 , m_processingMouseMoveEvent(false)
303 #if ENABLE(TOUCH_EVENTS)
304 , m_isTrackingTouchEvents(false)
307 , m_session(*configuration.session)
308 , m_isPageSuspended(false)
309 #if ENABLE(REMOTE_INSPECTOR)
310 , m_allowsRemoteInspection(true)
313 , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
315 , m_spellDocumentTag(0)
316 , m_hasSpellDocumentTag(false)
317 , m_pendingLearnOrIgnoreWordMessageCount(0)
318 , m_mainFrameHasCustomContentProvider(false)
319 , m_delegatesScrolling(false)
320 , m_mainFrameHasHorizontalScrollbar(false)
321 , m_mainFrameHasVerticalScrollbar(false)
322 , m_canShortCircuitHorizontalWheelEvents(true)
323 , m_mainFrameIsPinnedToLeftSide(false)
324 , m_mainFrameIsPinnedToRightSide(false)
325 , m_mainFrameIsPinnedToTopSide(false)
326 , m_mainFrameIsPinnedToBottomSide(false)
327 , m_shouldUseImplicitRubberBandControl(false)
328 , m_rubberBandsAtLeft(true)
329 , m_rubberBandsAtRight(true)
330 , m_rubberBandsAtTop(true)
331 , m_rubberBandsAtBottom(true)
332 , m_backgroundExtendsBeyondPage(false)
333 , m_shouldRecordNavigationSnapshots(false)
335 , m_renderTreeSize(0)
336 , m_shouldSendEventsSynchronously(false)
337 , m_suppressVisibilityUpdates(false)
338 , m_autoSizingShouldExpandToViewHeight(false)
340 , m_mayStartMediaWhenInWindow(true)
341 , m_waitingForDidUpdateViewState(false)
342 , m_scrollPinningBehavior(DoNotPin)
345 if (m_process->state() == WebProcessProxy::State::Running)
346 m_visitedLinkProvider->addProcess(m_process.get());
350 #if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
351 m_layerHostingMode = m_viewState & ViewState::IsInWindow ? m_pageClient.viewLayerHostingMode() : LayerHostingMode::OutOfProcess;
354 platformInitialize();
357 webPageProxyCounter.increment();
360 WebContext::statistics().wkPageCount++;
362 m_preferences->addPage(*this);
363 m_pageGroup->addPage(this);
365 #if ENABLE(INSPECTOR)
366 m_inspector = WebInspectorProxy::create(this);
368 #if ENABLE(FULLSCREEN_API)
369 m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
372 m_videoFullscreenManager = WebVideoFullscreenManagerProxy::create(*this);
374 #if ENABLE(VIBRATION)
375 m_vibration = WebVibrationProxy::create(this);
378 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
380 // FIXME: If we ever expose the session storage size as a preference, we need to pass it here.
381 IPC::Connection* connection = m_process->state() == WebProcessProxy::State::Running ? m_process->connection() : nullptr;
382 m_process->context().storageManager().createSessionStorageNamespace(m_pageID, connection, std::numeric_limits<unsigned>::max());
383 setSession(*configuration.session);
386 WebPageProxy::~WebPageProxy()
391 WebContext::statistics().wkPageCount--;
393 if (m_hasSpellDocumentTag)
394 TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
396 m_preferences->removePage(*this);
397 m_pageGroup->removePage(this);
400 webPageProxyCounter.decrement();
404 PlatformProcessIdentifier WebPageProxy::processIdentifier() const
409 return m_process->processIdentifier();
412 bool WebPageProxy::isValid() const
414 // A page that has been explicitly closed is never valid.
421 void WebPageProxy::setPreferences(WebPreferences& preferences)
423 if (&preferences == &m_preferences.get())
426 m_preferences->removePage(*this);
427 m_preferences = preferences;
428 m_preferences->addPage(*this);
430 preferencesDidChange();
433 void WebPageProxy::setLoaderClient(std::unique_ptr<API::LoaderClient> loaderClient)
436 m_loaderClient = std::make_unique<API::LoaderClient>();
440 m_loaderClient = std::move(loaderClient);
443 void WebPageProxy::setPolicyClient(std::unique_ptr<API::PolicyClient> policyClient)
446 m_policyClient = std::make_unique<API::PolicyClient>();
450 m_policyClient = std::move(policyClient);
453 void WebPageProxy::initializeFormClient(const WKPageFormClientBase* formClient)
455 m_formClient.initialize(formClient);
458 void WebPageProxy::setUIClient(std::unique_ptr<API::UIClient> uiClient)
461 m_uiClient = std::make_unique<API::UIClient>();
465 m_uiClient = std::move(uiClient);
470 m_process->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient->canRunBeforeUnloadConfirmPanel()), m_pageID);
471 setCanRunModal(m_uiClient->canRunModal());
474 void WebPageProxy::initializeFindClient(const WKPageFindClientBase* client)
476 m_findClient.initialize(client);
479 void WebPageProxy::initializeFindMatchesClient(const WKPageFindMatchesClientBase* client)
481 m_findMatchesClient.initialize(client);
484 #if ENABLE(CONTEXT_MENUS)
485 void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClientBase* client)
487 m_contextMenuClient.initialize(client);
491 void WebPageProxy::reattachToWebProcess()
494 ASSERT(m_process->state() == WebProcessProxy::State::Terminated);
500 if (m_process->context().processModel() == ProcessModelSharedSecondaryProcess)
501 m_process = m_process->context().ensureSharedWebProcess();
503 m_process = m_process->context().createNewWebProcessRespectingProcessCountLimit();
504 m_process->addExistingWebPage(this, m_pageID);
505 m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID, *this);
507 #if ENABLE(INSPECTOR)
508 m_inspector = WebInspectorProxy::create(this);
510 #if ENABLE(FULLSCREEN_API)
511 m_fullScreenManager = WebFullScreenManagerProxy::create(*this, m_pageClient.fullScreenManagerProxyClient());
516 m_pageClient.didRelaunchProcess();
517 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
520 void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
522 if (item && item != m_backForwardList->currentItem())
523 m_backForwardList->goToItem(item);
525 reattachToWebProcess();
530 m_process->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
531 m_process->responsivenessTimer()->start();
534 void WebPageProxy::setSession(API::Session& session)
537 m_process->send(Messages::WebPage::SetSessionID(session.getID()), m_pageID);
539 #if ENABLE(NETWORK_PROCESS)
540 if (session.isEphemeral())
541 m_process->context().sendToNetworkingProcess(Messages::NetworkProcess::EnsurePrivateBrowsingSession(session.getID()));
545 void WebPageProxy::initializeWebPage()
549 BackForwardListItemVector items = m_backForwardList->entries();
550 for (size_t i = 0; i < items.size(); ++i)
551 m_process->registerNewWebBackForwardListItem(items[i].get());
553 m_drawingArea = m_pageClient.createDrawingAreaProxy();
554 ASSERT(m_drawingArea);
556 #if ENABLE(ASYNC_SCROLLING)
557 if (m_drawingArea->type() == DrawingAreaTypeRemoteLayerTree)
558 m_scrollingCoordinatorProxy = std::make_unique<RemoteScrollingCoordinatorProxy>(*this);
561 #if ENABLE(INSPECTOR_SERVER)
562 if (pageGroup().preferences().developerExtrasEnabled())
563 inspector()->enableRemoteInspection();
566 process().send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
569 send(Messages::WebPage::SetSmartInsertDeleteEnabled(m_isSmartInsertDeleteEnabled));
573 bool WebPageProxy::isProcessSuppressible() const
575 return (m_viewState & ViewState::IsVisuallyIdle) && m_preferences->pageVisibilityBasedProcessSuppressionEnabled();
578 void WebPageProxy::close()
585 if (m_process->state() == WebProcessProxy::State::Running)
586 m_visitedLinkProvider->removeProcess(m_process.get());
588 m_backForwardList->pageClosed();
589 m_pageClient.pageClosed();
591 m_process->disconnectFramesFromPage(this);
595 m_loaderClient = std::make_unique<API::LoaderClient>();
596 m_policyClient = std::make_unique<API::PolicyClient>();
597 m_formClient.initialize(0);
598 m_uiClient = std::make_unique<API::UIClient>();
600 m_uiPopupMenuClient.initialize(0);
602 m_findClient.initialize(0);
603 m_findMatchesClient.initialize(0);
604 #if ENABLE(CONTEXT_MENUS)
605 m_contextMenuClient.initialize(0);
608 m_process->send(Messages::WebPage::Close(), m_pageID);
609 m_process->removeWebPage(m_pageID);
610 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_pageID);
611 m_process->context().storageManager().destroySessionStorageNamespace(m_pageID);
612 m_process->context().supplement<WebNotificationManagerProxy>()->clearNotifications(this);
615 bool WebPageProxy::tryClose()
620 m_process->send(Messages::WebPage::TryClose(), m_pageID);
621 m_process->responsivenessTimer()->start();
625 bool WebPageProxy::maybeInitializeSandboxExtensionHandle(const URL& url, SandboxExtension::Handle& sandboxExtensionHandle)
627 if (!url.isLocalFile())
630 #if ENABLE(INSPECTOR)
631 // Don't give the inspector full access to the file system.
632 if (WebInspectorProxy::isInspectorPage(*this))
636 SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
640 uint64_t WebPageProxy::loadRequest(const ResourceRequest& request, API::Object* userData)
642 uint64_t navigationID = generateNavigationID();
644 auto transaction = m_pageLoadState.transaction();
646 m_pageLoadState.setPendingAPIRequestURL(transaction, request.url());
649 reattachToWebProcess();
651 SandboxExtension::Handle sandboxExtensionHandle;
652 bool createdExtension = maybeInitializeSandboxExtensionHandle(request.url(), sandboxExtensionHandle);
653 if (createdExtension)
654 m_process->willAcquireUniversalFileReadSandboxExtension();
655 m_process->send(Messages::WebPage::LoadRequest(navigationID, request, sandboxExtensionHandle, WebContextUserMessageEncoder(userData, process())), m_pageID);
656 m_process->responsivenessTimer()->start();
661 void WebPageProxy::loadFile(const String& fileURLString, const String& resourceDirectoryURLString, API::Object* userData)
664 reattachToWebProcess();
666 URL fileURL = URL(URL(), fileURLString);
667 if (!fileURL.isLocalFile())
670 URL resourceDirectoryURL;
671 if (resourceDirectoryURLString.isNull())
672 resourceDirectoryURL = URL(ParsedURLString, ASCIILiteral("file:///"));
674 resourceDirectoryURL = URL(URL(), resourceDirectoryURLString);
675 if (!resourceDirectoryURL.isLocalFile())
679 String resourceDirectoryPath = resourceDirectoryURL.fileSystemPath();
681 SandboxExtension::Handle sandboxExtensionHandle;
682 SandboxExtension::createHandle(resourceDirectoryPath, SandboxExtension::ReadOnly, sandboxExtensionHandle);
683 m_process->assumeReadAccessToBaseURL(resourceDirectoryURL);
684 m_process->send(Messages::WebPage::LoadRequest(generateNavigationID(), fileURL, sandboxExtensionHandle, WebContextUserMessageEncoder(userData, process())), m_pageID);
685 m_process->responsivenessTimer()->start();
688 void WebPageProxy::loadData(API::Data* data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData)
691 reattachToWebProcess();
693 m_process->assumeReadAccessToBaseURL(baseURL);
694 m_process->send(Messages::WebPage::LoadData(data->dataReference(), MIMEType, encoding, baseURL, WebContextUserMessageEncoder(userData, process())), m_pageID);
695 m_process->responsivenessTimer()->start();
698 void WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL, API::Object* userData)
701 reattachToWebProcess();
703 m_process->assumeReadAccessToBaseURL(baseURL);
704 m_process->send(Messages::WebPage::LoadHTMLString(htmlString, baseURL, WebContextUserMessageEncoder(userData, process())), m_pageID);
705 m_process->responsivenessTimer()->start();
708 void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL, API::Object* userData)
711 reattachToWebProcess();
713 auto transaction = m_pageLoadState.transaction();
715 m_pageLoadState.setUnreachableURL(transaction, unreachableURL);
718 m_mainFrame->setUnreachableURL(unreachableURL);
720 m_process->assumeReadAccessToBaseURL(baseURL);
721 m_process->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL, WebContextUserMessageEncoder(userData, process())), m_pageID);
722 m_process->responsivenessTimer()->start();
725 void WebPageProxy::loadPlainTextString(const String& string, API::Object* userData)
728 reattachToWebProcess();
730 m_process->send(Messages::WebPage::LoadPlainTextString(string, WebContextUserMessageEncoder(userData, process())), m_pageID);
731 m_process->responsivenessTimer()->start();
734 void WebPageProxy::loadWebArchiveData(API::Data* webArchiveData, API::Object* userData)
737 reattachToWebProcess();
739 m_process->send(Messages::WebPage::LoadWebArchiveData(webArchiveData->dataReference(), WebContextUserMessageEncoder(userData, process())), m_pageID);
740 m_process->responsivenessTimer()->start();
743 void WebPageProxy::stopLoading()
748 m_process->send(Messages::WebPage::StopLoading(), m_pageID);
749 m_process->responsivenessTimer()->start();
752 void WebPageProxy::reload(bool reloadFromOrigin)
754 SandboxExtension::Handle sandboxExtensionHandle;
756 if (m_backForwardList->currentItem()) {
757 String url = m_backForwardList->currentItem()->url();
758 auto transaction = m_pageLoadState.transaction();
759 m_pageLoadState.setPendingAPIRequestURL(transaction, url);
761 // We may not have an extension yet if back/forward list was reinstated after a WebProcess crash or a browser relaunch
762 bool createdExtension = maybeInitializeSandboxExtensionHandle(URL(URL(), url), sandboxExtensionHandle);
763 if (createdExtension)
764 m_process->willAcquireUniversalFileReadSandboxExtension();
768 reattachToWebProcessWithItem(m_backForwardList->currentItem());
772 m_process->send(Messages::WebPage::Reload(generateNavigationID(), reloadFromOrigin, sandboxExtensionHandle), m_pageID);
773 m_process->responsivenessTimer()->start();
776 void WebPageProxy::recordNavigationSnapshot()
778 if (!m_shouldRecordNavigationSnapshots)
782 ViewSnapshotStore::shared().recordSnapshot(*this);
786 void WebPageProxy::goForward()
788 WebBackForwardListItem* forwardItem = m_backForwardList->forwardItem();
792 recordNavigationSnapshot();
794 auto transaction = m_pageLoadState.transaction();
796 m_pageLoadState.setPendingAPIRequestURL(transaction, forwardItem->url());
799 reattachToWebProcessWithItem(forwardItem);
803 m_process->send(Messages::WebPage::GoForward(forwardItem->itemID()), m_pageID);
804 m_process->responsivenessTimer()->start();
807 void WebPageProxy::goBack()
809 WebBackForwardListItem* backItem = m_backForwardList->backItem();
813 recordNavigationSnapshot();
815 auto transaction = m_pageLoadState.transaction();
817 m_pageLoadState.setPendingAPIRequestURL(transaction, backItem->url());
820 reattachToWebProcessWithItem(backItem);
824 m_process->send(Messages::WebPage::GoBack(backItem->itemID()), m_pageID);
825 m_process->responsivenessTimer()->start();
828 void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
831 reattachToWebProcessWithItem(item);
835 recordNavigationSnapshot();
837 auto transaction = m_pageLoadState.transaction();
839 m_pageLoadState.setPendingAPIRequestURL(transaction, item->url());
841 m_process->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
842 m_process->responsivenessTimer()->start();
845 void WebPageProxy::tryRestoreScrollPosition()
850 m_process->send(Messages::WebPage::TryRestoreScrollPosition(), m_pageID);
853 void WebPageProxy::didChangeBackForwardList(WebBackForwardListItem* added, Vector<RefPtr<WebBackForwardListItem>> removed)
855 m_loaderClient->didChangeBackForwardList(this, added, std::move(removed));
858 m_pageClient.clearCustomSwipeViews();
862 void WebPageProxy::willGoToBackForwardListItem(uint64_t itemID, IPC::MessageDecoder& decoder)
864 RefPtr<API::Object> userData;
865 WebContextUserMessageDecoder messageDecoder(userData, process());
866 if (!decoder.decode(messageDecoder))
869 if (WebBackForwardListItem* item = m_process->webBackForwardItem(itemID))
870 m_loaderClient->willGoToBackForwardListItem(this, item, userData.get());
873 bool WebPageProxy::canShowMIMEType(const String& mimeType)
875 if (MIMETypeRegistry::canShowMIMEType(mimeType))
878 #if ENABLE(NETSCAPE_PLUGIN_API)
879 String newMimeType = mimeType;
880 PluginModuleInfo plugin = m_process->context().pluginInfoStore().findPlugin(newMimeType, URL());
881 if (!plugin.path.isNull() && m_preferences->pluginsEnabled())
883 #endif // ENABLE(NETSCAPE_PLUGIN_API)
886 // On Mac, we can show PDFs.
887 if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(mimeType) && !WebContext::omitPDFSupport())
889 #endif // PLATFORM(COCOA)
894 #if ENABLE(REMOTE_INSPECTOR)
895 void WebPageProxy::setAllowsRemoteInspection(bool allow)
897 if (m_allowsRemoteInspection == allow)
900 m_allowsRemoteInspection = allow;
903 m_process->send(Messages::WebPage::SetAllowsRemoteInspection(allow), m_pageID);
907 void WebPageProxy::setDrawsBackground(bool drawsBackground)
909 if (m_drawsBackground == drawsBackground)
912 m_drawsBackground = drawsBackground;
915 m_process->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
918 void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground)
920 if (m_drawsTransparentBackground == drawsTransparentBackground)
923 m_drawsTransparentBackground = drawsTransparentBackground;
926 m_process->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
929 void WebPageProxy::setTopContentInset(float contentInset)
931 if (m_topContentInset == contentInset)
934 m_topContentInset = contentInset;
937 m_process->send(Messages::WebPage::SetTopContentInset(contentInset), m_pageID);
940 void WebPageProxy::setUnderlayColor(const Color& color)
942 if (m_underlayColor == color)
945 m_underlayColor = color;
948 m_process->send(Messages::WebPage::SetUnderlayColor(color), m_pageID);
951 void WebPageProxy::viewWillStartLiveResize()
955 #if ENABLE(INPUT_TYPE_COLOR_POPOVER)
959 m_process->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID);
962 void WebPageProxy::viewWillEndLiveResize()
966 m_process->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
969 void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
971 m_pageClient.setViewNeedsDisplay(rect);
974 void WebPageProxy::displayView()
976 m_pageClient.displayView();
979 bool WebPageProxy::canScrollView()
981 return m_pageClient.canScrollView();
984 void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
986 m_pageClient.scrollView(scrollRect, scrollOffset);
989 void WebPageProxy::updateViewState(ViewState::Flags flagsToUpdate)
991 m_viewState &= ~flagsToUpdate;
992 if (flagsToUpdate & ViewState::IsFocused && m_pageClient.isViewFocused())
993 m_viewState |= ViewState::IsFocused;
994 if (flagsToUpdate & ViewState::WindowIsActive && m_pageClient.isViewWindowActive())
995 m_viewState |= ViewState::WindowIsActive;
996 if (flagsToUpdate & ViewState::IsVisible && m_pageClient.isViewVisible())
997 m_viewState |= ViewState::IsVisible;
998 if (flagsToUpdate & ViewState::IsVisibleOrOccluded && m_pageClient.isViewVisibleOrOccluded())
999 m_viewState |= ViewState::IsVisibleOrOccluded;
1000 if (flagsToUpdate & ViewState::IsInWindow && m_pageClient.isViewInWindow())
1001 m_viewState |= ViewState::IsInWindow;
1002 if (flagsToUpdate & ViewState::IsVisuallyIdle && m_pageClient.isVisuallyIdle())
1003 m_viewState |= ViewState::IsVisuallyIdle;
1006 void WebPageProxy::viewStateDidChange(ViewState::Flags mayHaveChanged, WantsReplyOrNot wantsReply)
1011 // If the visibility state may have changed, then so may the visually idle & occluded agnostic state.
1012 if (mayHaveChanged & ViewState::IsVisible)
1013 mayHaveChanged |= ViewState::IsVisibleOrOccluded | ViewState::IsVisuallyIdle;
1015 // Record the prior view state, update the flags that may have changed,
1016 // and check which flags have actually changed.
1017 ViewState::Flags previousViewState = m_viewState;
1018 updateViewState(mayHaveChanged);
1019 ViewState::Flags changed = m_viewState ^ previousViewState;
1022 m_process->send(Messages::WebPage::SetViewState(m_viewState, wantsReply == WantsReplyOrNot::DoesWantReply), m_pageID);
1024 if (changed & ViewState::IsVisuallyIdle)
1025 m_process->pageSuppressibilityChanged(this);
1027 // If we've started the responsiveness timer as part of telling the web process to update the backing store
1028 // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we
1029 // stop the unresponsiveness timer here.
1030 if ((changed & ViewState::IsVisible) && !isViewVisible())
1031 m_process->responsivenessTimer()->stop();
1033 if ((mayHaveChanged & ViewState::IsInWindow) && (m_viewState & ViewState::IsInWindow)) {
1034 LayerHostingMode layerHostingMode = m_pageClient.viewLayerHostingMode();
1035 if (m_layerHostingMode != layerHostingMode) {
1036 m_layerHostingMode = layerHostingMode;
1037 m_process->send(Messages::WebPage::SetLayerHostingMode(static_cast<unsigned>(layerHostingMode)), m_pageID);
1041 #if ENABLE(INPUT_TYPE_COLOR_POPOVER)
1042 if ((mayHaveChanged & ViewState::IsInWindow) && !(m_viewState & ViewState::IsInWindow)) {
1043 // When leaving the current page, close the popover color well.
1049 if (changed & ViewState::IsInWindow)
1050 process().updateProcessState();
1052 updateBackingStoreDiscardableState();
1055 void WebPageProxy::waitForDidUpdateViewState()
1057 // If we have previously timed out with no response from the WebProcess, don't block the UIProcess again until it starts responding.
1058 if (m_waitingForDidUpdateViewState)
1064 m_waitingForDidUpdateViewState = true;
1066 if (m_process->state() != WebProcessProxy::State::Launching) {
1067 auto viewStateUpdateTimeout = std::chrono::milliseconds(250);
1068 m_process->connection()->waitForAndDispatchImmediately<Messages::WebPageProxy::DidUpdateViewState>(m_pageID, viewStateUpdateTimeout);
1072 IntSize WebPageProxy::viewSize() const
1074 return m_pageClient.viewSize();
1077 void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent)
1081 m_process->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
1084 void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
1088 m_process->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
1091 void WebPageProxy::clearSelection()
1095 m_process->send(Messages::WebPage::ClearSelection(), m_pageID);
1098 void WebPageProxy::validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback> callback)
1101 callback->invalidate();
1105 uint64_t callbackID = callback->callbackID();
1106 m_validateCommandCallbacks.set(callbackID, callback);
1107 m_process->send(Messages::WebPage::ValidateCommand(commandName, callbackID), m_pageID);
1110 void WebPageProxy::setMaintainsInactiveSelection(bool newValue)
1112 m_maintainsInactiveSelection = newValue;
1115 void WebPageProxy::executeEditCommand(const String& commandName)
1117 static NeverDestroyed<String> ignoreSpellingCommandName(ASCIILiteral("ignoreSpelling"));
1122 if (commandName == ignoreSpellingCommandName)
1123 ++m_pendingLearnOrIgnoreWordMessageCount;
1125 m_process->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
1128 #if USE(TILED_BACKING_STORE)
1129 void WebPageProxy::commitPageTransitionViewport()
1134 process().send(Messages::WebPage::CommitPageTransitionViewport(), m_pageID);
1138 #if ENABLE(DRAG_SUPPORT)
1139 void WebPageProxy::dragEntered(DragData& dragData, const String& dragStorageName)
1141 SandboxExtension::Handle sandboxExtensionHandle;
1142 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1143 performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1146 void WebPageProxy::dragUpdated(DragData& dragData, const String& dragStorageName)
1148 SandboxExtension::Handle sandboxExtensionHandle;
1149 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1150 performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1153 void WebPageProxy::dragExited(DragData& dragData, const String& dragStorageName)
1155 SandboxExtension::Handle sandboxExtensionHandle;
1156 SandboxExtension::HandleArray sandboxExtensionHandleEmptyArray;
1157 performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionHandleEmptyArray);
1160 void WebPageProxy::performDrag(DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1162 performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle, sandboxExtensionsForUpload);
1165 void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData& dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle, const SandboxExtension::HandleArray& sandboxExtensionsForUpload)
1170 UNUSED_PARAM(dragStorageName);
1171 UNUSED_PARAM(sandboxExtensionHandle);
1172 UNUSED_PARAM(sandboxExtensionsForUpload);
1173 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData), m_pageID);
1175 m_process->send(Messages::WebPage::PerformDragControllerAction(action, dragData.clientPosition(), dragData.globalPosition(), dragData.draggingSourceOperationMask(), dragStorageName, dragData.flags(), sandboxExtensionHandle, sandboxExtensionsForUpload), m_pageID);
1179 void WebPageProxy::didPerformDragControllerAction(WebCore::DragSession dragSession)
1181 m_currentDragSession = dragSession;
1185 void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle)
1187 RefPtr<ShareableBitmap> dragImage = 0;
1188 if (!dragImageHandle.isNull()) {
1189 dragImage = ShareableBitmap::create(dragImageHandle);
1194 m_pageClient.startDrag(dragData, dragImage.release());
1198 void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
1202 m_process->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID);
1204 #endif // ENABLE(DRAG_SUPPORT)
1206 void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
1211 // NOTE: This does not start the responsiveness timer because mouse move should not indicate interaction.
1212 if (event.type() != WebEvent::MouseMove)
1213 m_process->responsivenessTimer()->start();
1215 if (m_processingMouseMoveEvent) {
1216 m_nextMouseMoveEvent = adoptPtr(new NativeWebMouseEvent(event));
1220 m_processingMouseMoveEvent = true;
1223 // <https://bugs.webkit.org/show_bug.cgi?id=57904> We need to keep track of the mouse down event in the case where we
1224 // display a popup menu for select elements. When the user changes the selected item,
1225 // we fake a mouse up event by using this stored down event. This event gets cleared
1226 // when the mouse up message is received from WebProcess.
1227 if (event.type() == WebEvent::MouseDown)
1228 m_currentlyProcessedMouseDownEvent = adoptPtr(new NativeWebMouseEvent(event));
1230 if (m_shouldSendEventsSynchronously) {
1231 bool handled = false;
1232 m_process->sendSync(Messages::WebPage::MouseEventSyncForTesting(event), Messages::WebPage::MouseEventSyncForTesting::Reply(handled), m_pageID);
1233 didReceiveEvent(event.type(), handled);
1235 m_process->send(Messages::WebPage::MouseEvent(event), m_pageID);
1238 #if MERGE_WHEEL_EVENTS
1239 static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1241 if (a.position() != b.position())
1243 if (a.globalPosition() != b.globalPosition())
1245 if (a.modifiers() != b.modifiers())
1247 if (a.granularity() != b.granularity())
1250 if (a.phase() != b.phase())
1252 if (a.momentumPhase() != b.momentumPhase())
1254 if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
1261 static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
1263 ASSERT(canCoalesce(a, b));
1265 FloatSize mergedDelta = a.delta() + b.delta();
1266 FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
1269 FloatSize mergedUnacceleratedScrollingDelta = a.unacceleratedScrollingDelta() + b.unacceleratedScrollingDelta();
1271 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());
1273 return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
1276 #endif // MERGE_WHEEL_EVENTS
1278 static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
1280 ASSERT(!queue.isEmpty());
1281 ASSERT(coalescedEvents.isEmpty());
1283 #if MERGE_WHEEL_EVENTS
1284 NativeWebWheelEvent firstEvent = queue.takeFirst();
1285 coalescedEvents.append(firstEvent);
1287 WebWheelEvent event = firstEvent;
1288 while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
1289 NativeWebWheelEvent firstEvent = queue.takeFirst();
1290 coalescedEvents.append(firstEvent);
1291 event = coalesce(event, firstEvent);
1296 while (!queue.isEmpty())
1297 coalescedEvents.append(queue.takeFirst());
1298 return coalescedEvents.last();
1302 void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
1304 #if ENABLE(ASYNC_SCROLLING)
1305 if (m_scrollingCoordinatorProxy && m_scrollingCoordinatorProxy->handleWheelEvent(platform(event)))
1312 if (!m_currentlyProcessedWheelEvents.isEmpty()) {
1313 m_wheelEventQueue.append(event);
1314 if (m_wheelEventQueue.size() < wheelEventQueueSizeThreshold)
1316 // The queue has too many wheel events, so push a new event.
1319 if (!m_wheelEventQueue.isEmpty()) {
1320 processNextQueuedWheelEvent();
1324 OwnPtr<Vector<NativeWebWheelEvent>> coalescedWheelEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
1325 coalescedWheelEvent->append(event);
1326 m_currentlyProcessedWheelEvents.append(coalescedWheelEvent.release());
1327 sendWheelEvent(event);
1330 void WebPageProxy::processNextQueuedWheelEvent()
1332 OwnPtr<Vector<NativeWebWheelEvent>> nextCoalescedEvent = adoptPtr(new Vector<NativeWebWheelEvent>);
1333 WebWheelEvent nextWheelEvent = coalescedWheelEvent(m_wheelEventQueue, *nextCoalescedEvent.get());
1334 m_currentlyProcessedWheelEvents.append(nextCoalescedEvent.release());
1335 sendWheelEvent(nextWheelEvent);
1338 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event)
1340 m_process->responsivenessTimer()->start();
1342 if (m_shouldSendEventsSynchronously) {
1343 bool handled = false;
1344 m_process->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
1345 didReceiveEvent(event.type(), handled);
1350 Messages::EventDispatcher::WheelEvent(
1353 shouldUseImplicitRubberBandControl() ? !m_backForwardList->backItem() : rubberBandsAtLeft(),
1354 shouldUseImplicitRubberBandControl() ? !m_backForwardList->forwardItem() : rubberBandsAtRight(),
1356 rubberBandsAtBottom()
1360 void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
1365 LOG(KeyHandling, "WebPageProxy::handleKeyboardEvent: %s", webKeyboardEventTypeString(event.type()));
1367 m_keyEventQueue.append(event);
1369 m_process->responsivenessTimer()->start();
1370 if (m_shouldSendEventsSynchronously) {
1371 bool handled = false;
1372 m_process->sendSync(Messages::WebPage::KeyEventSyncForTesting(event), Messages::WebPage::KeyEventSyncForTesting::Reply(handled), m_pageID);
1373 didReceiveEvent(event.type(), handled);
1374 } else if (m_keyEventQueue.size() == 1) // Otherwise, sent from DidReceiveEvent message handler.
1375 m_process->send(Messages::WebPage::KeyEvent(event), m_pageID);
1378 uint64_t WebPageProxy::generateNavigationID()
1380 return ++m_navigationID;
1383 #if ENABLE(NETSCAPE_PLUGIN_API)
1384 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)
1386 MESSAGE_CHECK_URL(urlString);
1388 newMimeType = mimeType.lower();
1389 pluginLoadPolicy = PluginModuleLoadNormally;
1391 PluginData::AllowedPluginTypes allowedPluginTypes = allowOnlyApplicationPlugins ? PluginData::OnlyApplicationPlugins : PluginData::AllPlugins;
1392 PluginModuleInfo plugin = m_process->context().pluginInfoStore().findPlugin(newMimeType, URL(URL(), urlString), allowedPluginTypes);
1394 pluginProcessToken = 0;
1398 pluginLoadPolicy = PluginInfoStore::defaultLoadPolicyForPlugin(plugin);
1401 RefPtr<ImmutableDictionary> pluginInformation = createPluginInformationDictionary(plugin, frameURLString, String(), pageURLString, String(), String());
1402 pluginLoadPolicy = m_loaderClient->pluginLoadPolicy(this, static_cast<PluginModuleLoadPolicy>(pluginLoadPolicy), pluginInformation.get(), unavailabilityDescription);
1404 UNUSED_PARAM(frameURLString);
1405 UNUSED_PARAM(pageURLString);
1406 UNUSED_PARAM(unavailabilityDescription);
1409 PluginProcessSandboxPolicy pluginProcessSandboxPolicy = PluginProcessSandboxPolicyNormal;
1410 switch (pluginLoadPolicy) {
1411 case PluginModuleLoadNormally:
1412 pluginProcessSandboxPolicy = PluginProcessSandboxPolicyNormal;
1414 case PluginModuleLoadUnsandboxed:
1415 pluginProcessSandboxPolicy = PluginProcessSandboxPolicyUnsandboxed;
1418 case PluginModuleBlocked:
1419 pluginProcessToken = 0;
1423 pluginProcessToken = PluginProcessManager::shared().pluginProcessToken(plugin, static_cast<PluginProcessType>(processType), pluginProcessSandboxPolicy);
1426 #endif // ENABLE(NETSCAPE_PLUGIN_API)
1428 #if ENABLE(TOUCH_EVENTS)
1430 bool WebPageProxy::shouldStartTrackingTouchEvents(const WebTouchEvent& touchStartEvent) const
1432 #if ENABLE(ASYNC_SCROLLING)
1433 for (auto& touchPoint : touchStartEvent.touchPoints()) {
1434 if (m_scrollingCoordinatorProxy->isPointInNonFastScrollableRegion(touchPoint.location()))
1440 UNUSED_PARAM(touchStartEvent);
1441 #endif // ENABLE(ASYNC_SCROLLING)
1445 void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
1450 if (event.type() == WebEvent::TouchStart)
1451 m_isTrackingTouchEvents = shouldStartTrackingTouchEvents(event);
1453 if (!m_isTrackingTouchEvents)
1456 // If the page is suspended, which should be the case during panning, pinching
1457 // and animation on the page itself (kinetic scrolling, tap to zoom) etc, then
1458 // we do not send any of the events to the page even if is has listeners.
1459 if (!m_isPageSuspended) {
1460 m_touchEventQueue.append(event);
1461 m_process->responsivenessTimer()->start();
1462 if (m_shouldSendEventsSynchronously) {
1463 bool handled = false;
1464 m_process->sendSync(Messages::WebPage::TouchEventSyncForTesting(event), Messages::WebPage::TouchEventSyncForTesting::Reply(handled), m_pageID);
1465 didReceiveEvent(event.type(), handled);
1467 m_process->send(Messages::WebPage::TouchEvent(event), m_pageID);
1469 if (m_touchEventQueue.isEmpty()) {
1470 bool isEventHandled = false;
1471 m_pageClient.doneWithTouchEvent(event, isEventHandled);
1473 // We attach the incoming events to the newest queued event so that all
1474 // the events are delivered in the correct order when the event is dequed.
1475 QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
1476 lastEvent.deferredTouchEvents.append(event);
1480 if (event.type() == WebEvent::TouchEnd || event.type() == WebEvent::TouchCancel)
1481 m_isTrackingTouchEvents = false;
1483 #endif // ENABLE(TOUCH_EVENTS)
1485 void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
1490 m_process->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
1493 void WebPageProxy::centerSelectionInVisibleArea()
1498 m_process->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
1501 void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
1506 auto transaction = m_pageLoadState.transaction();
1508 if (action == PolicyIgnore)
1509 m_pageLoadState.clearPendingAPIRequestURL(transaction);
1511 uint64_t downloadID = 0;
1512 if (action == PolicyDownload) {
1513 // Create a download proxy.
1514 DownloadProxy* download = m_process->context().createDownloadProxy();
1515 downloadID = download->downloadID();
1516 #if PLATFORM(EFL) || PLATFORM(GTK)
1517 // Our design does not suppport downloads without a WebPage.
1518 handleDownloadRequest(download);
1522 // If we received a policy decision while in decidePolicyForResponse the decision will
1523 // be sent back to the web process by decidePolicyForResponse.
1524 if (m_inDecidePolicyForResponseSync) {
1525 m_syncMimeTypePolicyActionIsValid = true;
1526 m_syncMimeTypePolicyAction = action;
1527 m_syncMimeTypePolicyDownloadID = downloadID;
1531 // If we received a policy decision while in decidePolicyForNavigationAction the decision will
1532 // be sent back to the web process by decidePolicyForNavigationAction.
1533 if (m_inDecidePolicyForNavigationAction) {
1534 m_syncNavigationActionPolicyActionIsValid = true;
1535 m_syncNavigationActionPolicyAction = action;
1536 m_syncNavigationActionPolicyDownloadID = downloadID;
1540 m_process->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, downloadID), m_pageID);
1543 void WebPageProxy::setUserAgent(const String& userAgent)
1545 if (m_userAgent == userAgent)
1547 m_userAgent = userAgent;
1551 m_process->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
1554 void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
1556 if (m_applicationNameForUserAgent == applicationName)
1559 m_applicationNameForUserAgent = applicationName;
1560 if (!m_customUserAgent.isEmpty())
1563 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1566 void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
1568 if (m_customUserAgent == customUserAgent)
1571 m_customUserAgent = customUserAgent;
1573 if (m_customUserAgent.isEmpty()) {
1574 setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
1578 setUserAgent(m_customUserAgent);
1581 void WebPageProxy::resumeActiveDOMObjectsAndAnimations()
1583 if (!isValid() || !m_isPageSuspended)
1586 m_isPageSuspended = false;
1588 m_process->send(Messages::WebPage::ResumeActiveDOMObjectsAndAnimations(), m_pageID);
1591 void WebPageProxy::suspendActiveDOMObjectsAndAnimations()
1593 if (!isValid() || m_isPageSuspended)
1596 m_isPageSuspended = true;
1598 m_process->send(Messages::WebPage::SuspendActiveDOMObjectsAndAnimations(), m_pageID);
1601 bool WebPageProxy::supportsTextEncoding() const
1603 // FIXME (118840): We should probably only support this for text documents, not all non-image documents.
1604 return m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
1607 void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
1609 if (m_customTextEncodingName == encodingName)
1611 m_customTextEncodingName = encodingName;
1615 m_process->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
1618 void WebPageProxy::terminateProcess()
1620 // NOTE: This uses a check of m_isValid rather than calling isValid() since
1621 // we want this to run even for pages being closed or that already closed.
1625 m_process->requestTermination();
1626 resetStateAfterProcessExited();
1630 PassRefPtr<API::Data> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback, void* /*context*/) const
1632 // FIXME: Return session state data for saving Page state.
1636 void WebPageProxy::restoreFromSessionStateData(API::Data*)
1638 // FIXME: Restore the Page from the passed in session state data.
1642 bool WebPageProxy::supportsTextZoom() const
1644 // FIXME (118840): This should also return false for standalone media and plug-in documents.
1645 if (!m_mainFrame || m_mainFrame->isDisplayingStandaloneImageDocument())
1651 void WebPageProxy::setTextZoomFactor(double zoomFactor)
1656 if (m_textZoomFactor == zoomFactor)
1659 m_textZoomFactor = zoomFactor;
1660 m_process->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID);
1663 void WebPageProxy::setPageZoomFactor(double zoomFactor)
1668 if (m_pageZoomFactor == zoomFactor)
1671 m_pageZoomFactor = zoomFactor;
1672 m_process->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID);
1675 void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
1680 if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
1683 m_pageZoomFactor = pageZoomFactor;
1684 m_textZoomFactor = textZoomFactor;
1685 m_process->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID);
1688 void WebPageProxy::scalePage(double scale, const IntPoint& origin)
1693 m_pageScaleFactor = scale;
1694 m_process->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
1697 void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
1699 if (m_intrinsicDeviceScaleFactor == scaleFactor)
1702 m_intrinsicDeviceScaleFactor = scaleFactor;
1705 m_drawingArea->deviceScaleFactorDidChange();
1708 void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
1713 m_process->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID);
1716 float WebPageProxy::deviceScaleFactor() const
1718 if (m_customDeviceScaleFactor)
1719 return m_customDeviceScaleFactor;
1720 return m_intrinsicDeviceScaleFactor;
1723 void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
1728 if (m_customDeviceScaleFactor == customScaleFactor)
1731 float oldScaleFactor = deviceScaleFactor();
1733 m_customDeviceScaleFactor = customScaleFactor;
1735 if (deviceScaleFactor() != oldScaleFactor)
1736 m_drawingArea->deviceScaleFactorDidChange();
1739 void WebPageProxy::setUseFixedLayout(bool fixed)
1744 // This check is fine as the value is initialized in the web
1745 // process as part of the creation parameters.
1746 if (fixed == m_useFixedLayout)
1749 m_useFixedLayout = fixed;
1751 m_fixedLayoutSize = IntSize();
1752 m_process->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
1755 void WebPageProxy::setFixedLayoutSize(const IntSize& size)
1760 if (size == m_fixedLayoutSize)
1763 m_fixedLayoutSize = size;
1764 m_process->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
1767 void WebPageProxy::listenForLayoutMilestones(WebCore::LayoutMilestones milestones)
1772 m_process->send(Messages::WebPage::ListenForLayoutMilestones(milestones), m_pageID);
1775 void WebPageProxy::setSuppressScrollbarAnimations(bool suppressAnimations)
1780 if (suppressAnimations == m_suppressScrollbarAnimations)
1783 m_suppressScrollbarAnimations = suppressAnimations;
1784 m_process->send(Messages::WebPage::SetSuppressScrollbarAnimations(suppressAnimations), m_pageID);
1787 bool WebPageProxy::rubberBandsAtLeft() const
1789 return m_rubberBandsAtLeft;
1792 void WebPageProxy::setRubberBandsAtLeft(bool rubberBandsAtLeft)
1794 m_rubberBandsAtLeft = rubberBandsAtLeft;
1797 bool WebPageProxy::rubberBandsAtRight() const
1799 return m_rubberBandsAtRight;
1802 void WebPageProxy::setRubberBandsAtRight(bool rubberBandsAtRight)
1804 m_rubberBandsAtRight = rubberBandsAtRight;
1807 bool WebPageProxy::rubberBandsAtTop() const
1809 return m_rubberBandsAtTop;
1812 void WebPageProxy::setRubberBandsAtTop(bool rubberBandsAtTop)
1814 m_rubberBandsAtTop = rubberBandsAtTop;
1817 bool WebPageProxy::rubberBandsAtBottom() const
1819 return m_rubberBandsAtBottom;
1822 void WebPageProxy::setRubberBandsAtBottom(bool rubberBandsAtBottom)
1824 m_rubberBandsAtBottom = rubberBandsAtBottom;
1827 void WebPageProxy::setBackgroundExtendsBeyondPage(bool backgroundExtendsBeyondPage)
1829 if (backgroundExtendsBeyondPage == m_backgroundExtendsBeyondPage)
1832 m_backgroundExtendsBeyondPage = backgroundExtendsBeyondPage;
1836 m_process->send(Messages::WebPage::SetBackgroundExtendsBeyondPage(backgroundExtendsBeyondPage), m_pageID);
1839 bool WebPageProxy::backgroundExtendsBeyondPage() const
1841 return m_backgroundExtendsBeyondPage;
1844 void WebPageProxy::setPaginationMode(WebCore::Pagination::Mode mode)
1846 if (mode == m_paginationMode)
1849 m_paginationMode = mode;
1853 m_process->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
1856 void WebPageProxy::setPaginationBehavesLikeColumns(bool behavesLikeColumns)
1858 if (behavesLikeColumns == m_paginationBehavesLikeColumns)
1861 m_paginationBehavesLikeColumns = behavesLikeColumns;
1865 m_process->send(Messages::WebPage::SetPaginationBehavesLikeColumns(behavesLikeColumns), m_pageID);
1868 void WebPageProxy::setPageLength(double pageLength)
1870 if (pageLength == m_pageLength)
1873 m_pageLength = pageLength;
1877 m_process->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
1880 void WebPageProxy::setGapBetweenPages(double gap)
1882 if (gap == m_gapBetweenPages)
1885 m_gapBetweenPages = gap;
1889 m_process->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
1892 void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
1894 m_pageScaleFactor = scaleFactor;
1897 void WebPageProxy::pageZoomFactorDidChange(double zoomFactor)
1899 m_pageZoomFactor = zoomFactor;
1902 void WebPageProxy::setMemoryCacheClientCallsEnabled(bool memoryCacheClientCallsEnabled)
1907 if (m_areMemoryCacheClientCallsEnabled == memoryCacheClientCallsEnabled)
1910 m_areMemoryCacheClientCallsEnabled = memoryCacheClientCallsEnabled;
1911 m_process->send(Messages::WebPage::SetMemoryCacheMessagesEnabled(memoryCacheClientCallsEnabled), m_pageID);
1914 void WebPageProxy::findStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
1916 if (string.isEmpty()) {
1917 didFindStringMatches(string, Vector<Vector<WebCore::IntRect>> (), 0);
1921 m_process->send(Messages::WebPage::FindStringMatches(string, options, maxMatchCount), m_pageID);
1924 void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
1926 m_process->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
1929 void WebPageProxy::getImageForFindMatch(int32_t matchIndex)
1931 m_process->send(Messages::WebPage::GetImageForFindMatch(matchIndex), m_pageID);
1934 void WebPageProxy::selectFindMatch(int32_t matchIndex)
1936 m_process->send(Messages::WebPage::SelectFindMatch(matchIndex), m_pageID);
1939 void WebPageProxy::hideFindUI()
1941 m_process->send(Messages::WebPage::HideFindUI(), m_pageID);
1944 void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
1949 m_process->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
1952 void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptValueCallback> prpCallback)
1954 RefPtr<ScriptValueCallback> callback = prpCallback;
1956 callback->invalidate();
1960 uint64_t callbackID = callback->callbackID();
1961 m_scriptValueCallbacks.set(callbackID, callback);
1962 m_process->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
1965 void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
1967 RefPtr<StringCallback> callback = prpCallback;
1969 callback->invalidate();
1973 uint64_t callbackID = callback->callbackID();
1974 m_stringCallbacks.set(callbackID, callback);
1975 m_process->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
1978 void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback)
1980 RefPtr<StringCallback> callback = prpCallback;
1982 callback->invalidate();
1986 uint64_t callbackID = callback->callbackID();
1987 m_loadDependentStringCallbackIDs.add(callbackID);
1988 m_stringCallbacks.set(callbackID, callback);
1989 m_process->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
1992 void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback)
1994 RefPtr<StringCallback> callback = prpCallback;
1996 callback->invalidate();
2000 uint64_t callbackID = callback->callbackID();
2001 m_loadDependentStringCallbackIDs.add(callbackID);
2002 m_stringCallbacks.set(callbackID, callback);
2003 m_process->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
2006 void WebPageProxy::getBytecodeProfile(PassRefPtr<StringCallback> prpCallback)
2008 RefPtr<StringCallback> callback = prpCallback;
2010 callback->invalidate();
2014 uint64_t callbackID = callback->callbackID();
2015 m_loadDependentStringCallbackIDs.add(callbackID);
2016 m_stringCallbacks.set(callbackID, callback);
2017 m_process->send(Messages::WebPage::GetBytecodeProfile(callbackID), m_pageID);
2021 void WebPageProxy::getContentsAsMHTMLData(PassRefPtr<DataCallback> prpCallback, bool useBinaryEncoding)
2023 RefPtr<DataCallback> callback = prpCallback;
2025 callback->invalidate();
2029 uint64_t callbackID = callback->callbackID();
2030 m_dataCallbacks.set(callbackID, callback);
2031 m_process->send(Messages::WebPage::GetContentsAsMHTMLData(callbackID, useBinaryEncoding), m_pageID);
2035 void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback)
2037 RefPtr<StringCallback> callback = prpCallback;
2039 callback->invalidate();
2043 uint64_t callbackID = callback->callbackID();
2044 m_stringCallbacks.set(callbackID, callback);
2045 m_process->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
2048 void WebPageProxy::getSelectionAsWebArchiveData(PassRefPtr<DataCallback> prpCallback)
2050 RefPtr<DataCallback> callback = prpCallback;
2052 callback->invalidate();
2056 uint64_t callbackID = callback->callbackID();
2057 m_dataCallbacks.set(callbackID, callback);
2058 m_process->send(Messages::WebPage::GetSelectionAsWebArchiveData(callbackID), m_pageID);
2061 void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
2063 RefPtr<DataCallback> callback = prpCallback;
2065 callback->invalidate();
2069 uint64_t callbackID = callback->callbackID();
2070 m_dataCallbacks.set(callbackID, callback);
2071 m_process->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
2074 void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, API::URL* resourceURL, PassRefPtr<DataCallback> prpCallback)
2076 RefPtr<DataCallback> callback = prpCallback;
2078 callback->invalidate();
2082 uint64_t callbackID = callback->callbackID();
2083 m_dataCallbacks.set(callbackID, callback);
2084 m_process->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID);
2087 void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
2089 RefPtr<DataCallback> callback = prpCallback;
2091 callback->invalidate();
2095 uint64_t callbackID = callback->callbackID();
2096 m_dataCallbacks.set(callbackID, callback);
2097 m_process->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
2100 void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
2102 RefPtr<VoidCallback> callback = prpCallback;
2104 callback->invalidate();
2108 uint64_t callbackID = callback->callbackID();
2109 m_voidCallbacks.set(callbackID, callback);
2110 m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
2111 m_process->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID);
2114 void WebPageProxy::preferencesDidChange()
2119 #if ENABLE(INSPECTOR_SERVER)
2120 if (m_preferences->developerExtrasEnabled())
2121 inspector()->enableRemoteInspection();
2124 m_process->pagePreferencesChanged(this);
2126 m_pageClient.preferencesDidChange();
2128 // FIXME: It probably makes more sense to send individual preference changes.
2129 // However, WebKitTestRunner depends on getting a preference change notification
2130 // even if nothing changed in UI process, so that overrides get removed.
2132 // Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
2133 m_process->send(Messages::WebPage::PreferencesDidChange(m_preferences->store()), m_pageID, m_isPerformingDOMPrintOperation ? IPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
2136 void WebPageProxy::didCreateMainFrame(uint64_t frameID)
2138 MESSAGE_CHECK(!m_mainFrame);
2139 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2141 m_mainFrame = WebFrameProxy::create(this, frameID);
2143 // Add the frame to the process wide map.
2144 m_process->frameCreated(frameID, m_mainFrame.get());
2147 void WebPageProxy::didCreateSubframe(uint64_t frameID)
2149 MESSAGE_CHECK(m_mainFrame);
2150 MESSAGE_CHECK(m_process->canCreateFrame(frameID));
2152 RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
2154 // Add the frame to the process wide map.
2155 m_process->frameCreated(frameID, subFrame.get());
2158 double WebPageProxy::estimatedProgress() const
2160 return m_pageLoadState.estimatedProgress();
2163 void WebPageProxy::didStartProgress()
2165 auto transaction = m_pageLoadState.transaction();
2166 m_pageLoadState.didStartProgress(transaction);
2168 m_pageLoadState.commitChanges();
2169 m_loaderClient->didStartProgress(this);
2172 void WebPageProxy::didChangeProgress(double value)
2174 auto transaction = m_pageLoadState.transaction();
2175 m_pageLoadState.didChangeProgress(transaction, value);
2177 m_pageLoadState.commitChanges();
2178 m_loaderClient->didChangeProgress(this);
2181 void WebPageProxy::didFinishProgress()
2183 auto transaction = m_pageLoadState.transaction();
2184 m_pageLoadState.didFinishProgress(transaction);
2186 m_pageLoadState.commitChanges();
2187 m_loaderClient->didFinishProgress(this);
2190 void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, const String& unreachableURL, IPC::MessageDecoder& decoder)
2192 auto transaction = m_pageLoadState.transaction();
2194 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2196 RefPtr<API::Object> userData;
2197 WebContextUserMessageDecoder messageDecoder(userData, process());
2198 if (!decoder.decode(messageDecoder))
2201 WebFrameProxy* frame = m_process->webFrame(frameID);
2202 MESSAGE_CHECK(frame);
2203 MESSAGE_CHECK_URL(url);
2205 if (frame->isMainFrame()) {
2206 recordNavigationSnapshot();
2207 m_pageLoadState.didStartProvisionalLoad(transaction, url, unreachableURL);
2210 frame->setUnreachableURL(unreachableURL);
2211 frame->didStartProvisionalLoad(url);
2213 m_pageLoadState.commitChanges();
2214 m_loaderClient->didStartProvisionalLoadForFrame(this, frame, navigationID, userData.get());
2217 void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& url, IPC::MessageDecoder& decoder)
2219 RefPtr<API::Object> userData;
2220 WebContextUserMessageDecoder messageDecoder(userData, process());
2221 if (!decoder.decode(messageDecoder))
2224 WebFrameProxy* frame = m_process->webFrame(frameID);
2225 MESSAGE_CHECK(frame);
2226 MESSAGE_CHECK_URL(url);
2228 auto transaction = m_pageLoadState.transaction();
2230 if (frame->isMainFrame())
2231 m_pageLoadState.didReceiveServerRedirectForProvisionalLoad(transaction, url);
2233 frame->didReceiveServerRedirectForProvisionalLoad(url);
2235 m_pageLoadState.commitChanges();
2236 m_loaderClient->didReceiveServerRedirectForProvisionalLoadForFrame(this, frame, navigationID, userData.get());
2239 void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError& error, IPC::MessageDecoder& decoder)
2241 RefPtr<API::Object> userData;
2242 WebContextUserMessageDecoder messageDecoder(userData, process());
2243 if (!decoder.decode(messageDecoder))
2246 WebFrameProxy* frame = m_process->webFrame(frameID);
2247 MESSAGE_CHECK(frame);
2249 auto transaction = m_pageLoadState.transaction();
2251 if (frame->isMainFrame())
2252 m_pageLoadState.didFailProvisionalLoad(transaction);
2254 frame->didFailProvisionalLoad();
2256 m_pageLoadState.commitChanges();
2257 m_loaderClient->didFailProvisionalLoadWithErrorForFrame(this, frame, navigationID, error, userData.get());
2260 void WebPageProxy::clearLoadDependentCallbacks()
2262 Vector<uint64_t> callbackIDsCopy;
2263 copyToVector(m_loadDependentStringCallbackIDs, callbackIDsCopy);
2264 m_loadDependentStringCallbackIDs.clear();
2266 for (size_t i = 0; i < callbackIDsCopy.size(); ++i) {
2267 RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackIDsCopy[i]);
2269 callback->invalidate();
2273 void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t opaqueFrameLoadType, const WebCore::CertificateInfo& certificateInfo, IPC::MessageDecoder& decoder)
2275 RefPtr<API::Object> userData;
2276 WebContextUserMessageDecoder messageDecoder(userData, process());
2277 if (!decoder.decode(messageDecoder))
2280 WebFrameProxy* frame = m_process->webFrame(frameID);
2281 MESSAGE_CHECK(frame);
2283 auto transaction = m_pageLoadState.transaction();
2285 if (frame->isMainFrame())
2286 m_pageLoadState.didCommitLoad(transaction);
2289 // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
2290 // FIXME: A load going on in one frame shouldn't affect text editing in other frames on the page.
2291 m_pageClient.resetSecureInputState();
2292 dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2293 m_pageClient.dismissDictionaryLookupPanel();
2296 clearLoadDependentCallbacks();
2298 frame->didCommitLoad(mimeType, certificateInfo);
2300 if (frame->isMainFrame()) {
2301 m_mainFrameHasCustomContentProvider = frameHasCustomContentProvider;
2303 if (m_mainFrameHasCustomContentProvider) {
2304 // Always assume that the main frame is pinned here, since the custom representation view will handle
2305 // any wheel events and dispatch them to the WKView when necessary.
2306 m_mainFrameIsPinnedToLeftSide = true;
2307 m_mainFrameIsPinnedToRightSide = true;
2308 m_mainFrameIsPinnedToTopSide = true;
2309 m_mainFrameIsPinnedToBottomSide = true;
2311 m_pageClient.didCommitLoadForMainFrame(mimeType, frameHasCustomContentProvider);
2314 // Even if WebPage has the default pageScaleFactor (and therefore doesn't reset it),
2315 // WebPageProxy's cache of the value can get out of sync (e.g. in the case where a
2316 // plugin is handling page scaling itself) so we should reset it to the default
2317 // for standard main frame loads.
2318 if (frame->isMainFrame() && static_cast<FrameLoadType>(opaqueFrameLoadType) == FrameLoadTypeStandard)
2319 m_pageScaleFactor = 1;
2321 m_pageLoadState.commitChanges();
2322 m_loaderClient->didCommitLoadForFrame(this, frame, navigationID, userData.get());
2325 void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2327 RefPtr<API::Object> userData;
2328 WebContextUserMessageDecoder messageDecoder(userData, process());
2329 if (!decoder.decode(messageDecoder))
2332 WebFrameProxy* frame = m_process->webFrame(frameID);
2333 MESSAGE_CHECK(frame);
2335 m_loaderClient->didFinishDocumentLoadForFrame(this, frame, userData.get());
2338 void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, IPC::MessageDecoder& decoder)
2340 RefPtr<API::Object> userData;
2341 WebContextUserMessageDecoder messageDecoder(userData, process());
2342 if (!decoder.decode(messageDecoder))
2345 WebFrameProxy* frame = m_process->webFrame(frameID);
2346 MESSAGE_CHECK(frame);
2348 auto transaction = m_pageLoadState.transaction();
2350 if (frame->isMainFrame())
2351 m_pageLoadState.didFinishLoad(transaction);
2353 frame->didFinishLoad();
2355 m_pageLoadState.commitChanges();
2356 m_loaderClient->didFinishLoadForFrame(this, frame, navigationID, userData.get());
2359 void WebPageProxy::didFailLoadForFrame(uint64_t frameID, uint64_t navigationID, const ResourceError& error, IPC::MessageDecoder& decoder)
2361 RefPtr<API::Object> userData;
2362 WebContextUserMessageDecoder messageDecoder(userData, process());
2363 if (!decoder.decode(messageDecoder))
2366 WebFrameProxy* frame = m_process->webFrame(frameID);
2367 MESSAGE_CHECK(frame);
2369 clearLoadDependentCallbacks();
2371 auto transaction = m_pageLoadState.transaction();
2373 if (frame->isMainFrame())
2374 m_pageLoadState.didFailLoad(transaction);
2376 frame->didFailLoad();
2378 m_pageLoadState.commitChanges();
2379 m_loaderClient->didFailLoadWithErrorForFrame(this, frame, navigationID, error, userData.get());
2382 void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t opaqueSameDocumentNavigationType, const String& url, IPC::MessageDecoder& decoder)
2384 RefPtr<API::Object> userData;
2385 WebContextUserMessageDecoder messageDecoder(userData, process());
2386 if (!decoder.decode(messageDecoder))
2389 WebFrameProxy* frame = m_process->webFrame(frameID);
2390 MESSAGE_CHECK(frame);
2391 MESSAGE_CHECK_URL(url);
2393 auto transaction = m_pageLoadState.transaction();
2395 if (frame->isMainFrame())
2396 m_pageLoadState.didSameDocumentNavigation(transaction, url);
2398 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2399 frame->didSameDocumentNavigation(url);
2401 m_pageLoadState.commitChanges();
2402 m_loaderClient->didSameDocumentNavigationForFrame(this, frame, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
2405 void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, IPC::MessageDecoder& decoder)
2407 RefPtr<API::Object> userData;
2408 WebContextUserMessageDecoder messageDecoder(userData, process());
2409 if (!decoder.decode(messageDecoder))
2412 WebFrameProxy* frame = m_process->webFrame(frameID);
2413 MESSAGE_CHECK(frame);
2415 auto transaction = m_pageLoadState.transaction();
2417 if (frame->isMainFrame())
2418 m_pageLoadState.setTitle(transaction, title);
2420 frame->didChangeTitle(title);
2422 m_pageLoadState.commitChanges();
2423 m_loaderClient->didReceiveTitleForFrame(this, title, frame, userData.get());
2426 void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2428 RefPtr<API::Object> userData;
2429 WebContextUserMessageDecoder messageDecoder(userData, process());
2430 if (!decoder.decode(messageDecoder))
2433 WebFrameProxy* frame = m_process->webFrame(frameID);
2434 MESSAGE_CHECK(frame);
2436 m_loaderClient->didFirstLayoutForFrame(this, frame, userData.get());
2439 void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2441 RefPtr<API::Object> userData;
2442 WebContextUserMessageDecoder messageDecoder(userData, process());
2443 if (!decoder.decode(messageDecoder))
2446 WebFrameProxy* frame = m_process->webFrame(frameID);
2447 MESSAGE_CHECK(frame);
2449 m_loaderClient->didFirstVisuallyNonEmptyLayoutForFrame(this, frame, userData.get());
2452 void WebPageProxy::didLayout(uint32_t layoutMilestones, IPC::MessageDecoder& decoder)
2454 RefPtr<API::Object> userData;
2455 WebContextUserMessageDecoder messageDecoder(userData, process());
2456 if (!decoder.decode(messageDecoder))
2459 m_loaderClient->didLayout(this, static_cast<LayoutMilestones>(layoutMilestones), userData.get());
2462 void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, IPC::MessageDecoder& decoder)
2464 RefPtr<API::Object> userData;
2465 WebContextUserMessageDecoder messageDecoder(userData, process());
2466 if (!decoder.decode(messageDecoder))
2469 WebFrameProxy* frame = m_process->webFrame(frameID);
2470 MESSAGE_CHECK(frame);
2472 m_loaderClient->didRemoveFrameFromHierarchy(this, frame, userData.get());
2475 void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2477 RefPtr<API::Object> userData;
2478 WebContextUserMessageDecoder messageDecoder(userData, process());
2479 if (!decoder.decode(messageDecoder))
2482 WebFrameProxy* frame = m_process->webFrame(frameID);
2483 MESSAGE_CHECK(frame);
2485 auto transaction = m_pageLoadState.transaction();
2486 m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
2488 m_pageLoadState.commitChanges();
2489 m_loaderClient->didDisplayInsecureContentForFrame(this, frame, userData.get());
2492 void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2494 RefPtr<API::Object> userData;
2495 WebContextUserMessageDecoder messageDecoder(userData, process());
2496 if (!decoder.decode(messageDecoder))
2499 WebFrameProxy* frame = m_process->webFrame(frameID);
2500 MESSAGE_CHECK(frame);
2502 auto transaction = m_pageLoadState.transaction();
2503 m_pageLoadState.didDisplayOrRunInsecureContent(transaction);
2505 m_pageLoadState.commitChanges();
2506 m_loaderClient->didRunInsecureContentForFrame(this, frame, userData.get());
2509 void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, IPC::MessageDecoder& decoder)
2511 RefPtr<API::Object> userData;
2512 WebContextUserMessageDecoder messageDecoder(userData, process());
2513 if (!decoder.decode(messageDecoder))
2516 WebFrameProxy* frame = m_process->webFrame(frameID);
2517 MESSAGE_CHECK(frame);
2519 m_loaderClient->didDetectXSSForFrame(this, frame, userData.get());
2522 void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
2524 WebFrameProxy* frame = m_process->webFrame(frameID);
2525 MESSAGE_CHECK(frame);
2527 frame->setIsFrameSet(value);
2528 if (frame->isMainFrame())
2529 m_frameSetLargestFrame = value ? m_mainFrame : 0;
2532 void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, const NavigationActionData& navigationActionData, uint64_t originatingFrameID, const WebCore::ResourceRequest& originalRequest, const ResourceRequest& request, uint64_t listenerID, IPC::MessageDecoder& decoder, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
2534 RefPtr<API::Object> userData;
2535 WebContextUserMessageDecoder messageDecoder(userData, process());
2536 if (!decoder.decode(messageDecoder))
2539 auto transaction = m_pageLoadState.transaction();
2541 if (request.url() != m_pageLoadState.pendingAPIRequestURL())
2542 m_pageLoadState.clearPendingAPIRequestURL(transaction);
2544 WebFrameProxy* frame = m_process->webFrame(frameID);
2545 MESSAGE_CHECK(frame);
2546 MESSAGE_CHECK_URL(request.url());
2547 MESSAGE_CHECK_URL(originalRequest.url());
2549 WebFrameProxy* originatingFrame = m_process->webFrame(originatingFrameID);
2551 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2553 ASSERT(!m_inDecidePolicyForNavigationAction);
2555 m_inDecidePolicyForNavigationAction = true;
2556 m_syncNavigationActionPolicyActionIsValid = false;
2558 m_policyClient->decidePolicyForNavigationAction(this, frame, navigationActionData, originatingFrame, originalRequest, request, std::move(listener), userData.get());
2560 m_inDecidePolicyForNavigationAction = false;
2562 // Check if we received a policy decision already. If we did, we can just pass it back.
2563 receivedPolicyAction = m_syncNavigationActionPolicyActionIsValid;
2564 if (m_syncNavigationActionPolicyActionIsValid) {
2565 policyAction = m_syncNavigationActionPolicyAction;
2566 downloadID = m_syncNavigationActionPolicyDownloadID;
2570 void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, const NavigationActionData& navigationActionData, const ResourceRequest& request, const String& frameName, uint64_t listenerID, IPC::MessageDecoder& decoder)
2572 RefPtr<API::Object> userData;
2573 WebContextUserMessageDecoder messageDecoder(userData, process());
2574 if (!decoder.decode(messageDecoder))
2577 WebFrameProxy* frame = m_process->webFrame(frameID);
2578 MESSAGE_CHECK(frame);
2579 MESSAGE_CHECK_URL(request.url());
2581 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2583 m_policyClient->decidePolicyForNewWindowAction(this, frame, navigationActionData, request, frameName, std::move(listener), userData.get());
2586 void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, uint64_t listenerID, IPC::MessageDecoder& decoder)
2588 RefPtr<API::Object> userData;
2589 WebContextUserMessageDecoder messageDecoder(userData, process());
2590 if (!decoder.decode(messageDecoder))
2593 WebFrameProxy* frame = m_process->webFrame(frameID);
2594 MESSAGE_CHECK(frame);
2595 MESSAGE_CHECK_URL(request.url());
2596 MESSAGE_CHECK_URL(response.url());
2598 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
2600 m_policyClient->decidePolicyForResponse(this, frame, response, request, canShowMIMEType, std::move(listener), userData.get());
2603 void WebPageProxy::decidePolicyForResponseSync(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, bool canShowMIMEType, uint64_t listenerID, IPC::MessageDecoder& decoder, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
2605 ASSERT(!m_inDecidePolicyForResponseSync);
2607 m_inDecidePolicyForResponseSync = true;
2608 m_decidePolicyForResponseRequest = &request;
2609 m_syncMimeTypePolicyActionIsValid = false;
2611 decidePolicyForResponse(frameID, response, request, canShowMIMEType, listenerID, decoder);
2613 m_inDecidePolicyForResponseSync = false;
2614 m_decidePolicyForResponseRequest = 0;
2616 // Check if we received a policy decision already. If we did, we can just pass it back.
2617 receivedPolicyAction = m_syncMimeTypePolicyActionIsValid;
2618 if (m_syncMimeTypePolicyActionIsValid) {
2619 policyAction = m_syncMimeTypePolicyAction;
2620 downloadID = m_syncMimeTypePolicyDownloadID;
2624 void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError& error, IPC::MessageDecoder& decoder)
2626 RefPtr<API::Object> userData;
2627 WebContextUserMessageDecoder messageDecoder(userData, process());
2628 if (!decoder.decode(messageDecoder))
2631 WebFrameProxy* frame = m_process->webFrame(frameID);
2632 MESSAGE_CHECK(frame);
2634 m_policyClient->unableToImplementPolicy(this, frame, error, userData.get());
2639 void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const Vector<std::pair<String, String>>& textFieldValues, uint64_t listenerID, IPC::MessageDecoder& decoder)
2641 RefPtr<API::Object> userData;
2642 WebContextUserMessageDecoder messageDecoder(userData, process());
2643 if (!decoder.decode(messageDecoder))
2646 WebFrameProxy* frame = m_process->webFrame(frameID);
2647 MESSAGE_CHECK(frame);
2649 WebFrameProxy* sourceFrame = m_process->webFrame(sourceFrameID);
2650 MESSAGE_CHECK(sourceFrame);
2652 RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
2653 if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues, userData.get(), listener.get()))
2654 listener->continueSubmission();
2659 void WebPageProxy::createNewPage(const ResourceRequest& request, const WindowFeatures& windowFeatures, uint32_t opaqueModifiers, int32_t opaqueMouseButton, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
2661 RefPtr<WebPageProxy> newPage = m_uiClient->createNewPage(this, request, windowFeatures, static_cast<WebEvent::Modifiers>(opaqueModifiers), static_cast<WebMouseEvent::Button>(opaqueMouseButton));
2667 newPageID = newPage->pageID();
2668 newPageParameters = newPage->creationParameters();
2669 process().context().storageManager().cloneSessionStorageNamespace(m_pageID, newPage->pageID());
2672 void WebPageProxy::showPage()
2674 m_uiClient->showPage(this);
2677 void WebPageProxy::closePage(bool stopResponsivenessTimer)
2679 if (stopResponsivenessTimer)
2680 m_process->responsivenessTimer()->stop();
2682 m_pageClient.clearAllEditCommands();
2683 m_uiClient->close(this);
2686 void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptAlert::DelayedReply> reply)
2688 WebFrameProxy* frame = m_process->webFrame(frameID);
2689 MESSAGE_CHECK(frame);
2691 // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
2692 m_process->responsivenessTimer()->stop();
2694 m_uiClient->runJavaScriptAlert(this, message, frame, [reply]{ reply->send(); });
2697 void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, RefPtr<Messages::WebPageProxy::RunJavaScriptConfirm::DelayedReply> reply)
2699 WebFrameProxy* frame = m_process->webFrame(frameID);
2700 MESSAGE_CHECK(frame);
2702 // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
2703 m_process->responsivenessTimer()->stop();
2705 m_uiClient->runJavaScriptConfirm(this, message, frame, [reply](bool result) { reply->send(result); });
2708 void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, RefPtr<Messages::WebPageProxy::RunJavaScriptPrompt::DelayedReply> reply)
2710 WebFrameProxy* frame = m_process->webFrame(frameID);
2711 MESSAGE_CHECK(frame);
2713 // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
2714 m_process->responsivenessTimer()->stop();
2716 m_uiClient->runJavaScriptPrompt(this, message, defaultValue, frame, [reply](const String& result) { reply->send(result); });
2719 void WebPageProxy::shouldInterruptJavaScript(bool& result)
2721 // Since shouldInterruptJavaScript() can spin a nested run loop we need to turn off the responsiveness timer.
2722 m_process->responsivenessTimer()->stop();
2724 result = m_uiClient->shouldInterruptJavaScript(this);
2727 void WebPageProxy::setStatusText(const String& text)
2729 m_uiClient->setStatusText(this, text);
2732 void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t opaqueModifiers, IPC::MessageDecoder& decoder)
2734 RefPtr<API::Object> userData;
2735 WebContextUserMessageDecoder messageDecoder(userData, process());
2736 if (!decoder.decode(messageDecoder))
2739 WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
2741 m_uiClient->mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());
2744 void WebPageProxy::connectionWillOpen(IPC::Connection* connection)
2746 ASSERT(connection == m_process->connection());
2748 m_visitedLinkProvider->addProcess(m_process.get());
2750 m_process->context().storageManager().setAllowedSessionStorageNamespaceConnection(m_pageID, connection);
2753 void WebPageProxy::connectionWillClose(IPC::Connection* connection)
2755 ASSERT_UNUSED(connection, connection == m_process->connection());
2757 m_process->context().storageManager().setAllowedSessionStorageNamespaceConnection(m_pageID, 0);
2760 #if ENABLE(NETSCAPE_PLUGIN_API)
2761 void WebPageProxy::unavailablePluginButtonClicked(uint32_t opaquePluginUnavailabilityReason, const String& mimeType, const String& pluginURLString, const String& pluginspageAttributeURLString, const String& frameURLString, const String& pageURLString)
2763 MESSAGE_CHECK_URL(pluginURLString);
2764 MESSAGE_CHECK_URL(pluginspageAttributeURLString);
2765 MESSAGE_CHECK_URL(frameURLString);
2766 MESSAGE_CHECK_URL(pageURLString);
2768 RefPtr<ImmutableDictionary> pluginInformation;
2769 String newMimeType = mimeType;
2770 PluginModuleInfo plugin = m_process->context().pluginInfoStore().findPlugin(newMimeType, URL(URL(), pluginURLString));
2771 pluginInformation = createPluginInformationDictionary(plugin, frameURLString, mimeType, pageURLString, pluginspageAttributeURLString, pluginURLString);
2773 WKPluginUnavailabilityReason pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
2774 switch (static_cast<RenderEmbeddedObject::PluginUnavailabilityReason>(opaquePluginUnavailabilityReason)) {
2775 case RenderEmbeddedObject::PluginMissing:
2776 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginMissing;
2778 case RenderEmbeddedObject::InsecurePluginVersion:
2779 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonInsecurePluginVersion;
2781 case RenderEmbeddedObject::PluginCrashed:
2782 pluginUnavailabilityReason = kWKPluginUnavailabilityReasonPluginCrashed;
2784 case RenderEmbeddedObject::PluginBlockedByContentSecurityPolicy:
2785 ASSERT_NOT_REACHED();
2788 m_uiClient->unavailablePluginButtonClicked(this, pluginUnavailabilityReason, pluginInformation.get());
2790 #endif // ENABLE(NETSCAPE_PLUGIN_API)
2793 void WebPageProxy::webGLPolicyForURL(const String& url, uint32_t& loadPolicy)
2795 loadPolicy = static_cast<uint32_t>(m_loaderClient->webGLLoadPolicy(this, url));
2798 void WebPageProxy::resolveWebGLPolicyForURL(const String& url, uint32_t& loadPolicy)
2800 loadPolicy = static_cast<uint32_t>(m_loaderClient->resolveWebGLLoadPolicy(this, url));
2802 #endif // ENABLE(WEBGL)
2804 void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
2806 m_uiClient->setToolbarsAreVisible(this, toolbarsAreVisible);
2809 void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
2811 toolbarsAreVisible = m_uiClient->toolbarsAreVisible(this);
2814 void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
2816 m_uiClient->setMenuBarIsVisible(this, menuBarIsVisible);
2819 void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
2821 menuBarIsVisible = m_uiClient->menuBarIsVisible(this);
2824 void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
2826 m_uiClient->setStatusBarIsVisible(this, statusBarIsVisible);
2829 void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
2831 statusBarIsVisible = m_uiClient->statusBarIsVisible(this);
2834 void WebPageProxy::setIsResizable(bool isResizable)
2836 m_uiClient->setIsResizable(this, isResizable);
2839 void WebPageProxy::getIsResizable(bool& isResizable)
2841 isResizable = m_uiClient->isResizable(this);
2844 void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
2846 m_uiClient->setWindowFrame(this, m_pageClient.convertToDeviceSpace(newWindowFrame));
2849 void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
2851 newWindowFrame = m_pageClient.convertToUserSpace(m_uiClient->windowFrame(this));
2854 void WebPageProxy::screenToRootView(const IntPoint& screenPoint, IntPoint& windowPoint)
2856 windowPoint = m_pageClient.screenToRootView(screenPoint);
2859 void WebPageProxy::rootViewToScreen(const IntRect& viewRect, IntRect& result)
2861 result = m_pageClient.rootViewToScreen(viewRect);
2864 void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
2866 WebFrameProxy* frame = m_process->webFrame(frameID);
2867 MESSAGE_CHECK(frame);
2869 // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2870 m_process->responsivenessTimer()->stop();
2872 shouldClose = m_uiClient->runBeforeUnloadConfirmPanel(this, message, frame);
2875 #if USE(TILED_BACKING_STORE)
2876 void WebPageProxy::pageDidRequestScroll(const IntPoint& point)
2878 m_pageClient.pageDidRequestScroll(point);
2881 void WebPageProxy::pageTransitionViewportReady()
2883 m_pageClient.pageTransitionViewportReady();
2886 void WebPageProxy::didRenderFrame(const WebCore::IntSize& contentsSize, const WebCore::IntRect& coveredRect)
2888 m_pageClient.didRenderFrame(contentsSize, coveredRect);
2893 void WebPageProxy::didChangeViewportProperties(const ViewportAttributes& attr)
2895 m_pageClient.didChangeViewportProperties(attr);
2898 void WebPageProxy::pageDidScroll()
2900 m_uiClient->pageDidScroll(this);
2902 dismissCorrectionPanel(ReasonForDismissingAlternativeTextIgnored);
2906 void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
2908 if (m_openPanelResultListener) {
2909 m_openPanelResultListener->invalidate();
2910 m_openPanelResultListener = 0;
2913 WebFrameProxy* frame = m_process->webFrame(frameID);
2914 MESSAGE_CHECK(frame);
2916 RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
2917 m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
2919 // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
2920 m_process->responsivenessTimer()->stop();
2922 if (!m_uiClient->runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
2923 didCancelForOpenPanel();
2926 void WebPageProxy::printFrame(uint64_t frameID)
2928 ASSERT(!m_isPerformingDOMPrintOperation);
2929 m_isPerformingDOMPrintOperation = true;
2931 WebFrameProxy* frame = m_process->webFrame(frameID);
2932 MESSAGE_CHECK(frame);
2934 m_uiClient->printFrame(this, frame);
2936 endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
2937 m_isPerformingDOMPrintOperation = false;
2940 void WebPageProxy::printMainFrame()
2942 printFrame(m_mainFrame->frameID());
2945 void WebPageProxy::setMediaVolume(float volume)
2947 if (volume == m_mediaVolume)
2950 m_mediaVolume = volume;
2955 m_process->send(Messages::WebPage::SetMediaVolume(volume), m_pageID);
2958 void WebPageProxy::setMayStartMediaWhenInWindow(bool mayStartMedia)
2960 if (mayStartMedia == m_mayStartMediaWhenInWindow)
2963 m_mayStartMediaWhenInWindow = mayStartMedia;
2968 process().send(Messages::WebPage::SetMayStartMediaWhenInWindow(mayStartMedia), m_pageID);
2971 #if PLATFORM(EFL) || PLATFORM(GTK)
2972 void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
2974 m_pageClient.handleDownloadRequest(download);
2976 #endif // PLATFORM(EFL) || PLATFORM(GTK)
2979 void WebPageProxy::didChangeContentSize(const IntSize& size)
2981 m_pageClient.didChangeContentSize(size);
2985 #if ENABLE(INPUT_TYPE_COLOR)
2986 void WebPageProxy::showColorPicker(const WebCore::Color& initialColor, const IntRect& elementRect)
2988 #if ENABLE(INPUT_TYPE_COLOR_POPOVER)
2989 // A new popover color well needs to be created (and the previous one destroyed) for
2990 // each activation of a color element.
2994 m_colorPicker = m_pageClient.createColorPicker(this, initialColor, elementRect);
2995 m_colorPicker->showColorPicker(initialColor);
2998 void WebPageProxy::setColorPickerColor(const WebCore::Color& color)
3000 ASSERT(m_colorPicker);
3002 m_colorPicker->setSelectedColor(color);
3005 void WebPageProxy::endColorPicker()
3007 ASSERT(m_colorPicker);
3009 m_colorPicker->endPicker();
3012 void WebPageProxy::didChooseColor(const WebCore::Color& color)
3017 m_process->send(Messages::WebPage::DidChooseColor(color), m_pageID);
3020 void WebPageProxy::didEndColorPicker()
3025 if (m_colorPicker) {
3026 m_colorPicker->invalidate();
3027 m_colorPicker = nullptr;
3030 m_process->send(Messages::WebPage::DidEndColorPicker(), m_pageID);
3034 void WebPageProxy::didDraw()
3036 m_uiClient->didDraw(this);
3041 #if ENABLE(INSPECTOR)
3043 WebInspectorProxy* WebPageProxy::inspector()
3045 if (isClosed() || !isValid())
3047 return m_inspector.get();
3052 #if ENABLE(FULLSCREEN_API)
3053 WebFullScreenManagerProxy* WebPageProxy::fullScreenManager()
3055 return m_fullScreenManager.get();
3060 RefPtr<WebVideoFullscreenManagerProxy> WebPageProxy::videoFullscreenManager()
3062 return m_videoFullscreenManager;
3068 void WebPageProxy::backForwardAddItem(uint64_t itemID)
3070 m_backForwardList->addItem(m_process->webBackForwardItem(itemID));
3073 void WebPageProxy::backForwardGoToItem(uint64_t itemID, SandboxExtension::Handle& sandboxExtensionHandle)
3075 WebBackForwardListItem* item = m_process->webBackForwardItem(itemID);
3079 bool createdExtension = maybeInitializeSandboxExtensionHandle(URL(URL(), item->url()), sandboxExtensionHandle);
3080 if (createdExtension)
3081 m_process->willAcquireUniversalFileReadSandboxExtension();
3082 m_backForwardList->goToItem(item);
3085 void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
3087 WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
3088 itemID = item ? item->itemID() : 0;
3091 void WebPageProxy::backForwardBackListCount(int32_t& count)
3093 count = m_backForwardList->backListCount();
3096 void WebPageProxy::backForwardForwardListCount(int32_t& count)
3098 count = m_backForwardList->forwardListCount();
3101 void WebPageProxy::editorStateChanged(const EditorState& editorState)
3104 bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
3105 bool closedComposition = !editorState.shouldIgnoreCompositionSelectionChange && !editorState.hasComposition && (m_editorState.hasComposition || m_temporarilyClosedComposition);
3106 m_temporarilyClosedComposition = editorState.shouldIgnoreCompositionSelectionChange && (m_temporarilyClosedComposition || m_editorState.hasComposition) && !editorState.hasComposition;
3109 m_editorState = editorState;
3112 // Selection being none is a temporary state when editing. Flipping secure input state too quickly was causing trouble (not fully understood).
3113 if (couldChangeSecureInputState && !editorState.selectionIsNone)
3114 m_pageClient.updateSecureInputState();
3116 if (editorState.shouldIgnoreCompositionSelectionChange)
3119 if (closedComposition)
3120 m_pageClient.notifyInputContextAboutDiscardedComposition();
3121 if (editorState.hasComposition) {
3122 // Abandon the current inline input session if selection changed for any other reason but an input method changing the composition.
3123 // FIXME: This logic should be in WebCore, no need to round-trip to UI process to cancel the composition.
3124 cancelComposition();
3125 m_pageClient.notifyInputContextAboutDiscardedComposition();
3129 // We need to notify the client on iOS to make sure the selection is redrawn.
3130 notifyRevealedSelection();
3133 #elif PLATFORM(EFL) || PLATFORM(GTK)
3134 m_pageClient.updateTextInputState();
3140 void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
3142 registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
3145 void WebPageProxy::canUndoRedo(uint32_t action, bool& result)
3147 result = m_pageClient.canUndoRedo(static_cast<UndoOrRedo>(action));
3150 void WebPageProxy::executeUndoRedo(uint32_t action, bool& result)
3152 m_pageClient.executeUndoRedo(static_cast<UndoOrRedo>(action));
3156 void WebPageProxy::clearAllEditCommands()
3158 m_pageClient.clearAllEditCommands();
3161 void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
3163 m_findClient.didCountStringMatches(this, string, matchCount);
3166 void WebPageProxy::didGetImageForFindMatch(const ShareableBitmap::Handle& contentImageHandle, uint32_t matchIndex)
3168 m_findMatchesClient.didGetImageForMatchResult(this, WebImage::create(ShareableBitmap::create(contentImageHandle)).get(), matchIndex);
3171 void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
3173 RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
3174 m_pageClient.setFindIndicator(findIndicator.release(), fadeOut, animate);
3177 void WebPageProxy::didFindString(const String& string, uint32_t matchCount)
3179 m_findClient.didFindString(this, string, matchCount);
3182 void WebPageProxy::didFindStringMatches(const String& string, Vector<Vector<WebCore::IntRect>> matchRects, int32_t firstIndexAfterSelection)
3184 Vector<RefPtr<API::Object>> matches;
3185 matches.reserveInitialCapacity(matchRects.size());
3187 for (const auto& rects : matchRects) {
3188 Vector<RefPtr<API::Object>> apiRects;
3189 apiRects.reserveInitialCapacity(rects.size());
3191 for (const auto& rect : rects)
3192 apiRects.uncheckedAppend(API::Rect::create(toAPI(rect)));
3194 matches.uncheckedAppend(API::Array::create(std::move(apiRects)));
3197 m_findMatchesClient.didFindStringMatches(this, string, API::Array::create(std::move(matches)).get(), firstIndexAfterSelection);
3200 void WebPageProxy::didFailToFindString(const String& string)
3202 m_findClient.didFailToFindString(this, string);
3205 bool WebPageProxy::sendMessage(std::unique_ptr<IPC::MessageEncoder> encoder, unsigned messageSendFlags)
3207 return m_process->sendMessage(std::move(encoder), messageSendFlags);
3210 IPC::Connection* WebPageProxy::messageSenderConnection()
3212 return m_process->connection();
3215 uint64_t WebPageProxy::messageSenderDestinationID()
3220 void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
3222 m_process->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
3225 void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
3227 m_process->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
3230 NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent()
3232 return m_currentlyProcessedMouseDownEvent.get();
3235 void WebPageProxy::postMessageToInjectedBundle(const String& messageName, API::Object* messageBody)
3237 process().send(Messages::WebPage::PostInjectedBundleMessage(messageName, WebContextUserMessageEncoder(messageBody, process())), m_pageID);
3241 void WebPageProxy::failedToShowPopupMenu()
3243 m_process->send(Messages::WebPage::FailedToShowPopupMenu(), m_pageID);
3247 void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
3249 if (m_activePopupMenu) {
3251 m_uiPopupMenuClient.hidePopupMenu(this);
3253 m_activePopupMenu->hidePopupMenu();
3255 m_activePopupMenu->invalidate();
3256 m_activePopupMenu = 0;
3259 m_activePopupMenu = m_pageClient.createPopupMenuProxy(this);
3261 if (!m_activePopupMenu)
3264 // Since showPopupMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3265 m_process->responsivenessTimer()->stop();
3269 m_uiPopupMenuClient.showPopupMenu(this, m_activePopupMenu.get(), rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, selectedIndex);
3271 RefPtr<WebPopupMenuProxy> protectedActivePopupMenu = m_activePopupMenu;
3273 protectedActivePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, data, selectedIndex);
3275 // Since Efl doesn't use a nested mainloop to show the popup and get the answer, we need to keep the client pointer valid.
3276 // FIXME: The above comment doesn't make any sense since this code is compiled out for EFL.
3277 protectedActivePopupMenu->invalidate();
3278 protectedActivePopupMenu = 0;
3282 void WebPageProxy::hidePopupMenu()
3284 if (!m_activePopupMenu)
3288 m_uiPopupMenuClient.hidePopupMenu(this);
3290 m_activePopupMenu->hidePopupMenu();
3292 m_activePopupMenu->invalidate();
3293 m_activePopupMenu = 0;
3296 #if ENABLE(CONTEXT_MENUS)
3297 void WebPageProxy::showContextMenu(const IntPoint& menuLocation, const ContextMenuContextData& contextMenuContextData, const Vector<WebContextMenuItemData>& proposedItems, IPC::MessageDecoder& decoder)
3299 internalShowContextMenu(menuLocation, contextMenuContextData, proposedItems, decoder);
3301 // No matter the result of internalShowContextMenu, always notify the WebProcess that the menu is hidden so it starts handling mouse events again.
3302 m_process->send(Messages::WebPage::ContextMenuHidden(), m_pageID);
3305 void WebPageProxy::internalShowContextMenu(const IntPoint& menuLocation, const ContextMenuContextData& contextMenuContextData, const Vector<WebContextMenuItemData>& proposedItems, IPC::MessageDecoder& decoder)
3307 RefPtr<API::Object> userData;
3308 WebContextUserMessageDecoder messageDecoder(userData, process());
3309 if (!decoder.decode(messageDecoder))
3312 m_activeContextMenuContextData = contextMenuContextData;
3314 if (!m_contextMenuClient.hideContextMenu(this) && m_activeContextMenu) {
3315 m_activeContextMenu->hideContextMenu();
3316 m_activeContextMenu = 0;
3319 m_activeContextMenu = m_pageClient.createContextMenuProxy(this);
3320 if (!m_activeContextMenu)
3323 // Since showContextMenu() can spin a nested run loop we need to turn off the responsiveness timer.
3324 m_process->responsivenessTimer()->stop();
3326 // Unless this is an image control, give the PageContextMenuClient one last swipe at changing the menu.
3327 Vector<WebContextMenuItemData> items;
3328 bool useProposedItems = true;
3329 bool askClientToChangeMenu = true;
3330 #if ENABLE(IMAGE_CONTROLS)
3331 if (!contextMenuContextData.controlledImageHandle().isNull())
3332 askClientToChangeMenu = false;
3335 if (askClientToChangeMenu && m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, contextMenuContextData.webHitTestResultData(), userData.get()))
3336 useProposedItems = false;
3338 const Vector<WebContextMenuItemData>& itemsToShow = useProposedItems ? proposedItems : items;
3339 if (!m_contextMenuClient.showContextMenu(this, menuLocation, itemsToShow))
3340 m_activeContextMenu->showContextMenu(menuLocation, itemsToShow, contextMenuContextData);
3342 m_contextMenuClient.contextMenuDismissed(this);
3345 #if ENABLE(IMAGE_CONTROLS)
3346 void WebPageProxy::replaceControlledImage(PassRefPtr<ShareableBitmap> newBitmap)
3348 RefPtr<ShareableBitmap> bitmap = newBitmap;
3349 ShareableBitmap::Handle bitmapHandle;
3350 bitmap->createHandle(bitmapHandle);
3351 m_process->send(Messages::WebPage::ReplaceControlledImage(bitmapHandle), m_pageID);
3355 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
3357 // Application custom items don't need to round-trip through to WebCore in the WebProcess.
3358 if (item.action() >= ContextMenuItemBaseApplicationTag) {
3359 m_contextMenuClient.customContextMenuItemSelected(this, item);
3364 if (item.action() == ContextMenuItemTagSmartCopyPaste) {
3365 setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
3368 if (item.action() == ContextMenuItemTagSmartQuotes) {
3369 TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
3370 m_process->updateTextCheckerState();
3373 if (item.action() == ContextMenuItemTagSmartDashes) {
3374 TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
3375 m_process->updateTextCheckerState();
3378 if (item.action() == ContextMenuItemTagSmartLinks) {
3379 TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
3380 m_process->updateTextCheckerState();
3383 if (item.action() == ContextMenuItemTagTextReplacement) {
3384 TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
3385 m_process->updateTextCheckerState();
3388 if (item.action() == ContextMenuItemTagCorrectSpellingAutomatically) {
3389 TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
3390 m_process->updateTextCheckerState();
3393 if (item.action() == ContextMenuItemTagShowSubstitutions) {
3394 TextChecker::toggleSubstitutionsPanelIsShowing();
3398 if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
3399 m_process->context().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteImageURL));
3402 if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
3403 m_process->context().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteLinkURL));
3406 if (item.action() == ContextMenuItemTagDownloadMediaToDisk) {
3407 m_process->context().download(this, URL(URL(), m_activeContextMenuContextData.webHitTestResultData().absoluteMediaURL));
3410 if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) {
3411 TextChecker::setContinuousSpellCheckingEnabled(!TextChecker::state().isContinuousSpellCheckingEnabled);
3412 m_process->updateTextCheckerState();
3415 if (item.action() == ContextMenuItemTagCheckGrammarWithSpelling) {
3416 TextChecker::setGrammarCheckingEnabled(!TextChecker::state().isGrammarCheckingEnabled);
3417 m_process->updateTextCheckerState();
3420 if (item.action() == ContextMenuItemTagShowSpellingPanel) {
3421 if (!TextChecker::spellingUIIsShowing())
3422 advanceToNextMisspelling(true);
3423 TextChecker::toggleSpellingUIIsShowing();
3426 if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
3427 ++m_pendingLearnOrIgnoreWordMessageCount;
3429 m_process->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID);
3431 #endif // ENABLE(CONTEXT_MENUS)
3433 void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
3438 #if ENABLE(WEB_PROCESS_SANDBOX)
3439 // FIXME: The sandbox extensions should be sent with the DidChooseFilesForOpenPanel message. This
3440 // is gated on a way of passing SandboxExtension::Handles in a Vector.
3441 for (size_t i = 0; i < fileURLs.size(); ++i) {
3442 SandboxExtension::Handle sandboxExtensionHandle;
3443 SandboxExtension::createHandle(fileURLs[i], SandboxExtension::ReadOnly, sandboxExtensionHandle);
3444 m_process->send(Messages::WebPage::ExtendSandboxForFileFromOpenPanel(sandboxExtensionHandle), m_pageID);
3448 m_process->send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs), m_pageID);
3450 m_openPanelResultListener->invalidate();
3451 m_openPanelResultListener = 0;
3454 void WebPageProxy::didCancelForOpenPanel()
3459 m_process->send(Messages::WebPage::DidCancelForOpenPanel(), m_pageID);
3461 m_openPanelResultListener->invalidate();
3462 m_openPanelResultListener = 0;
3465 void WebPageProxy::advanceToNextMisspelling(bool startBeforeSelection)
3467 m_process->send(Messages::WebPage::AdvanceToNextMisspelling(startBeforeSelection), m_pageID);
3470 void WebPageProxy::changeSpellingToWord(const String& word)
3475 m_process->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID);
3478 void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
3480 m_pageClient.registerEditCommand(commandProxy, undoOrRedo);
3483 void WebPageProxy::addEditCommand(WebEditCommandProxy* command)
3485 m_editCommandSet.add(command);
3488 void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
3490 m_editCommandSet.remove(command);
3494 m_process->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
3497 bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command)
3499 return m_editCommandSet.find(command) != m_editCommandSet.end();
3502 int64_t WebPageProxy::spellDocumentTag()
3504 if (!m_hasSpellDocumentTag) {
3505 m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag(this);
3506 m_hasSpellDocumentTag = true;
3509 return m_spellDocumentTag;
3512 #if USE(UNIFIED_TEXT_CHECKING)
3513 void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
3515 results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text, checkingTypes);
3519 void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
3521 TextChecker::checkSpellingOfString(spellDocumentTag(), text, misspellingLocation, misspellingLength);
3524 void WebPageProxy::checkGrammarOfString(const String& text, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
3526 TextChecker::checkGrammarOfString(spellDocumentTag(), text, grammarDetails, badGrammarLocation, badGrammarLength);
3529 void WebPageProxy::spellingUIIsShowing(bool& isShowing)
3531 isShowing = TextChecker::spellingUIIsShowing();
3534 void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
3536 TextChecker::updateSpellingUIWithMisspelledWord(spellDocumentTag(), misspelledWord);
3539 void WebPageProxy::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
3541 TextChecker::updateSpellingUIWithGrammarString(spellDocumentTag(), badGrammarPhrase, grammarDetail);
3544 void WebPageProxy::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
3546 TextChecker::getGuessesForWord(spellDocumentTag(), word, context, guesses);
3549 void WebPageProxy::learnWord(const String& word)
3551 MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3552 --m_pendingLearnOrIgnoreWordMessageCount;
3554 TextChecker::learnWord(spellDocumentTag(), word);
3557 void WebPageProxy::ignoreWord(const String& word)
3559 MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
3560 --m_pendingLearnOrIgnoreWordMessageCount;
3562 TextChecker::ignoreWord(spellDocumentTag(), word);
3565 void WebPageProxy::requestCheckingOfString(uint64_t requestID, const TextCheckingRequestData& request)
3567 TextChecker::requestCheckingOfString(TextCheckerCompletion::create(requestID, request, this));
3570 void WebPageProxy::didFinishCheckingText(uint64_t requestID, const Vector<WebCore::TextCheckingResult>& result)
3572 m_process->send(Messages::WebPage::DidFinishCheckingText(requestID, result), m_pageID);
3575 void WebPageProxy::didCancelCheckingText(uint64_t requestID)
3577 m_process->send(Messages::WebPage::DidCancelCheckingText(requestID), m_pageID);
3581 void WebPageProxy::setFocus(bool focused)
3584 m_uiClient->focus(this);
3586 m_uiClient->unfocus(this);
3589 void WebPageProxy::takeFocus(uint32_t direction)
3591 m_uiClient->takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward);
3594 void WebPageProxy::setToolTip(const String& toolTip)
3596 String oldToolTip = m_toolTip;
3597 m_toolTip = toolTip;
3598 m_pageClient.toolTipChanged(oldToolTip, m_toolTip);
3601 void WebPageProxy::setCursor(const WebCore::Cursor& cursor)
3603 // The Web process may have asked to change the cursor when the view was in an active window, but
3604 // if it is no longer in a window or the window is not active, then the cursor should not change.
3605 if (m_pageClient.isViewWindowActive())
3606 m_pageClient.setCursor(cursor);
3609 void WebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
3611 m_pageClient.setCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves);
3614 void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
3616 WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
3619 case WebEvent::NoType:
3620 case WebEvent::MouseMove:
3623 case WebEvent::MouseDown:
3624 case WebEvent::MouseUp:
3625 case WebEvent::Wheel:
3626 case WebEvent::KeyDown:
3627 case WebEvent::KeyUp:
3628 case WebEvent::RawKeyDown:
3629 case WebEvent::Char:
3630 #if ENABLE(TOUCH_EVENTS)
3631 case WebEvent::TouchStart:
3632 case WebEvent::TouchMove:
3633 case WebEvent::TouchEnd:
3634 case WebEvent::TouchCancel:
3636 m_process->responsivenessTimer()->stop();