| 1 | /* |
| 2 | * Copyright (C) 2019 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | #include "ProvisionalPageProxy.h" |
| 28 | |
| 29 | #include "APINavigation.h" |
| 30 | #include "DrawingAreaProxy.h" |
| 31 | #include "FormDataReference.h" |
| 32 | #include "Logging.h" |
| 33 | #include "PageClient.h" |
| 34 | #include "URLSchemeTaskParameters.h" |
| 35 | #include "WebBackForwardList.h" |
| 36 | #include "WebBackForwardListItem.h" |
| 37 | #include "WebErrors.h" |
| 38 | #include "WebNavigationDataStore.h" |
| 39 | #include "WebNavigationState.h" |
| 40 | #include "WebPageMessages.h" |
| 41 | #include "WebPageProxy.h" |
| 42 | #include "WebPageProxyMessages.h" |
| 43 | #include "WebProcessMessages.h" |
| 44 | #include "WebProcessPool.h" |
| 45 | #include "WebProcessProxy.h" |
| 46 | #include <WebCore/ShouldTreatAsContinuingLoad.h> |
| 47 | |
| 48 | namespace WebKit { |
| 49 | |
| 50 | using namespace WebCore; |
| 51 | |
| 52 | #define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(m_page.isAlwaysOnLoggingAllowed(), channel, "%p - ProvisionalPageProxy::" fmt, this, ##__VA_ARGS__) |
| 53 | #define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(m_page.isAlwaysOnLoggingAllowed(), channel, "%p - ProvisionalPageProxy::" fmt, this, ##__VA_ARGS__) |
| 54 | |
| 55 | ProvisionalPageProxy::ProvisionalPageProxy(WebPageProxy& page, Ref<WebProcessProxy>&& process, std::unique_ptr<SuspendedPageProxy> suspendedPage, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest& request, ProcessSwapRequestedByClient processSwapRequestedByClient) |
| 56 | : m_page(page) |
| 57 | , m_process(WTFMove(process)) |
| 58 | , m_navigationID(navigationID) |
| 59 | , m_isServerRedirect(isServerRedirect) |
| 60 | , m_request(request) |
| 61 | , m_processSwapRequestedByClient(processSwapRequestedByClient) |
| 62 | #if PLATFORM(IOS_FAMILY) |
| 63 | , m_suspensionToken(m_process->throttler().foregroundActivityToken()) |
| 64 | #endif |
| 65 | { |
| 66 | RELEASE_LOG_ERROR_IF_ALLOWED(ProcessSwapping, "ProvisionalPageProxy: pageID = %" PRIu64 " navigationID = %" PRIu64 " suspendedPage: %p" , m_page.pageID().toUInt64(), navigationID, suspendedPage.get()); |
| 67 | |
| 68 | m_process->addMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_page.pageID(), *this); |
| 69 | m_process->addProvisionalPageProxy(*this); |
| 70 | |
| 71 | if (m_process->state() == AuxiliaryProcessProxy::State::Running) |
| 72 | m_page.webProcessLifetimeTracker().webPageEnteringWebProcess(m_process); |
| 73 | |
| 74 | if (&m_process->websiteDataStore() != &m_page.websiteDataStore()) |
| 75 | m_process->processPool().pageBeginUsingWebsiteDataStore(m_page.pageID(), m_process->websiteDataStore()); |
| 76 | |
| 77 | // If we are reattaching to a SuspendedPage, then the WebProcess' WebPage already exists and |
| 78 | // WebPageProxy::didCreateMainFrame() will not be called to initialize m_mainFrame. In such |
| 79 | // case, we need to initialize m_mainFrame to reflect the fact the the WebProcess' WebPage |
| 80 | // already exists and already has a main frame. |
| 81 | if (suspendedPage) { |
| 82 | ASSERT(&suspendedPage->process() == m_process.ptr()); |
| 83 | suspendedPage->unsuspend(); |
| 84 | m_mainFrame = WebFrameProxy::create(m_page, suspendedPage->mainFrameID()); |
| 85 | m_process->frameCreated(suspendedPage->mainFrameID(), *m_mainFrame); |
| 86 | } |
| 87 | |
| 88 | initializeWebPage(); |
| 89 | } |
| 90 | |
| 91 | ProvisionalPageProxy::~ProvisionalPageProxy() |
| 92 | { |
| 93 | m_process->removeProvisionalPageProxy(*this); |
| 94 | |
| 95 | if (m_wasCommitted) |
| 96 | return; |
| 97 | |
| 98 | if (m_process->state() == AuxiliaryProcessProxy::State::Running) |
| 99 | m_page.webProcessLifetimeTracker().webPageLeavingWebProcess(m_process); |
| 100 | |
| 101 | if (&m_process->websiteDataStore() != &m_page.websiteDataStore()) |
| 102 | m_process->processPool().pageEndUsingWebsiteDataStore(m_page.pageID(), m_process->websiteDataStore()); |
| 103 | |
| 104 | m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_page.pageID()); |
| 105 | m_process->send(Messages::WebPage::Close(), m_page.pageID()); |
| 106 | m_process->removeVisitedLinkStoreUser(m_page.visitedLinkStore(), m_page.pageID()); |
| 107 | |
| 108 | RunLoop::main().dispatch([process = m_process.copyRef()] { |
| 109 | process->maybeShutDown(); |
| 110 | }); |
| 111 | } |
| 112 | |
| 113 | void ProvisionalPageProxy::connectionWillOpen(IPC::Connection& connection) |
| 114 | { |
| 115 | ASSERT_UNUSED(connection, &connection == m_process->connection()); |
| 116 | |
| 117 | m_page.webProcessLifetimeTracker().webPageEnteringWebProcess(m_process); |
| 118 | } |
| 119 | |
| 120 | void ProvisionalPageProxy::processDidTerminate() |
| 121 | { |
| 122 | RELEASE_LOG_ERROR_IF_ALLOWED(ProcessSwapping, "processDidTerminate: pageID = %" PRIu64, m_page.pageID().toUInt64()); |
| 123 | m_page.provisionalProcessDidTerminate(); |
| 124 | } |
| 125 | |
| 126 | std::unique_ptr<DrawingAreaProxy> ProvisionalPageProxy::takeDrawingArea() |
| 127 | { |
| 128 | return WTFMove(m_drawingArea); |
| 129 | } |
| 130 | |
| 131 | void ProvisionalPageProxy::cancel() |
| 132 | { |
| 133 | // If the provisional load started, then indicate that it failed due to cancellation by calling didFailProvisionalLoadForFrame(). |
| 134 | if (m_provisionalLoadURL.isEmpty()) |
| 135 | return; |
| 136 | |
| 137 | RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "cancel: Simulating a didFailProvisionalLoadForFrame for pageID = %" PRIu64, m_page.pageID().toUInt64()); |
| 138 | ASSERT(m_mainFrame); |
| 139 | auto error = WebKit::cancelledError(m_request); |
| 140 | error.setType(WebCore::ResourceError::Type::Cancellation); |
| 141 | didFailProvisionalLoadForFrame(m_mainFrame->frameID(), { }, m_navigationID, m_provisionalLoadURL, error, WebCore::WillContinueLoading::No, UserData { }); // Will delete |this|. |
| 142 | } |
| 143 | |
| 144 | void ProvisionalPageProxy::initializeWebPage() |
| 145 | { |
| 146 | m_drawingArea = m_page.pageClient().createDrawingAreaProxy(m_process); |
| 147 | |
| 148 | auto parameters = m_page.creationParameters(m_process, *m_drawingArea); |
| 149 | parameters.isProcessSwap = true; |
| 150 | m_process->send(Messages::WebProcess::CreateWebPage(m_page.pageID(), parameters), 0); |
| 151 | m_process->addVisitedLinkStoreUser(m_page.visitedLinkStore(), m_page.pageID()); |
| 152 | } |
| 153 | |
| 154 | void ProvisionalPageProxy::loadData(API::Navigation& navigation, const IPC::DataReference& data, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, Optional<WebsitePoliciesData>&& websitePolicies) |
| 155 | { |
| 156 | RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "loadData: pageID = %" PRIu64, m_page.pageID().toUInt64()); |
| 157 | |
| 158 | m_page.loadDataWithNavigationShared(m_process.copyRef(), navigation, data, MIMEType, encoding, baseURL, userData, WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePolicies)); |
| 159 | } |
| 160 | |
| 161 | void ProvisionalPageProxy::loadRequest(API::Navigation& navigation, WebCore::ResourceRequest&& request, WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy, API::Object* userData, Optional<WebsitePoliciesData>&& websitePolicies) |
| 162 | { |
| 163 | RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "loadRequest: pageID = %" PRIu64, m_page.pageID().toUInt64()); |
| 164 | |
| 165 | // If this is a client-side redirect continuing in a new process, then the new process will overwrite the fromItem's URL. In this case, |
| 166 | // we need to make sure we update fromItem's processIdentifier as we want future navigations to this BackForward item to happen in the |
| 167 | // new process. |
| 168 | if (navigation.fromItem() && navigation.lockBackForwardList() == WebCore::LockBackForwardList::Yes) |
| 169 | navigation.fromItem()->setLastProcessIdentifier(m_process->coreProcessIdentifier()); |
| 170 | |
| 171 | m_page.loadRequestWithNavigationShared(m_process.copyRef(), navigation, WTFMove(request), shouldOpenExternalURLsPolicy, userData, WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePolicies)); |
| 172 | } |
| 173 | |
| 174 | void ProvisionalPageProxy::goToBackForwardItem(API::Navigation& navigation, WebBackForwardListItem& item, Optional<WebsitePoliciesData>&& websitePolicies) |
| 175 | { |
| 176 | RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "goToBackForwardItem: pageID = %" PRIu64, m_page.pageID().toUInt64()); |
| 177 | |
| 178 | auto itemStates = m_page.backForwardList().filteredItemStates([this, targetItem = &item](auto& item) { |
| 179 | if (auto* page = item.suspendedPage()) { |
| 180 | if (&page->process() == m_process.ptr()) |
| 181 | return false; |
| 182 | } |
| 183 | return &item != targetItem; |
| 184 | }); |
| 185 | m_process->send(Messages::WebPage::UpdateBackForwardListForReattach(WTFMove(itemStates)), m_page.pageID()); |
| 186 | m_process->send(Messages::WebPage::GoToBackForwardItem(navigation.navigationID(), item.itemID(), *navigation.backForwardFrameLoadType(), WebCore::ShouldTreatAsContinuingLoad::Yes, WTFMove(websitePolicies)), m_page.pageID()); |
| 187 | m_process->responsivenessTimer().start(); |
| 188 | } |
| 189 | |
| 190 | inline bool ProvisionalPageProxy::validateInput(uint64_t frameID, const Optional<uint64_t>& navigationID) |
| 191 | { |
| 192 | // If the previous provisional load used an existing process, we may receive leftover IPC for a previous navigation, which we need to ignore. |
| 193 | if (!m_mainFrame || m_mainFrame->frameID() != frameID) |
| 194 | return false; |
| 195 | |
| 196 | return !navigationID || !*navigationID || *navigationID == m_navigationID; |
| 197 | } |
| 198 | |
| 199 | void ProvisionalPageProxy::didCreateMainFrame(uint64_t frameID) |
| 200 | { |
| 201 | RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "didCreateMainFrame: pageID = %" PRIu64 ", frameID = %" PRIu64, m_page.pageID().toUInt64(), frameID); |
| 202 | ASSERT(!m_mainFrame); |
| 203 | |
| 204 | m_mainFrame = WebFrameProxy::create(m_page, frameID); |
| 205 | |
| 206 | // Add the frame to the process wide map. |
| 207 | m_process->frameCreated(frameID, *m_mainFrame); |
| 208 | |
| 209 | // This navigation was destroyed so no need to notify of redirect. |
| 210 | if (!m_page.navigationState().hasNavigation(m_navigationID)) |
| 211 | return; |
| 212 | |
| 213 | // Restore the main frame's committed URL as some clients may rely on it until the next load is committed. |
| 214 | if (auto* mainFrame = m_page.mainFrame()) |
| 215 | m_mainFrame->frameLoadState().setURL(mainFrame->frameLoadState().url()); |
| 216 | |
| 217 | // Normally, notification of a server redirect comes from the WebContent process. |
| 218 | // If we are process swapping in response to a server redirect then that notification will not come from the new WebContent process. |
| 219 | // In this case we have the UIProcess synthesize the redirect notification at the appropriate time. |
| 220 | if (m_isServerRedirect) { |
| 221 | m_mainFrame->frameLoadState().didStartProvisionalLoad(m_request.url()); |
| 222 | m_page.didReceiveServerRedirectForProvisionalLoadForFrameShared(m_process.copyRef(), m_mainFrame->frameID(), m_navigationID, WTFMove(m_request), { }); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | void ProvisionalPageProxy::didPerformClientRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID) |
| 227 | { |
| 228 | if (!validateInput(frameID)) |
| 229 | return; |
| 230 | |
| 231 | m_page.didPerformClientRedirectShared(m_process.copyRef(), sourceURLString, destinationURLString, frameID); |
| 232 | } |
| 233 | |
| 234 | void ProvisionalPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, URL&& url, URL&& unreachableURL, const UserData& userData) |
| 235 | { |
| 236 | if (!validateInput(frameID, navigationID)) |
| 237 | return; |
| 238 | |
| 239 | RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "didStartProvisionalLoadForFrame: pageID = %" PRIu64 ", frameID = %" PRIu64 ", navigationID = %" PRIu64, m_page.pageID().toUInt64(), frameID, navigationID); |
| 240 | ASSERT(m_provisionalLoadURL.isNull()); |
| 241 | m_provisionalLoadURL = url; |
| 242 | |
| 243 | // Merely following a server side redirect so there is no need to send a didStartProvisionalLoad again. |
| 244 | if (m_isServerRedirect) |
| 245 | return; |
| 246 | |
| 247 | // Clients expect the Page's main frame's expectedURL to be the provisional one when a provisional load is started. |
| 248 | if (auto* pageMainFrame = m_page.mainFrame()) |
| 249 | pageMainFrame->didStartProvisionalLoad(url); |
| 250 | |
| 251 | m_page.didStartProvisionalLoadForFrameShared(m_process.copyRef(), frameID, navigationID, WTFMove(url), WTFMove(unreachableURL), userData); |
| 252 | } |
| 253 | |
| 254 | void ProvisionalPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const WebCore::SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError& error, WebCore::WillContinueLoading willContinueLoading, const UserData& userData) |
| 255 | { |
| 256 | if (!validateInput(frameID, navigationID)) |
| 257 | return; |
| 258 | |
| 259 | RELEASE_LOG_ERROR_IF_ALLOWED(ProcessSwapping, "didFailProvisionalLoadForFrame: pageID = %" PRIu64 ", frameID = %" PRIu64 ", navigationID = %" PRIu64, m_page.pageID().toUInt64(), frameID, navigationID); |
| 260 | ASSERT(!m_provisionalLoadURL.isNull()); |
| 261 | m_provisionalLoadURL = { }; |
| 262 | |
| 263 | // Make sure the Page's main frame's expectedURL gets cleared since we updated it in didStartProvisionalLoad. |
| 264 | if (auto* pageMainFrame = m_page.mainFrame()) |
| 265 | pageMainFrame->didFailProvisionalLoad(); |
| 266 | |
| 267 | m_page.didFailProvisionalLoadForFrameShared(m_process.copyRef(), frameID, frameSecurityOrigin, navigationID, provisionalURL, error, willContinueLoading, userData); // May delete |this|. |
| 268 | } |
| 269 | |
| 270 | void ProvisionalPageProxy::didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo& certificateInfo, bool containsPluginDocument, Optional<WebCore::HasInsecureContent> forcedHasInsecureContent, const UserData& userData) |
| 271 | { |
| 272 | if (!validateInput(frameID, navigationID)) |
| 273 | return; |
| 274 | |
| 275 | RELEASE_LOG_IF_ALLOWED(ProcessSwapping, "didCommitLoadForFrame: pageID = %" PRIu64 ", frameID = %" PRIu64 ", navigationID = %" PRIu64, m_page.pageID().toUInt64(), frameID, navigationID); |
| 276 | m_provisionalLoadURL = { }; |
| 277 | m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_page.pageID()); |
| 278 | |
| 279 | m_wasCommitted = true; |
| 280 | m_page.commitProvisionalPage(frameID, navigationID, mimeType, frameHasCustomContentProvider, frameLoadType, certificateInfo, containsPluginDocument, forcedHasInsecureContent, userData); // Will delete |this|. |
| 281 | } |
| 282 | |
| 283 | void ProvisionalPageProxy::didNavigateWithNavigationData(const WebNavigationDataStore& store, uint64_t frameID) |
| 284 | { |
| 285 | if (!validateInput(frameID)) |
| 286 | return; |
| 287 | |
| 288 | m_page.didNavigateWithNavigationDataShared(m_process.copyRef(), store, frameID); |
| 289 | } |
| 290 | |
| 291 | void ProvisionalPageProxy::didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, URL&& url) |
| 292 | { |
| 293 | if (!validateInput(frameID, navigationID)) |
| 294 | return; |
| 295 | |
| 296 | m_page.didChangeProvisionalURLForFrameShared(m_process.copyRef(), frameID, navigationID, WTFMove(url)); |
| 297 | } |
| 298 | |
| 299 | void ProvisionalPageProxy::decidePolicyForNavigationActionAsync(uint64_t frameID, WebCore::SecurityOriginData&& frameSecurityOrigin, WebCore::PolicyCheckIdentifier identifier, |
| 300 | uint64_t navigationID, NavigationActionData&& navigationActionData, FrameInfoData&& frameInfoData, Optional<PageIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, |
| 301 | WebCore::ResourceRequest&& request, IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&& redirectResponse, const UserData& userData, uint64_t listenerID) |
| 302 | { |
| 303 | if (!validateInput(frameID, navigationID)) |
| 304 | return; |
| 305 | |
| 306 | m_page.decidePolicyForNavigationActionAsyncShared(m_process.copyRef(), frameID, WTFMove(frameSecurityOrigin), identifier, navigationID, WTFMove(navigationActionData), |
| 307 | WTFMove(frameInfoData), originatingPageID, originalRequest, WTFMove(request), WTFMove(requestBody), WTFMove(redirectResponse), userData, listenerID); |
| 308 | } |
| 309 | |
| 310 | void ProvisionalPageProxy::decidePolicyForResponse(uint64_t frameID, const WebCore::SecurityOriginData& frameSecurityOrigin, WebCore::PolicyCheckIdentifier identifier, |
| 311 | uint64_t navigationID, const WebCore::ResourceResponse& response, const WebCore::ResourceRequest& request, bool canShowMIMEType, const String& downloadAttribute, uint64_t listenerID, const UserData& userData) |
| 312 | { |
| 313 | if (!validateInput(frameID, navigationID)) |
| 314 | return; |
| 315 | |
| 316 | m_page.decidePolicyForResponseShared(m_process.copyRef(), frameID, frameSecurityOrigin, identifier, navigationID, response, request, canShowMIMEType, downloadAttribute, listenerID, userData); |
| 317 | } |
| 318 | |
| 319 | void ProvisionalPageProxy::didPerformServerRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID) |
| 320 | { |
| 321 | if (!validateInput(frameID)) |
| 322 | return; |
| 323 | |
| 324 | m_page.didPerformServerRedirectShared(m_process.copyRef(), sourceURLString, destinationURLString, frameID); |
| 325 | } |
| 326 | |
| 327 | void ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceRequest&& request, const UserData& userData) |
| 328 | { |
| 329 | if (!validateInput(frameID, navigationID)) |
| 330 | return; |
| 331 | |
| 332 | m_page.didReceiveServerRedirectForProvisionalLoadForFrameShared(m_process.copyRef(), frameID, navigationID, WTFMove(request), userData); |
| 333 | } |
| 334 | |
| 335 | void ProvisionalPageProxy::startURLSchemeTask(URLSchemeTaskParameters&& parameters) |
| 336 | { |
| 337 | m_page.startURLSchemeTaskShared(m_process.copyRef(), WTFMove(parameters)); |
| 338 | } |
| 339 | |
| 340 | void ProvisionalPageProxy::backForwardGoToItem(const WebCore::BackForwardItemIdentifier& identifier, CompletionHandler<void(SandboxExtension::Handle&&)>&& completionHandler) |
| 341 | { |
| 342 | m_page.backForwardGoToItemShared(m_process.copyRef(), identifier, WTFMove(completionHandler)); |
| 343 | } |
| 344 | |
| 345 | void ProvisionalPageProxy::decidePolicyForNavigationActionSync(uint64_t frameID, bool isMainFrame, WebCore::SecurityOriginData&& frameSecurityOrigin, WebCore::PolicyCheckIdentifier identifier, |
| 346 | uint64_t navigationID, NavigationActionData&& navigationActionData, FrameInfoData&& frameInfoData, Optional<PageIdentifier> originatingPageID, |
| 347 | const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&& request, IPC::FormDataReference&& requestBody, WebCore::ResourceResponse&& redirectResponse, |
| 348 | const UserData& userData, Messages::WebPageProxy::DecidePolicyForNavigationActionSync::DelayedReply&& reply) |
| 349 | { |
| 350 | if (!isMainFrame || (m_mainFrame && m_mainFrame->frameID() != frameID) || navigationID != m_navigationID) { |
| 351 | reply(identifier, WebCore::PolicyAction::Ignore, navigationID, DownloadID(), WTF::nullopt); |
| 352 | return; |
| 353 | } |
| 354 | |
| 355 | if (!m_mainFrame) { |
| 356 | // This synchronous IPC message was processed before the asynchronous DidCreateMainFrame one so we do not know about this frameID yet. |
| 357 | didCreateMainFrame(frameID); |
| 358 | } |
| 359 | ASSERT(m_mainFrame); |
| 360 | |
| 361 | m_page.decidePolicyForNavigationActionSyncShared(m_process.copyRef(), frameID, isMainFrame, WTFMove(frameSecurityOrigin), identifier, navigationID, WTFMove(navigationActionData), |
| 362 | WTFMove(frameInfoData), originatingPageID, originalRequest, WTFMove(request), WTFMove(requestBody), WTFMove(redirectResponse), userData, WTFMove(reply)); |
| 363 | } |
| 364 | |
| 365 | #if USE(QUICK_LOOK) |
| 366 | void ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName) |
| 367 | { |
| 368 | m_page.didRequestPasswordForQuickLookDocumentInMainFrameShared(m_process.copyRef(), fileName); |
| 369 | } |
| 370 | #endif |
| 371 | |
| 372 | #if PLATFORM(COCOA) |
| 373 | void ProvisionalPageProxy::registerWebProcessAccessibilityToken(const IPC::DataReference& data) |
| 374 | { |
| 375 | m_accessibilityToken = data.vector(); |
| 376 | } |
| 377 | #endif |
| 378 | |
| 379 | #if ENABLE(CONTENT_FILTERING) |
| 380 | void ProvisionalPageProxy::contentFilterDidBlockLoadForFrame(const WebCore::ContentFilterUnblockHandler& unblockHandler, uint64_t frameID) |
| 381 | { |
| 382 | m_page.contentFilterDidBlockLoadForFrameShared(m_process.copyRef(), unblockHandler, frameID); |
| 383 | } |
| 384 | #endif |
| 385 | |
| 386 | void ProvisionalPageProxy::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder) |
| 387 | { |
| 388 | ASSERT(decoder.messageReceiverName() == Messages::WebPageProxy::messageReceiverName()); |
| 389 | |
| 390 | if (decoder.messageName() == Messages::WebPageProxy::DidStartProgress::name() |
| 391 | || decoder.messageName() == Messages::WebPageProxy::DidChangeProgress::name() |
| 392 | || decoder.messageName() == Messages::WebPageProxy::DidDestroyNavigation::name() |
| 393 | || decoder.messageName() == Messages::WebPageProxy::DidFinishProgress::name() |
| 394 | || decoder.messageName() == Messages::WebPageProxy::BackForwardAddItem::name() |
| 395 | || decoder.messageName() == Messages::WebPageProxy::LogDiagnosticMessage::name() |
| 396 | || decoder.messageName() == Messages::WebPageProxy::LogDiagnosticMessageWithEnhancedPrivacy::name() |
| 397 | || decoder.messageName() == Messages::WebPageProxy::LogDiagnosticMessageWithValueDictionary::name() |
| 398 | || decoder.messageName() == Messages::WebPageProxy::SetNetworkRequestsInProgress::name() |
| 399 | || decoder.messageName() == Messages::WebPageProxy::WillGoToBackForwardListItem::name() |
| 400 | #if USE(QUICK_LOOK) |
| 401 | || decoder.messageName() == Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame::name() |
| 402 | || decoder.messageName() == Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame::name() |
| 403 | #endif |
| 404 | ) |
| 405 | { |
| 406 | m_page.didReceiveMessage(connection, decoder); |
| 407 | return; |
| 408 | } |
| 409 | |
| 410 | #if PLATFORM(COCOA) |
| 411 | if (decoder.messageName() == Messages::WebPageProxy::RegisterWebProcessAccessibilityToken::name()) { |
| 412 | IPC::handleMessage<Messages::WebPageProxy::RegisterWebProcessAccessibilityToken>(decoder, this, &ProvisionalPageProxy::registerWebProcessAccessibilityToken); |
| 413 | return; |
| 414 | } |
| 415 | #endif |
| 416 | |
| 417 | if (decoder.messageName() == Messages::WebPageProxy::StartURLSchemeTask::name()) { |
| 418 | IPC::handleMessage<Messages::WebPageProxy::StartURLSchemeTask>(decoder, this, &ProvisionalPageProxy::startURLSchemeTask); |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | if (decoder.messageName() == Messages::WebPageProxy::DecidePolicyForNavigationActionAsync::name()) { |
| 423 | IPC::handleMessage<Messages::WebPageProxy::DecidePolicyForNavigationActionAsync>(decoder, this, &ProvisionalPageProxy::decidePolicyForNavigationActionAsync); |
| 424 | return; |
| 425 | } |
| 426 | |
| 427 | if (decoder.messageName() == Messages::WebPageProxy::DecidePolicyForResponse::name()) { |
| 428 | IPC::handleMessage<Messages::WebPageProxy::DecidePolicyForResponse>(decoder, this, &ProvisionalPageProxy::decidePolicyForResponse); |
| 429 | return; |
| 430 | } |
| 431 | |
| 432 | if (decoder.messageName() == Messages::WebPageProxy::DidChangeProvisionalURLForFrame::name()) { |
| 433 | IPC::handleMessage<Messages::WebPageProxy::DidChangeProvisionalURLForFrame>(decoder, this, &ProvisionalPageProxy::didChangeProvisionalURLForFrame); |
| 434 | return; |
| 435 | } |
| 436 | |
| 437 | if (decoder.messageName() == Messages::WebPageProxy::DidNavigateWithNavigationData::name()) { |
| 438 | IPC::handleMessage<Messages::WebPageProxy::DidNavigateWithNavigationData>(decoder, this, &ProvisionalPageProxy::didNavigateWithNavigationData); |
| 439 | return; |
| 440 | } |
| 441 | |
| 442 | if (decoder.messageName() == Messages::WebPageProxy::DidPerformClientRedirect::name()) { |
| 443 | IPC::handleMessage<Messages::WebPageProxy::DidPerformClientRedirect>(decoder, this, &ProvisionalPageProxy::didPerformClientRedirect); |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | if (decoder.messageName() == Messages::WebPageProxy::DidCreateMainFrame::name()) { |
| 448 | IPC::handleMessage<Messages::WebPageProxy::DidCreateMainFrame>(decoder, this, &ProvisionalPageProxy::didCreateMainFrame); |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | if (decoder.messageName() == Messages::WebPageProxy::DidStartProvisionalLoadForFrame::name()) { |
| 453 | IPC::handleMessage<Messages::WebPageProxy::DidStartProvisionalLoadForFrame>(decoder, this, &ProvisionalPageProxy::didStartProvisionalLoadForFrame); |
| 454 | return; |
| 455 | } |
| 456 | |
| 457 | if (decoder.messageName() == Messages::WebPageProxy::DidFailProvisionalLoadForFrame::name()) { |
| 458 | IPC::handleMessage<Messages::WebPageProxy::DidFailProvisionalLoadForFrame>(decoder, this, &ProvisionalPageProxy::didFailProvisionalLoadForFrame); |
| 459 | return; |
| 460 | } |
| 461 | |
| 462 | if (decoder.messageName() == Messages::WebPageProxy::DidCommitLoadForFrame::name()) { |
| 463 | IPC::handleMessage<Messages::WebPageProxy::DidCommitLoadForFrame>(decoder, this, &ProvisionalPageProxy::didCommitLoadForFrame); |
| 464 | return; |
| 465 | } |
| 466 | |
| 467 | if (decoder.messageName() == Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame::name()) { |
| 468 | IPC::handleMessage<Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame>(decoder, this, &ProvisionalPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame); |
| 469 | return; |
| 470 | } |
| 471 | |
| 472 | if (decoder.messageName() == Messages::WebPageProxy::DidPerformServerRedirect::name()) { |
| 473 | IPC::handleMessage<Messages::WebPageProxy::DidPerformServerRedirect>(decoder, this, &ProvisionalPageProxy::didPerformServerRedirect); |
| 474 | return; |
| 475 | } |
| 476 | |
| 477 | #if USE(QUICK_LOOK) |
| 478 | if (decoder.messageName() == Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame::name()) { |
| 479 | IPC::handleMessage<Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame>(decoder, this, &ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame); |
| 480 | return; |
| 481 | } |
| 482 | #endif |
| 483 | |
| 484 | #if ENABLE(CONTENT_FILTERING) |
| 485 | if (decoder.messageName() == Messages::WebPageProxy::ContentFilterDidBlockLoadForFrame::name()) { |
| 486 | IPC::handleMessage<Messages::WebPageProxy::ContentFilterDidBlockLoadForFrame>(decoder, this, &ProvisionalPageProxy::contentFilterDidBlockLoadForFrame); |
| 487 | return; |
| 488 | } |
| 489 | #endif |
| 490 | |
| 491 | LOG(ProcessSwapping, "Unhandled message %s::%s from provisional process" , decoder.messageReceiverName().toString().data(), decoder.messageName().toString().data()); |
| 492 | } |
| 493 | |
| 494 | void ProvisionalPageProxy::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder) |
| 495 | { |
| 496 | if (decoder.messageName() == Messages::WebPageProxy::BackForwardGoToItem::name()) { |
| 497 | IPC::handleMessageSynchronous<Messages::WebPageProxy::BackForwardGoToItem>(connection, decoder, replyEncoder, this, &ProvisionalPageProxy::backForwardGoToItem); |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | if (decoder.messageName() == Messages::WebPageProxy::DecidePolicyForNavigationActionSync::name()) { |
| 502 | IPC::handleMessageSynchronous<Messages::WebPageProxy::DecidePolicyForNavigationActionSync>(connection, decoder, replyEncoder, this, &ProvisionalPageProxy::decidePolicyForNavigationActionSync); |
| 503 | return; |
| 504 | } |
| 505 | |
| 506 | m_page.didReceiveSyncMessage(connection, decoder, replyEncoder); |
| 507 | } |
| 508 | |
| 509 | } // namespace WebKit |
| 510 | |