diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp')
-rw-r--r-- | Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp | 795 |
1 files changed, 505 insertions, 290 deletions
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp index 06880399f..044f8430a 100644 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2010-2017 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,16 +28,19 @@ #include "AuthenticationManager.h" #include "DataReference.h" +#include "DrawingArea.h" #include "InjectedBundle.h" #include "InjectedBundleBackForwardListItem.h" #include "InjectedBundleDOMWindowExtension.h" #include "InjectedBundleNavigationAction.h" -#include "InjectedBundleUserMessageCoders.h" #include "NavigationActionData.h" #include "PluginView.h" +#include "UserData.h" +#include "WKBundleAPICast.h" +#include "WebAutomationSessionProxy.h" #include "WebBackForwardListProxy.h" -#include "WebContextMessages.h" #include "WebCoreArgumentCoders.h" +#include "WebDocumentLoader.h" #include "WebErrors.h" #include "WebEvent.h" #include "WebFrame.h" @@ -46,12 +49,14 @@ #include "WebIconDatabaseMessages.h" #include "WebNavigationDataStore.h" #include "WebPage.h" +#include "WebPageGroupProxy.h" #include "WebPageProxyMessages.h" #include "WebProcess.h" -#include "WebProcessProxyMessages.h" +#include "WebProcessPoolMessages.h" +#include "WebsitePolicies.h" #include <JavaScriptCore/APICast.h> #include <JavaScriptCore/JSObject.h> -#include <WebCore/AXObjectCache.h> +#include <WebCore/CachedFrame.h> #include <WebCore/CertificateInfo.h> #include <WebCore/Chrome.h> #include <WebCore/DOMWrapperWorld.h> @@ -72,8 +77,9 @@ #include <WebCore/PluginData.h> #include <WebCore/PluginDocument.h> #include <WebCore/ProgressTracker.h> -#include <WebCore/ResourceBuffer.h> #include <WebCore/ResourceError.h> +#include <WebCore/ScriptController.h> +#include <WebCore/SecurityOriginData.h> #include <WebCore/Settings.h> #include <WebCore/SubframeLoader.h> #include <WebCore/UIEventWithKeyState.h> @@ -88,7 +94,8 @@ namespace WebKit { WebFrameLoaderClient::WebFrameLoaderClient() : m_frame(0) , m_hasSentResponseToPluginView(false) - , m_didCompletePageTransitionAlready(false) + , m_didCompletePageTransition(false) + , m_frameHasCustomContentProvider(false) , m_frameCameFromPageCache(false) { } @@ -99,26 +106,23 @@ WebFrameLoaderClient::~WebFrameLoaderClient() void WebFrameLoaderClient::frameLoaderDestroyed() { - if (WebPage* webPage = m_frame->page()) - webPage->injectedBundleLoaderClient().willDestroyFrame(webPage, m_frame); - m_frame->invalidate(); // Balances explicit ref() in WebFrame::create(). m_frame->deref(); } -bool WebFrameLoaderClient::hasWebView() const +bool WebFrameLoaderClient::hasHTMLView() const { - return m_frame->page(); + return !m_frameHasCustomContentProvider; } -void WebFrameLoaderClient::makeRepresentation(DocumentLoader*) +bool WebFrameLoaderClient::hasWebView() const { - notImplemented(); + return m_frame->page(); } -void WebFrameLoaderClient::forceLayout() +void WebFrameLoaderClient::makeRepresentation(DocumentLoader*) { notImplemented(); } @@ -143,10 +147,6 @@ void WebFrameLoaderClient::detachedFromParent2() // Notify the bundle client. webPage->injectedBundleLoaderClient().didRemoveFrameFromHierarchy(webPage, m_frame, userData); - - // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidRemoveFrameFromHierarchy(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); - } void WebFrameLoaderClient::detachedFromParent3() @@ -165,6 +165,7 @@ void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identi pageIsProvisionallyLoading = frameLoader->provisionalDocumentLoader() == loader; webPage->injectedBundleResourceLoadClient().didInitiateLoadForResource(webPage, m_frame, identifier, request, pageIsProvisionallyLoading); + webPage->addResourceRequest(identifier, request); } void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse) @@ -194,29 +195,15 @@ void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoa if (!webPage) return; - WebProcess::shared().supplement<AuthenticationManager>()->didReceiveAuthenticationChallenge(m_frame, challenge); -} - -void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long /*identifier*/, const AuthenticationChallenge&) -{ - notImplemented(); + WebProcess::singleton().supplement<AuthenticationManager>()->didReceiveAuthenticationChallenge(m_frame, challenge); } #if USE(PROTECTION_SPACE_AUTH_CALLBACK) bool WebFrameLoaderClient::canAuthenticateAgainstProtectionSpace(DocumentLoader*, unsigned long, const ProtectionSpace& protectionSpace) { - // FIXME: Authentication is a per-resource concept, but we don't do per-resource handling in the UIProcess at the API level quite yet. - // Once we do, we might need to make sure authentication fits with our solution. - - WebPage* webPage = m_frame->page(); - if (!webPage) - return false; - - bool canAuthenticate; - if (!webPage->sendSync(Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame(m_frame->frameID(), protectionSpace), Messages::WebPageProxy::CanAuthenticateAgainstProtectionSpaceInFrame::Reply(canAuthenticate))) - return false; - - return canAuthenticate; + // The WebKit 2 Networking process asks the UIProcess directly, so the WebContent process should never receive this callback. + ASSERT_NOT_REACHED(); + return false; } #endif @@ -238,6 +225,16 @@ void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsi webPage->injectedBundleResourceLoadClient().didReceiveContentLengthForResource(webPage, m_frame, identifier, dataLength); } +#if ENABLE(DATA_DETECTION) +void WebFrameLoaderClient::dispatchDidFinishDataDetection(NSArray *detectionResults) +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + webPage->setDataDetectionResults(detectionResults); +} +#endif + void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned long identifier) { WebPage* webPage = m_frame->page(); @@ -245,6 +242,7 @@ void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned lo return; webPage->injectedBundleResourceLoadClient().didFinishLoadForResource(webPage, m_frame, identifier); + webPage->removeResourceRequest(identifier); } void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError& error) @@ -254,6 +252,7 @@ void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long return; webPage->injectedBundleResourceLoadClient().didFailLoadForResource(webPage, m_frame, identifier, error); + webPage->removeResourceRequest(identifier); } bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int /*length*/) @@ -262,7 +261,7 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader return false; } -void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() +void WebFrameLoaderClient::dispatchDidDispatchOnloadEvents() { WebPage* webPage = m_frame->page(); if (!webPage) @@ -278,15 +277,25 @@ void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() if (!webPage) return; - DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader().provisionalDocumentLoader(); - const String& url = provisionalLoader->url().string(); + WebDocumentLoader& documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader()); + const String& url = documentLoader.url().string(); RefPtr<API::Object> userData; // Notify the bundle client. webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(webPage, m_frame, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), url, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), url, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); +} + +void WebFrameLoaderClient::dispatchDidChangeProvisionalURL() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + WebDocumentLoader& documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader()); + webPage->send(Messages::WebPageProxy::DidChangeProvisionalURLForFrame(m_frame->frameID(), documentLoader.navigationID(), documentLoader.url().string())); } void WebFrameLoaderClient::dispatchDidCancelClientRedirect() @@ -317,11 +326,13 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() RefPtr<API::Object> userData; + auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); + // Notify the bundle client. webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationAnchorNavigation, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::dispatchDidPushStateWithinPage() @@ -332,11 +343,13 @@ void WebFrameLoaderClient::dispatchDidPushStateWithinPage() RefPtr<API::Object> userData; + auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); + // Notify the bundle client. webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePush, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage() @@ -347,11 +360,13 @@ void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage() RefPtr<API::Object> userData; + auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); + // Notify the bundle client. webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStateReplace, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::dispatchDidPopStateWithinPage() @@ -362,11 +377,13 @@ void WebFrameLoaderClient::dispatchDidPopStateWithinPage() RefPtr<API::Object> userData; + auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); + // Notify the bundle client. webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(webPage, m_frame, SameDocumentNavigationSessionStatePop, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->document()->url().string(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->document()->url().string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::dispatchWillClose() @@ -376,7 +393,7 @@ void WebFrameLoaderClient::dispatchWillClose() void WebFrameLoaderClient::dispatchDidReceiveIcon() { - WebProcess::shared().parentProcessConnection()->send(Messages::WebIconDatabase::DidReceiveIconForPageURL(m_frame->url()), 0); + WebProcess::singleton().parentProcessConnection()->send(Messages::WebIconDatabase::DidReceiveIconForPageURL(m_frame->url()), 0); } void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() @@ -394,47 +411,46 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() webPage->findController().hideFindUI(); webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame); - DocumentLoader* provisionalLoader = m_frame->coreFrame()->loader().provisionalDocumentLoader(); - const String& url = provisionalLoader->url().string(); + WebDocumentLoader& provisionalLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader()); + const String& url = provisionalLoader.url().string(); RefPtr<API::Object> userData; // Notify the bundle client. webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(webPage, m_frame, userData); - String unreachableURL = provisionalLoader->unreachableURL().string(); + String unreachableURL = provisionalLoader.unreachableURL().string(); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), url, unreachableURL, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), provisionalLoader.navigationID(), url, unreachableURL, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } +static constexpr unsigned maxTitleLength = 1000; // Closest power of 10 above the W3C recommendation for Title length. + void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title) { WebPage* webPage = m_frame->page(); if (!webPage) return; + auto truncatedTitle = truncateFromEnd(title, maxTitleLength); + RefPtr<API::Object> userData; // Notify the bundle client. - // FIXME: use direction of title. - webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, title.string(), m_frame, userData); + // FIXME: Use direction of title. + webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(webPage, truncatedTitle.string, m_frame, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), title.string(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), truncatedTitle.string, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } -void WebFrameLoaderClient::dispatchDidChangeIcons(WebCore::IconType) -{ - notImplemented(); -} - -void WebFrameLoaderClient::dispatchDidCommitLoad() +void WebFrameLoaderClient::dispatchDidCommitLoad(std::optional<HasInsecureContent> hasInsecureContent) { WebPage* webPage = m_frame->page(); if (!webPage) return; - const ResourceResponse& response = m_frame->coreFrame()->loader().documentLoader()->response(); + WebDocumentLoader& documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()); RefPtr<API::Object> userData; // Notify the bundle client. @@ -443,9 +459,7 @@ void WebFrameLoaderClient::dispatchDidCommitLoad() webPage->sandboxExtensionTracker().didCommitProvisionalLoad(m_frame); // Notify the UIProcess. - - webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), response.mimeType(), m_frame->coreFrame()->loader().loadType(), CertificateInfo(response), InjectedBundleUserMessageEncoder(userData.get()))); - + webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frameHasCustomContentProvider, static_cast<uint32_t>(m_frame->coreFrame()->loader().loadType()), valueOrCompute(documentLoader.response().certificateInfo(), [] { return CertificateInfo(); }), m_frame->coreFrame()->document()->isPluginDocument(), hasInsecureContent, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); webPage->didCommitLoad(m_frame); } @@ -462,9 +476,22 @@ void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& e webPage->sandboxExtensionTracker().didFailProvisionalLoad(m_frame); + // FIXME: This is gross. This is necessary because if the client calls WKBundlePageStopLoading() from within the didFailProvisionalLoadWithErrorForFrame + // injected bundle client call, that will cause the provisional DocumentLoader to be disconnected from the Frame, and didDistroyNavigation message + // to be sent to the UIProcess (and the destruction of the DocumentLoader). If that happens, and we had captured the navigationID before injected bundle + // client call, the DidFailProvisionalLoadForFrame would send a navigationID of a destroyed Navigation, and the UIProcess would not be able to find it + // in its table. + // + // A better solution to this problem would be find a clean way to postpone the disconnection of the DocumentLoader from the Frame until + // the entire FrameLoaderClient function was complete. + uint64_t navigationID = 0; + if (auto documentLoader = m_frame->coreFrame()->loader().provisionalDocumentLoader()) + navigationID = static_cast<WebDocumentLoader*>(documentLoader)->navigationID(); + // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get()))); - + WebCore::Frame* coreFrame = m_frame ? m_frame->coreFrame() : nullptr; + webPage->send(Messages::WebPageProxy::DidFailProvisionalLoadForFrame(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), navigationID, m_frame->coreFrame()->loader().provisionalLoadErrorBeingHandledURL(), error, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); + // If we have a load listener, notify it. if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) loadListener->didFailLoad(m_frame, error.isCancellation()); @@ -478,11 +505,13 @@ void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error) RefPtr<API::Object> userData; + auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); + // Notify the bundle client. webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(webPage, m_frame, error, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidFailLoadForFrame(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidFailLoadForFrame(m_frame->frameID(), navigationID, error, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); // If we have a load listener, notify it. if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) @@ -497,11 +526,13 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() RefPtr<API::Object> userData; + auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); + // Notify the bundle client. webPage->injectedBundleLoaderClient().didFinishDocumentLoadForFrame(webPage, m_frame, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::dispatchDidFinishLoad() @@ -512,11 +543,13 @@ void WebFrameLoaderClient::dispatchDidFinishLoad() RefPtr<API::Object> userData; + auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID(); + // Notify the bundle client. webPage->injectedBundleLoaderClient().didFinishLoadForFrame(webPage, m_frame, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); // If we have a load listener, notify it. if (WebFrame::LoadListener* loadListener = m_frame->loadListener()) @@ -527,7 +560,7 @@ void WebFrameLoaderClient::dispatchDidFinishLoad() void WebFrameLoaderClient::forcePageTransitionIfNeeded() { - if (m_didCompletePageTransitionAlready) + if (m_didCompletePageTransition) return; WebPage* webPage = m_frame->page(); @@ -535,10 +568,10 @@ void WebFrameLoaderClient::forcePageTransitionIfNeeded() return; webPage->didCompletePageTransition(); - m_didCompletePageTransitionAlready = true; + m_didCompletePageTransition = true; } -void WebFrameLoaderClient::dispatchDidLayout(LayoutMilestones milestones) +void WebFrameLoaderClient::dispatchDidReachLayoutMilestone(LayoutMilestones milestones) { WebPage* webPage = m_frame->page(); if (!webPage) @@ -550,30 +583,35 @@ void WebFrameLoaderClient::dispatchDidLayout(LayoutMilestones milestones) // FIXME: We should consider removing the old didFirstLayout API since this is doing double duty with the // new didLayout API. webPage->injectedBundleLoaderClient().didFirstLayoutForFrame(webPage, m_frame, userData); - webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); - if (m_frame == m_frame->page()->mainWebFrame()) { - if (!webPage->corePage()->settings().suppressesIncrementalRendering() && !m_didCompletePageTransitionAlready) { - webPage->didCompletePageTransition(); - m_didCompletePageTransitionAlready = true; - } +#if PLATFORM(MAC) + // FIXME: Do this on DidFirstVisuallyNonEmptyLayout when Mac Safari is able to handle it (<rdar://problem/17580021>) + if (m_frame->isMainFrame() && !m_didCompletePageTransition && !webPage->corePage()->settings().suppressesIncrementalRendering()) { + webPage->didCompletePageTransition(); + m_didCompletePageTransition = true; } - -#if USE(TILED_BACKING_STORE) +#endif + +#if USE(COORDINATED_GRAPHICS) // Make sure viewport properties are dispatched on the main frame by the time the first layout happens. ASSERT(!webPage->useFixedLayout() || m_frame != m_frame->page()->mainWebFrame() || m_frame->coreFrame()->document()->didDispatchViewportPropertiesChanged()); #endif } // Send this after DidFirstLayout-specific calls since some clients expect to get those messages first. - webPage->injectedBundleLoaderClient().didLayout(webPage, milestones, userData); - webPage->send(Messages::WebPageProxy::DidLayout(milestones, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->dispatchDidReachLayoutMilestone(milestones); if (milestones & DidFirstVisuallyNonEmptyLayout) { + if (m_frame->isMainFrame() && !m_didCompletePageTransition && !webPage->corePage()->settings().suppressesIncrementalRendering()) { + webPage->didCompletePageTransition(); + m_didCompletePageTransition = true; + } + // FIXME: We should consider removing the old didFirstVisuallyNonEmptyLayoutForFrame API since this is doing // double duty with the new didLayout API. webPage->injectedBundleLoaderClient().didFirstVisuallyNonEmptyLayoutForFrame(webPage, m_frame, userData); - webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } } @@ -588,6 +626,10 @@ void WebFrameLoaderClient::dispatchDidLayout() webPage->recomputeShortCircuitHorizontalWheelEventsState(); +#if PLATFORM(IOS) + webPage->updateSelectionAppearance(); +#endif + // NOTE: Unlike the other layout notifications, this does not notify the // the UIProcess for every call. @@ -602,12 +644,13 @@ Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigati { WebPage* webPage = m_frame->page(); if (!webPage) - return 0; + return nullptr; // Just call through to the chrome client. - Page* newPage = webPage->corePage()->chrome().createWindow(m_frame->coreFrame(), FrameLoadRequest(m_frame->coreFrame()->document()->securityOrigin()), WindowFeatures(), navigationAction); + FrameLoadRequest request(m_frame->coreFrame()->document()->securityOrigin(), navigationAction.resourceRequest(), LockHistory::No, LockBackForwardList::No, MaybeSendReferrer, AllowNavigationToInvalidURL::Yes, NewFrameOpenerPolicy::Allow, navigationAction.shouldOpenExternalURLsPolicy()); + Page* newPage = webPage->corePage()->chrome().createWindow(*m_frame->coreFrame(), request, WindowFeatures(), navigationAction); if (!newPage) - return 0; + return nullptr; return &newPage->mainFrame(); } @@ -624,8 +667,10 @@ void WebFrameLoaderClient::dispatchShow() void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& request, FramePolicyFunction function) { WebPage* webPage = m_frame->page(); - if (!webPage) + if (!webPage) { + function(PolicyIgnore); return; + } if (!request.url().string()) { function(PolicyUse); @@ -643,27 +688,30 @@ void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceRespons bool canShowMIMEType = webPage->canShowMIMEType(response.mimeType()); - uint64_t listenerID = m_frame->setUpPolicyListener(std::move(function)); + uint64_t listenerID = m_frame->setUpPolicyListener(WTFMove(function)); bool receivedPolicyAction; uint64_t policyAction; - uint64_t downloadID; + DownloadID downloadID; - // Notify the UIProcess. - // FIXME (126021): It is not good to change IPC behavior conditionally, and SpinRunLoopWhileWaitingForReply was known to cause trouble in other similar cases. - unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? IPC::SpinRunLoopWhileWaitingForReply : 0; - if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponseSync(m_frame->frameID(), response, request, canShowMIMEType, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForResponseSync::Reply(receivedPolicyAction, policyAction, downloadID), std::chrono::milliseconds::max(), syncSendFlags)) + Ref<WebFrame> protect(*m_frame); + WebCore::Frame* coreFrame = m_frame->coreFrame(); + if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForResponseSync(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), response, request, canShowMIMEType, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())), Messages::WebPageProxy::DecidePolicyForResponseSync::Reply(receivedPolicyAction, policyAction, downloadID), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend)) { + m_frame->didReceivePolicyDecision(listenerID, PolicyIgnore, 0, { }); return; + } // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback. if (receivedPolicyAction) - m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID); + m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), 0, downloadID); } -void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, FramePolicyFunction function) +void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction& navigationAction, const ResourceRequest& request, FormState* formState, const String& frameName, FramePolicyFunction function) { WebPage* webPage = m_frame->page(); - if (!webPage) + if (!webPage) { + function(PolicyIgnore); return; + } RefPtr<API::Object> userData; @@ -677,21 +725,29 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const Navigati } - uint64_t listenerID = m_frame->setUpPolicyListener(std::move(function)); + uint64_t listenerID = m_frame->setUpPolicyListener(WTFMove(function)); NavigationActionData navigationActionData; navigationActionData.navigationType = action->navigationType(); navigationActionData.modifiers = action->modifiers(); navigationActionData.mouseButton = action->mouseButton(); + navigationActionData.syntheticClickType = action->syntheticClickType(); + navigationActionData.userGestureTokenIdentifier = WebProcess::singleton().userGestureTokenIdentifier(navigationAction.userGestureToken()); + navigationActionData.canHandleRequest = webPage->canHandleRequest(request); + navigationActionData.shouldOpenExternalURLsPolicy = navigationAction.shouldOpenExternalURLsPolicy(); + navigationActionData.downloadAttribute = navigationAction.downloadAttribute(); - webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), navigationActionData, request, frameName, listenerID, InjectedBundleUserMessageEncoder(userData.get()))); + WebCore::Frame* coreFrame = m_frame ? m_frame->coreFrame() : nullptr; + webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), navigationActionData, request, frameName, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } -void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> prpFormState, FramePolicyFunction function) +void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const NavigationAction& navigationAction, const ResourceRequest& request, FormState* formState, FramePolicyFunction function) { WebPage* webPage = m_frame->page(); - if (!webPage) + if (!webPage) { + function(PolicyIgnore); return; + } // Always ignore requests with empty URLs. if (request.isEmpty()) { @@ -700,7 +756,6 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat } RefPtr<API::Object> userData; - RefPtr<FormState> formState = prpFormState; RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState); @@ -711,26 +766,30 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat return; } - uint64_t listenerID = m_frame->setUpPolicyListener(std::move(function)); + uint64_t listenerID = m_frame->setUpPolicyListener(WTFMove(function)); bool receivedPolicyAction; + uint64_t newNavigationID; uint64_t policyAction; - uint64_t downloadID; + DownloadID downloadID; RefPtr<WebFrame> originatingFrame; switch (action->navigationType()) { - case NavigationTypeLinkClicked: - originatingFrame = action->hitTestResult()->frame(); - break; - case NavigationTypeFormSubmitted: - case NavigationTypeFormResubmitted: - if (formState) { - if (WebFrameLoaderClient* originatingFrameLoaderClient = toWebFrameLoaderClient(formState->sourceDocument()->frame()->loader().client())) - originatingFrame = originatingFrameLoaderClient->webFrame(); + case NavigationType::LinkClicked: + if (EventTarget* target = navigationAction.event()->target()) { + if (Node* node = target->toNode()) { + if (Frame* frame = node->document().frame()) + originatingFrame = WebFrame::fromCoreFrame(*frame); + } } break; - case NavigationTypeBackForward: - case NavigationTypeReload: - case NavigationTypeOther: + case NavigationType::FormSubmitted: + case NavigationType::FormResubmitted: + if (formState) + originatingFrame = WebFrame::fromCoreFrame(*formState->sourceDocument().frame()); + break; + case NavigationType::BackForward: + case NavigationType::Reload: + case NavigationType::Other: break; } @@ -738,14 +797,48 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat navigationActionData.navigationType = action->navigationType(); navigationActionData.modifiers = action->modifiers(); navigationActionData.mouseButton = action->mouseButton(); + navigationActionData.syntheticClickType = action->syntheticClickType(); + navigationActionData.userGestureTokenIdentifier = WebProcess::singleton().userGestureTokenIdentifier(navigationAction.userGestureToken()); + navigationActionData.canHandleRequest = webPage->canHandleRequest(request); + navigationActionData.shouldOpenExternalURLsPolicy = navigationAction.shouldOpenExternalURLsPolicy(); + navigationActionData.downloadAttribute = navigationAction.downloadAttribute(); + + WebCore::Frame* coreFrame = m_frame->coreFrame(); + WebDocumentLoader* documentLoader = static_cast<WebDocumentLoader*>(coreFrame->loader().policyDocumentLoader()); + if (!documentLoader) + documentLoader = static_cast<WebDocumentLoader*>(coreFrame->loader().documentLoader()); // Notify the UIProcess. - if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), navigationActionData, originatingFrame ? originatingFrame->frameID() : 0, navigationAction.resourceRequest(), request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(receivedPolicyAction, policyAction, downloadID))) + Ref<WebFrame> protect(*m_frame); + WebCore::Frame* originatingCoreFrame = originatingFrame ? originatingFrame->coreFrame() : nullptr; + WebsitePolicies websitePolicies; + if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), SecurityOriginData::fromFrame(coreFrame), documentLoader->navigationID(), navigationActionData, originatingFrame ? originatingFrame->frameID() : 0, SecurityOriginData::fromFrame(originatingCoreFrame), navigationAction.resourceRequest(), request, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(receivedPolicyAction, newNavigationID, policyAction, downloadID, websitePolicies))) { + m_frame->didReceivePolicyDecision(listenerID, PolicyIgnore, 0, { }); return; + } + + // Only setUserContentExtensionsEnabled if it hasn't already been disabled by reloading without content blockers. + if (documentLoader->userContentExtensionsEnabled()) + documentLoader->setUserContentExtensionsEnabled(websitePolicies.contentBlockersEnabled); + + switch (websitePolicies.autoplayPolicy) { + case WebsiteAutoplayPolicy::Default: + documentLoader->setAutoplayPolicy(AutoplayPolicy::Default); + break; + case WebsiteAutoplayPolicy::Allow: + documentLoader->setAutoplayPolicy(AutoplayPolicy::Allow); + break; + case WebsiteAutoplayPolicy::AllowWithoutSound: + documentLoader->setAutoplayPolicy(AutoplayPolicy::AllowWithoutSound); + break; + case WebsiteAutoplayPolicy::Deny: + documentLoader->setAutoplayPolicy(AutoplayPolicy::Deny); + break; + } // We call this synchronously because WebCore cannot gracefully handle a frame load without a synchronous navigation policy reply. if (receivedPolicyAction) - m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID); + m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), newNavigationID, downloadID); } void WebFrameLoaderClient::cancelPolicyCheck() @@ -765,49 +858,43 @@ void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError& webPage->injectedBundlePolicyClient().unableToImplementPolicy(webPage, m_frame, error, userData); // Notify the UIProcess. - webPage->send(Messages::WebPageProxy::UnableToImplementPolicy(m_frame->frameID(), error, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::UnableToImplementPolicy(m_frame->frameID(), error, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } -void WebFrameLoaderClient::dispatchWillSendSubmitEvent(PassRefPtr<FormState> prpFormState) +void WebFrameLoaderClient::dispatchWillSendSubmitEvent(Ref<FormState>&& formState) { - WebPage* webPage = m_frame->page(); + auto* webPage = m_frame->page(); if (!webPage) return; - RefPtr<FormState> formState = prpFormState; - HTMLFormElement* form = formState->form(); + auto& form = formState->form(); - WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(formState->sourceDocument()->frame()->loader().client()); - WebFrame* sourceFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; + ASSERT(formState->sourceDocument().frame()); + auto* sourceFrame = WebFrame::fromCoreFrame(*formState->sourceDocument().frame()); ASSERT(sourceFrame); - webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, form, m_frame, sourceFrame, formState->textFieldValues()); + webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, &form, m_frame, sourceFrame, formState->textFieldValues()); } -void WebFrameLoaderClient::dispatchWillSubmitForm(PassRefPtr<FormState> prpFormState, FramePolicyFunction function) +void WebFrameLoaderClient::dispatchWillSubmitForm(FormState& formState, FramePolicyFunction function) { WebPage* webPage = m_frame->page(); if (!webPage) return; - // FIXME: Pass more of the form state. - RefPtr<FormState> formState = prpFormState; - - HTMLFormElement* form = formState->form(); + auto& form = formState.form(); - WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(formState->sourceDocument()->frame()->loader().client()); - WebFrame* sourceFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : 0; + auto* sourceFrame = WebFrame::fromCoreFrame(*formState.sourceDocument().frame()); ASSERT(sourceFrame); - const Vector<std::pair<String, String>>& values = formState->textFieldValues(); + auto& values = formState.textFieldValues(); RefPtr<API::Object> userData; - webPage->injectedBundleFormClient().willSubmitForm(webPage, form, m_frame, sourceFrame, values, userData); - + webPage->injectedBundleFormClient().willSubmitForm(webPage, &form, m_frame, sourceFrame, values, userData); - uint64_t listenerID = m_frame->setUpPolicyListener(std::move(function)); + uint64_t listenerID = m_frame->setUpPolicyListener(WTFMove(function)); - webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), values, listenerID, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::WillSubmitForm(m_frame->frameID(), sourceFrame->frameID(), values, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::revertToProvisionalState(DocumentLoader*) @@ -821,7 +908,7 @@ void WebFrameLoaderClient::setMainDocumentError(DocumentLoader*, const ResourceE return; m_pluginView->manualLoadDidFail(error); - m_pluginView = 0; + m_pluginView = nullptr; m_hasSentResponseToPluginView = false; } @@ -830,9 +917,9 @@ void WebFrameLoaderClient::setMainFrameDocumentReady(bool) notImplemented(); } -void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& /* suggestedName */) +void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& suggestedName) { - m_frame->startDownload(request); + m_frame->startDownload(request, suggestedName); } void WebFrameLoaderClient::willChangeTitle(DocumentLoader*) @@ -845,6 +932,22 @@ void WebFrameLoaderClient::didChangeTitle(DocumentLoader*) notImplemented(); } +void WebFrameLoaderClient::willReplaceMultipartContent() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + webPage->willReplaceMultipartContent(*m_frame); +} + +void WebFrameLoaderClient::didReplaceMultipartContent() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + webPage->didReplaceMultipartContent(*m_frame); +} + void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length) { if (!m_pluginView) @@ -873,8 +976,19 @@ void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* dat void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader) { - if (!m_pluginView) + if (!m_pluginView) { + if (m_frameHasCustomContentProvider) { + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + RefPtr<SharedBuffer> mainResourceData = loader->mainResourceData(); + IPC::DataReference dataReference(reinterpret_cast<const uint8_t*>(mainResourceData ? mainResourceData->data() : 0), mainResourceData ? mainResourceData->size() : 0); + webPage->send(Messages::WebPageProxy::DidFinishLoadingDataForCustomContentProvider(loader->response().suggestedFilename(), dataReference)); + } + return; + } // If we just received an empty response without any data, we won't have sent a response to the plug-in view. // Make sure to do this before calling manualLoadDidFinishLoading. @@ -887,7 +1001,7 @@ void WebFrameLoaderClient::finishedLoading(DocumentLoader* loader) } m_pluginView->manualLoadDidFinishLoading(); - m_pluginView = 0; + m_pluginView = nullptr; m_hasSentResponseToPluginView = false; } @@ -901,12 +1015,12 @@ void WebFrameLoaderClient::updateGlobalHistory() WebNavigationDataStore data; data.url = loader->url().string(); - // FIXME: use direction of title. - data.title = loader->title().string(); + // FIXME: Use direction of title. + data.title = loader->title().string; data.originalRequest = loader->originalRequestCopy(); data.response = loader->response(); - WebProcess::shared().parentProcessConnection()->send(Messages::WebProcessProxy::DidNavigateWithNavigationData(webPage->pageID(), data, m_frame->frameID()), 0); + webPage->send(Messages::WebPageProxy::DidNavigateWithNavigationData(data, m_frame->frameID())); } void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks() @@ -920,14 +1034,14 @@ void WebFrameLoaderClient::updateGlobalHistoryRedirectLinks() // Client redirect if (!loader->clientRedirectSourceForHistory().isNull()) { - WebProcess::shared().parentProcessConnection()->send(Messages::WebProcessProxy::DidPerformClientRedirect(webPage->pageID(), - loader->clientRedirectSourceForHistory(), loader->clientRedirectDestinationForHistory(), m_frame->frameID()), 0); + webPage->send(Messages::WebPageProxy::DidPerformClientRedirect( + loader->clientRedirectSourceForHistory(), loader->clientRedirectDestinationForHistory(), m_frame->frameID())); } // Server redirect if (!loader->serverRedirectSourceForHistory().isNull()) { - WebProcess::shared().parentProcessConnection()->send(Messages::WebProcessProxy::DidPerformServerRedirect(webPage->pageID(), - loader->serverRedirectSourceForHistory(), loader->serverRedirectDestinationForHistory(), m_frame->frameID()), 0); + webPage->send(Messages::WebPageProxy::DidPerformServerRedirect( + loader->serverRedirectSourceForHistory(), loader->serverRedirectDestinationForHistory(), m_frame->frameID())); } } @@ -952,7 +1066,7 @@ bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const if (!shouldGoToBackForwardListItem) return false; - webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::WillGoToBackForwardListItem(itemID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); return true; } @@ -966,10 +1080,10 @@ void WebFrameLoaderClient::didDisplayInsecureContent() webPage->injectedBundleLoaderClient().didDisplayInsecureContentForFrame(webPage, m_frame, userData); - webPage->send(Messages::WebPageProxy::DidDisplayInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidDisplayInsecureContentForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } -void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*, const URL&) +void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin&, const URL&) { WebPage* webPage = m_frame->page(); if (!webPage) @@ -979,7 +1093,7 @@ void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin*, const URL&) webPage->injectedBundleLoaderClient().didRunInsecureContentForFrame(webPage, m_frame, userData); - webPage->send(Messages::WebPageProxy::DidRunInsecureContentForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidRunInsecureContentForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } void WebFrameLoaderClient::didDetectXSS(const URL&, bool) @@ -992,7 +1106,7 @@ void WebFrameLoaderClient::didDetectXSS(const URL&, bool) webPage->injectedBundleLoaderClient().didDetectXSSForFrame(webPage, m_frame, userData); - webPage->send(Messages::WebPageProxy::DidDetectXSSForFrame(m_frame->frameID(), InjectedBundleUserMessageEncoder(userData.get()))); + webPage->send(Messages::WebPageProxy::DidDetectXSSForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); } ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request) @@ -1005,6 +1119,11 @@ ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request) return WebKit::blockedError(request); } +ResourceError WebFrameLoaderClient::blockedByContentBlockerError(const ResourceRequest& request) +{ + return WebKit::blockedByContentBlockerError(request); +} + ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request) { return WebKit::cannotShowURLError(request); @@ -1015,6 +1134,13 @@ ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const Resour return WebKit::interruptedForPolicyChangeError(request); } +#if ENABLE(CONTENT_FILTERING) +ResourceError WebFrameLoaderClient::blockedByContentFilterError(const ResourceRequest& request) +{ + return WebKit::blockedByContentFilterError(request); +} +#endif + ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response) { return WebKit::cannotShowMIMETypeError(response); @@ -1080,19 +1206,34 @@ void WebFrameLoaderClient::frameLoadCompleted() if (!webPage) return; - if (m_frame == m_frame->page()->mainWebFrame() && !m_didCompletePageTransitionAlready) { + if (m_frame->isMainFrame() && !m_didCompletePageTransition) { webPage->didCompletePageTransition(); - m_didCompletePageTransitionAlready = true; + m_didCompletePageTransition = true; } } -void WebFrameLoaderClient::saveViewStateToItem(HistoryItem*) +void WebFrameLoaderClient::saveViewStateToItem(HistoryItem& historyItem) { - notImplemented(); +#if PLATFORM(IOS) + if (m_frame->isMainFrame()) + m_frame->page()->savePageState(historyItem); +#else + UNUSED_PARAM(historyItem); +#endif } void WebFrameLoaderClient::restoreViewState() { +#if PLATFORM(IOS) + Frame& frame = *m_frame->coreFrame(); + HistoryItem* currentItem = frame.loader().history().currentItem(); + if (FrameView* view = frame.view()) { + if (m_frame->isMainFrame()) + m_frame->page()->restorePageState(*currentItem); + else if (!view->wasScrolledByUser()) + view->setScrollPosition(currentItem->scrollPosition()); + } +#else // Inform the UI process of the scale factor. double scaleFactor = m_frame->coreFrame()->loader().history().currentItem()->pageScaleFactor(); @@ -1102,8 +1243,9 @@ void WebFrameLoaderClient::restoreViewState() // FIXME: This should not be necessary. WebCore should be correctly invalidating // the view on restores from the back/forward cache. - if (m_frame == m_frame->page()->mainWebFrame()) + if (m_frame->page() && m_frame == m_frame->page()->mainWebFrame()) m_frame->page()->drawingArea()->setNeedsDisplay(); +#endif } void WebFrameLoaderClient::provisionalLoadStarted() @@ -1112,9 +1254,9 @@ void WebFrameLoaderClient::provisionalLoadStarted() if (!webPage) return; - if (m_frame == m_frame->page()->mainWebFrame()) { + if (m_frame->isMainFrame()) { webPage->didStartPageTransition(); - m_didCompletePageTransitionAlready = false; + m_didCompletePageTransition = false; } } @@ -1130,20 +1272,24 @@ void WebFrameLoaderClient::prepareForDataSourceReplacement() notImplemented(); } -PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) +Ref<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData) { return m_frame->page()->createDocumentLoader(*m_frame->coreFrame(), request, substituteData); } +void WebFrameLoaderClient::updateCachedDocumentLoader(WebCore::DocumentLoader& loader) +{ + m_frame->page()->updateCachedDocumentLoader(static_cast<WebDocumentLoader&>(loader), *m_frame->coreFrame()); +} + void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const URL& url) { WebPage* webPage = m_frame->page(); if (!webPage || !webPage->pageGroup()->isVisibleToHistoryClient()) return; - // FIXME: use direction of title. - WebProcess::shared().parentProcessConnection()->send(Messages::WebProcessProxy::DidUpdateHistoryTitle(webPage->pageID(), - title.string(), url.string(), m_frame->frameID()), 0); + // FIXME: Use direction of title. + webPage->send(Messages::WebPageProxy::DidUpdateHistoryTitle(title.string, url.string(), m_frame->frameID())); } String WebFrameLoaderClient::userAgent(const URL& url) @@ -1152,53 +1298,78 @@ String WebFrameLoaderClient::userAgent(const URL& url) if (!webPage) return String(); - return webPage->userAgent(url); + return webPage->userAgent(m_frame, url); +} + +String WebFrameLoaderClient::overrideContentSecurityPolicy() const +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return String(); + + return webPage->overrideContentSecurityPolicy(); } -void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame*) +void WebFrameLoaderClient::savePlatformDataToCachedFrame(CachedFrame* cachedFrame) { + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + HasInsecureContent hasInsecureContent; + if (webPage->sendSync(Messages::WebPageProxy::HasInsecureContent(), Messages::WebPageProxy::HasInsecureContent::Reply(hasInsecureContent))) + cachedFrame->setHasInsecureContent(hasInsecureContent); } void WebFrameLoaderClient::transitionToCommittedFromCachedFrame(CachedFrame*) { + const ResourceResponse& response = m_frame->coreFrame()->loader().documentLoader()->response(); + m_frameHasCustomContentProvider = m_frame->isMainFrame() && m_frame->page()->shouldUseCustomContentProviderForResponse(response); + m_frameCameFromPageCache = true; } void WebFrameLoaderClient::transitionToCommittedForNewPage() { WebPage* webPage = m_frame->page(); - Color backgroundColor = webPage->drawsTransparentBackground() ? Color::transparent : Color::white; - bool isMainFrame = webPage->mainWebFrame() == m_frame; + Color backgroundColor = webPage->drawsBackground() ? Color::white : Color::transparent; + bool isMainFrame = m_frame->isMainFrame(); bool isTransparent = !webPage->drawsBackground(); bool shouldUseFixedLayout = isMainFrame && webPage->useFixedLayout(); bool shouldDisableScrolling = isMainFrame && !webPage->mainFrameIsScrollable(); - bool shouldHideScrollbars = shouldUseFixedLayout || shouldDisableScrolling; + bool shouldHideScrollbars = shouldDisableScrolling; IntRect fixedVisibleContentRect; -#if USE(TILED_BACKING_STORE) +#if USE(COORDINATED_GRAPHICS) if (m_frame->coreFrame()->view()) fixedVisibleContentRect = m_frame->coreFrame()->view()->fixedVisibleContentRect(); + if (shouldUseFixedLayout) + shouldHideScrollbars = true; #endif + const ResourceResponse& response = m_frame->coreFrame()->loader().documentLoader()->response(); + m_frameHasCustomContentProvider = isMainFrame && webPage->shouldUseCustomContentProviderForResponse(response); m_frameCameFromPageCache = false; ScrollbarMode defaultScrollbarMode = shouldHideScrollbars ? ScrollbarAlwaysOff : ScrollbarAuto; m_frame->coreFrame()->createView(webPage->size(), backgroundColor, isTransparent, - IntSize(), fixedVisibleContentRect, shouldUseFixedLayout, + webPage->fixedLayoutSize(), fixedVisibleContentRect, shouldUseFixedLayout, defaultScrollbarMode, /* lock */ shouldHideScrollbars, defaultScrollbarMode, /* lock */ shouldHideScrollbars); if (int minimumLayoutWidth = webPage->minimumLayoutSize().width()) { int minimumLayoutHeight = std::max(webPage->minimumLayoutSize().height(), 1); int maximumSize = std::numeric_limits<int>::max(); m_frame->coreFrame()->view()->enableAutoSizeMode(true, IntSize(minimumLayoutWidth, minimumLayoutHeight), IntSize(maximumSize, maximumSize)); - m_frame->coreFrame()->view()->setAutoSizeFixedMinimumHeight(webPage->size().height()); + + if (webPage->autoSizingShouldExpandToViewHeight()) + m_frame->coreFrame()->view()->setAutoSizeFixedMinimumHeight(webPage->size().height()); } m_frame->coreFrame()->view()->setProhibitsScrolling(shouldDisableScrolling); m_frame->coreFrame()->view()->setVisualUpdatesAllowedByClient(!webPage->shouldExtendIncrementalRenderingSuppression()); -#if PLATFORM(MAC) - m_frame->coreFrame()->view()->setExposedRect(webPage->drawingArea()->exposedRect()); +#if PLATFORM(COCOA) + m_frame->coreFrame()->view()->setViewExposedRect(webPage->drawingArea()->viewExposedRect()); #endif #if PLATFORM(IOS) m_frame->coreFrame()->view()->setDelegatesScrolling(true); @@ -1207,7 +1378,7 @@ void WebFrameLoaderClient::transitionToCommittedForNewPage() if (webPage->scrollPinningBehavior() != DoNotPin) m_frame->coreFrame()->view()->setScrollPinningBehavior(webPage->scrollPinningBehavior()); -#if USE(TILED_BACKING_STORE) +#if USE(COORDINATED_GRAPHICS) if (shouldUseFixedLayout) { m_frame->coreFrame()->view()->setDelegatesScrolling(shouldUseFixedLayout); m_frame->coreFrame()->view()->setPaintsEntireContents(shouldUseFixedLayout); @@ -1222,7 +1393,8 @@ void WebFrameLoaderClient::didSaveToPageCache() if (!webPage) return; - webPage->send(Messages::WebPageProxy::DidSaveToPageCache()); + if (m_frame->isMainFrame()) + webPage->send(Messages::WebPageProxy::DidSaveToPageCache()); } void WebFrameLoaderClient::didRestoreFromPageCache() @@ -1239,39 +1411,45 @@ void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool value) webPage->send(Messages::WebPageProxy::FrameDidBecomeFrameSet(m_frame->frameID(), value)); } -void WebFrameLoaderClient::convertMainResourceLoadToDownload(DocumentLoader *documentLoader, const ResourceRequest& request, const ResourceResponse& response) +bool WebFrameLoaderClient::canCachePage() const { - m_frame->convertMainResourceLoadToDownload(documentLoader, request, response); + // We cannot cache frames that have custom representations because they are + // rendered in the UIProcess. + return !m_frameHasCustomContentProvider; } -PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const URL& url, const String& name, HTMLFrameOwnerElement* ownerElement, - const String& referrer, bool /*allowsScrolling*/, int /*marginWidth*/, int /*marginHeight*/) +void WebFrameLoaderClient::convertMainResourceLoadToDownload(DocumentLoader *documentLoader, SessionID sessionID, const ResourceRequest& request, const ResourceResponse& response) { - WebPage* webPage = m_frame->page(); + m_frame->convertMainResourceLoadToDownload(documentLoader, sessionID, request, response); +} - RefPtr<WebFrame> subframe = WebFrame::createSubframe(webPage, name, ownerElement); +RefPtr<Frame> WebFrameLoaderClient::createFrame(const URL& url, const String& name, HTMLFrameOwnerElement& ownerElement, + const String& referrer, bool /*allowsScrolling*/, int /*marginWidth*/, int /*marginHeight*/) +{ + auto* webPage = m_frame->page(); - Frame* coreSubframe = subframe->coreFrame(); + auto subframe = WebFrame::createSubframe(webPage, name, &ownerElement); + auto* coreSubframe = subframe->coreFrame(); if (!coreSubframe) - return 0; + return nullptr; // The creation of the frame may have run arbitrary JavaScript that removed it from the page already. if (!coreSubframe->page()) - return 0; + return nullptr; m_frame->coreFrame()->loader().loadURLIntoChildFrame(url, referrer, coreSubframe); // The frame's onload handler may have removed it from the document. if (!subframe->coreFrame()) - return 0; + return nullptr; ASSERT(subframe->coreFrame() == coreSubframe); if (!coreSubframe->tree().parent()) - return 0; + return nullptr; return coreSubframe; } -PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement* pluginElement, const URL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) +RefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElement& pluginElement, const URL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually) { ASSERT(paramNames.size() == paramValues.size()); ASSERT(m_frame->page()); @@ -1283,165 +1461,141 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugIn parameters.mimeType = mimeType; parameters.isFullFramePlugin = loadManually; parameters.shouldUseManualLoader = parameters.isFullFramePlugin && !m_frameCameFromPageCache; -#if PLATFORM(MAC) +#if PLATFORM(COCOA) parameters.layerHostingMode = m_frame->page()->layerHostingMode(); #endif -#if PLUGIN_ARCHITECTURE(X11) - // FIXME: This should really be X11-specific plug-in quirks. - if (equalIgnoringCase(mimeType, "application/x-shockwave-flash")) { - // Currently we don't support transparency and windowed mode. - // Inject wmode=opaque to make Flash work in these conditions. - size_t wmodeIndex = parameters.names.find("wmode"); - if (wmodeIndex == notFound) { - parameters.names.append("wmode"); - parameters.values.append("opaque"); - } else if (equalIgnoringCase(parameters.values[wmodeIndex], "window")) - parameters.values[wmodeIndex] = "opaque"; - } else if (equalIgnoringCase(mimeType, "application/x-webkit-test-netscape")) { - parameters.names.append("windowedPlugin"); - parameters.values.append("false"); - } -#endif - #if ENABLE(NETSCAPE_PLUGIN_API) - RefPtr<Plugin> plugin = m_frame->page()->createPlugin(m_frame, pluginElement, parameters, parameters.mimeType); + auto plugin = m_frame->page()->createPlugin(m_frame, &pluginElement, parameters, parameters.mimeType); if (!plugin) - return 0; + return nullptr; - return PluginView::create(pluginElement, plugin.release(), parameters); + return PluginView::create(pluginElement, plugin.releaseNonNull(), parameters); #else UNUSED_PARAM(pluginElement); - return 0; + return nullptr; #endif } void WebFrameLoaderClient::recreatePlugin(Widget* widget) { #if ENABLE(NETSCAPE_PLUGIN_API) - ASSERT(widget && widget->isPluginViewBase()); + ASSERT(widget); + ASSERT(widget->isPluginViewBase()); ASSERT(m_frame->page()); - PluginView* pluginView = static_cast<PluginView*>(widget); + auto& pluginView = static_cast<PluginView&>(*widget); String newMIMEType; - RefPtr<Plugin> plugin = m_frame->page()->createPlugin(m_frame, pluginView->pluginElement(), pluginView->initialParameters(), newMIMEType); - pluginView->recreateAndInitialize(plugin.release()); + auto plugin = m_frame->page()->createPlugin(m_frame, pluginView.pluginElement(), pluginView.initialParameters(), newMIMEType); + pluginView.recreateAndInitialize(plugin.releaseNonNull()); #else UNUSED_PARAM(widget); #endif } -void WebFrameLoaderClient::redirectDataToPlugin(Widget* pluginWidget) +void WebFrameLoaderClient::redirectDataToPlugin(Widget& pluginWidget) { - if (pluginWidget) - m_pluginView = static_cast<PluginView*>(pluginWidget); + m_pluginView = static_cast<PluginView*>(&pluginWidget); } #if ENABLE(WEBGL) + WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const String& url) const { - if (WebPage* webPage = m_frame->page()) + if (auto* webPage = m_frame->page()) return webPage->webGLPolicyForURL(m_frame, url); - return WebGLAllow; + return WebGLAllowCreation; +} + +WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const String& url) const +{ + if (auto* webPage = m_frame->page()) + return webPage->resolveWebGLPolicyForURL(m_frame, url); + + return WebGLAllowCreation; } -#endif // ENABLE(WEBGL) -PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement* appletElement, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues) +#endif + +RefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& pluginSize, HTMLAppletElement& appletElement, const URL&, const Vector<String>& paramNames, const Vector<String>& paramValues) { #if ENABLE(NETSCAPE_PLUGIN_API) - RefPtr<Widget> plugin = createPlugin(pluginSize, appletElement, URL(), paramNames, paramValues, appletElement->serviceType(), false); + auto plugin = createPlugin(pluginSize, appletElement, URL(), paramNames, paramValues, appletElement.serviceType(), false); if (!plugin) { - if (WebPage* webPage = m_frame->page()) { - String frameURLString = m_frame->coreFrame()->loader().documentLoader()->responseURL().string(); - String pageURLString = webPage->corePage()->mainFrame().loader().documentLoader()->responseURL().string(); - webPage->send(Messages::WebPageProxy::DidFailToInitializePlugin(appletElement->serviceType(), frameURLString, pageURLString)); + if (auto* webPage = m_frame->page()) { + auto frameURLString = m_frame->coreFrame()->loader().documentLoader()->responseURL().string(); + auto pageURLString = webPage->corePage()->mainFrame().loader().documentLoader()->responseURL().string(); + webPage->send(Messages::WebPageProxy::DidFailToInitializePlugin(appletElement.serviceType(), frameURLString, pageURLString)); } } - return plugin.release(); + return plugin; #else UNUSED_PARAM(pluginSize); UNUSED_PARAM(appletElement); UNUSED_PARAM(paramNames); UNUSED_PARAM(paramValues); - return 0; + return nullptr; #endif } -#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) -PassRefPtr<Widget> WebFrameLoaderClient::createMediaPlayerProxyPlugin(const IntSize&, HTMLMediaElement*, const URL&, const Vector<String>&, const Vector<String>&, const String&) -{ - notImplemented(); - return 0; -} - -void WebFrameLoaderClient::hideMediaPlayerProxyPlugin(Widget*) -{ - notImplemented(); -} - -void WebFrameLoaderClient::showMediaPlayerProxyPlugin(Widget*) -{ - notImplemented(); -} -#endif - static bool pluginSupportsExtension(const PluginData& pluginData, const String& extension) { - ASSERT(extension.lower() == extension); - - for (size_t i = 0; i < pluginData.mimes().size(); ++i) { - const MimeClassInfo& mimeClassInfo = pluginData.mimes()[i]; - + ASSERT(extension.convertToASCIILowercase() == extension); + Vector<MimeClassInfo> mimes; + Vector<size_t> mimePluginIndices; + pluginData.getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices); + for (auto& mimeClassInfo : mimes) { if (mimeClassInfo.extensions.contains(extension)) return true; } return false; } -ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const String& mimeTypeIn, bool shouldPreferPlugInsForImages) +ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const String& mimeTypeIn) { - // FIXME: This should be merged with WebCore::FrameLoader::defaultObjectContentType when the plugin code - // is consolidated. + // FIXME: This should eventually be merged with WebCore::FrameLoader::defaultObjectContentType. String mimeType = mimeTypeIn; if (mimeType.isEmpty()) { - String extension = url.path().substring(url.path().reverseFind('.') + 1).lower(); + String path = url.path(); + auto dotPosition = path.reverseFind('.'); + if (dotPosition == notFound) + return ObjectContentType::Frame; + String extension = path.substring(dotPosition + 1).convertToASCIILowercase(); // Try to guess the MIME type from the extension. mimeType = MIMETypeRegistry::getMIMETypeForExtension(extension); - if (mimeType.isEmpty()) { // Check if there's a plug-in around that can handle the extension. if (WebPage* webPage = m_frame->page()) { if (pluginSupportsExtension(webPage->corePage()->pluginData(), extension)) - return ObjectContentNetscapePlugin; + return ObjectContentType::PlugIn; } + return ObjectContentType::Frame; } } - if (mimeType.isEmpty()) - return ObjectContentFrame; + if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) + return ObjectContentType::Image; - bool plugInSupportsMIMEType = false; if (WebPage* webPage = m_frame->page()) { - const PluginData& pluginData = webPage->corePage()->pluginData(); - if (pluginData.supportsMimeType(mimeType, PluginData::AllPlugins) && webFrame()->coreFrame()->loader().subframeLoader().allowPlugins(NotAboutToInstantiatePlugin)) - plugInSupportsMIMEType = true; - else if (pluginData.supportsMimeType(mimeType, PluginData::OnlyApplicationPlugins)) - plugInSupportsMIMEType = true; + auto allowedPluginTypes = webFrame()->coreFrame()->loader().subframeLoader().allowPlugins() + ? PluginData::AllPlugins : PluginData::OnlyApplicationPlugins; + if (webPage->corePage()->pluginData().supportsMimeType(mimeType, allowedPluginTypes)) + return ObjectContentType::PlugIn; } - - if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType)) - return shouldPreferPlugInsForImages && plugInSupportsMIMEType ? ObjectContentNetscapePlugin : ObjectContentImage; - - if (plugInSupportsMIMEType) - return ObjectContentNetscapePlugin; if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)) - return ObjectContentFrame; + return ObjectContentType::Frame; - return ObjectContentNone; +#if PLATFORM(IOS) + // iOS can render PDF in <object>/<embed> via PDFDocumentImage. + if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(mimeType)) + return ObjectContentType::Image; +#endif + + return ObjectContentType::None; } String WebFrameLoaderClient::overrideMediaType() const @@ -1458,7 +1612,12 @@ void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(webPage, m_frame, world); -#if HAVE(ACCESSIBILITY) && (PLATFORM(GTK) || PLATFORM(EFL)) + + WebAutomationSessionProxy* automationSessionProxy = WebProcess::singleton().automationSessionProxy(); + if (automationSessionProxy && world.isNormal()) + automationSessionProxy->didClearWindowObjectForFrame(*m_frame); + +#if HAVE(ACCESSIBILITY) && PLATFORM(GTK) // Ensure the accessibility hierarchy is updated. webPage->updateAccessibilityTree(); #endif @@ -1506,7 +1665,7 @@ void WebFrameLoaderClient::registerForIconNotification(bool /*listen*/) notImplemented(); } -#if PLATFORM(MAC) +#if PLATFORM(COCOA) RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject() { @@ -1517,7 +1676,7 @@ RemoteAXObjectRef WebFrameLoaderClient::accessibilityRemoteObject() return webPage->accessibilityRemoteObject(); } -NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const +NSCachedURLResponse *WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long identifier, NSCachedURLResponse* response) const { WebPage* webPage = m_frame->page(); if (!webPage) @@ -1526,7 +1685,16 @@ NSCachedURLResponse* WebFrameLoaderClient::willCacheResponse(DocumentLoader*, un return webPage->injectedBundleResourceLoadClient().shouldCacheResponse(webPage, m_frame, identifier) ? response : nil; } -#endif // PLATFORM(MAC) +NSDictionary *WebFrameLoaderClient::dataDetectionContext() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return nil; + + return webPage->dataDetectionContext(); +} + +#endif // PLATFORM(COCOA) bool WebFrameLoaderClient::shouldAlwaysUsePluginDocument(const String& /*mimeType*/) const { @@ -1540,17 +1708,7 @@ void WebFrameLoaderClient::didChangeScrollOffset() if (!webPage) return; - webPage->drawingArea()->didChangeScrollOffsetForAnyFrame(); - - if (!m_frame->isMainFrame()) - return; - - // If this is called when tearing down a FrameView, the WebCore::Frame's - // current FrameView will be null. - if (!m_frame->coreFrame()->view()) - return; - - webPage->updateMainFrameScrollOffsetPinning(); + webPage->didChangeScrollOffsetForFrame(m_frame->coreFrame()); } bool WebFrameLoaderClient::allowScript(bool enabledPerSettings) @@ -1583,10 +1741,67 @@ bool WebFrameLoaderClient::shouldForceUniversalAccessFromLocalURL(const WebCore: return webPage->injectedBundleLoaderClient().shouldForceUniversalAccessFromLocalURL(webPage, url.string()); } -PassRefPtr<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext() +Ref<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext() { - RefPtr<WebFrameNetworkingContext> context = WebFrameNetworkingContext::create(m_frame); - return context.release(); + return WebFrameNetworkingContext::create(m_frame); +} + +#if ENABLE(CONTENT_FILTERING) + +void WebFrameLoaderClient::contentFilterDidBlockLoad(WebCore::ContentFilterUnblockHandler unblockHandler) +{ + if (!unblockHandler.needsUIProcess()) { + m_frame->coreFrame()->loader().policyChecker().setContentFilterUnblockHandler(WTFMove(unblockHandler)); + return; + } + + if (WebPage* webPage { m_frame->page() }) + webPage->send(Messages::WebPageProxy::ContentFilterDidBlockLoadForFrame(unblockHandler, m_frame->frameID())); +} + +#endif + +#if ENABLE(REQUEST_AUTOCOMPLETE) + +void WebFrameLoaderClient::didRequestAutocomplete(Ref<WebCore::FormState>&&) +{ +} + +#endif + +void WebFrameLoaderClient::prefetchDNS(const String& hostname) +{ + WebProcess::singleton().prefetchDNS(hostname); +} + +void WebFrameLoaderClient::didRestoreScrollPosition() +{ + WebPage* webPage = m_frame->page(); + if (!webPage) + return; + + webPage->didRestoreScrollPosition(); +} + +bool WebFrameLoaderClient::useIconLoadingClient() +{ + return m_useIconLoadingClient; +} + +void WebFrameLoaderClient::getLoadDecisionForIcon(const LinkIcon& icon, uint64_t callbackID) +{ + if (WebPage* webPage { m_frame->page() }) + webPage->send(Messages::WebPageProxy::GetLoadDecisionForIcon(icon, callbackID)); +} + +void WebFrameLoaderClient::finishedLoadingIcon(uint64_t loadIdentifier, SharedBuffer* data) +{ + if (WebPage* webPage { m_frame->page() }) { + if (data) + webPage->send(Messages::WebPageProxy::FinishedLoadingIcon(loadIdentifier, { reinterpret_cast<const uint8_t*>(data->data()), data->size() })); + else + webPage->send(Messages::WebPageProxy::FinishedLoadingIcon(loadIdentifier, { nullptr, 0 })); + } } } // namespace WebKit |