| 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 | #pragma once |
| 27 | |
| 28 | #include "MessageReceiver.h" |
| 29 | #include "SandboxExtension.h" |
| 30 | #include "WebFramePolicyListenerProxy.h" |
| 31 | #include "WebPageProxyMessages.h" |
| 32 | #include "WebsitePoliciesData.h" |
| 33 | #include <wtf/WeakPtr.h> |
| 34 | |
| 35 | namespace API { |
| 36 | class Navigation; |
| 37 | } |
| 38 | |
| 39 | namespace IPC { |
| 40 | class FormDataReference; |
| 41 | } |
| 42 | |
| 43 | namespace WebCore { |
| 44 | class ResourceRequest; |
| 45 | struct BackForwardItemIdentifier; |
| 46 | } |
| 47 | |
| 48 | namespace WebKit { |
| 49 | |
| 50 | class DrawingAreaProxy; |
| 51 | class SuspendedPageProxy; |
| 52 | class UserData; |
| 53 | class WebFrameProxy; |
| 54 | class WebPageProxy; |
| 55 | class WebProcessProxy; |
| 56 | struct FrameInfoData; |
| 57 | struct NavigationActionData; |
| 58 | struct URLSchemeTaskParameters; |
| 59 | struct WebNavigationDataStore; |
| 60 | |
| 61 | class ProvisionalPageProxy : public IPC::MessageReceiver, public CanMakeWeakPtr<ProvisionalPageProxy> { |
| 62 | WTF_MAKE_FAST_ALLOCATED; |
| 63 | public: |
| 64 | ProvisionalPageProxy(WebPageProxy&, Ref<WebProcessProxy>&&, std::unique_ptr<SuspendedPageProxy>, uint64_t navigationID, bool isServerRedirect, const WebCore::ResourceRequest&, ProcessSwapRequestedByClient); |
| 65 | ~ProvisionalPageProxy(); |
| 66 | |
| 67 | WebPageProxy& page() { return m_page; } |
| 68 | WebFrameProxy* mainFrame() const { return m_mainFrame.get(); } |
| 69 | WebProcessProxy& process() { return m_process.get(); } |
| 70 | ProcessSwapRequestedByClient processSwapRequestedByClient() const { return m_processSwapRequestedByClient; } |
| 71 | uint64_t navigationID() const { return m_navigationID; } |
| 72 | const URL& provisionalURL() const { return m_provisionalLoadURL; } |
| 73 | |
| 74 | DrawingAreaProxy* drawingArea() const { return m_drawingArea.get(); } |
| 75 | std::unique_ptr<DrawingAreaProxy> takeDrawingArea(); |
| 76 | |
| 77 | void setNavigationID(uint64_t navigationID) { m_navigationID = navigationID; } |
| 78 | |
| 79 | #if PLATFORM(COCOA) |
| 80 | Vector<uint8_t> takeAccessibilityToken() { return WTFMove(m_accessibilityToken); } |
| 81 | #endif |
| 82 | |
| 83 | void loadData(API::Navigation&, const IPC::DataReference&, const String& MIMEType, const String& encoding, const String& baseURL, API::Object* userData, Optional<WebsitePoliciesData>&& = WTF::nullopt); |
| 84 | void loadRequest(API::Navigation&, WebCore::ResourceRequest&&, WebCore::ShouldOpenExternalURLsPolicy, API::Object* userData, Optional<WebsitePoliciesData>&& = WTF::nullopt); |
| 85 | void goToBackForwardItem(API::Navigation&, WebBackForwardListItem&, Optional<WebsitePoliciesData>&&); |
| 86 | void cancel(); |
| 87 | |
| 88 | void processDidTerminate(); |
| 89 | void connectionWillOpen(IPC::Connection&); |
| 90 | |
| 91 | private: |
| 92 | // IPC::MessageReceiver |
| 93 | void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; |
| 94 | void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final; |
| 95 | |
| 96 | void decidePolicyForNavigationActionAsync(uint64_t frameID, WebCore::SecurityOriginData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&, FrameInfoData&&, |
| 97 | uint64_t originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody, |
| 98 | WebCore::ResourceResponse&& redirectResponse, const UserData&, uint64_t listenerID); |
| 99 | void decidePolicyForResponse(uint64_t frameID, const WebCore::SecurityOriginData&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, const WebCore::ResourceResponse&, |
| 100 | const WebCore::ResourceRequest&, bool canShowMIMEType, const String& downloadAttribute, uint64_t listenerID, const UserData&); |
| 101 | void didChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, URL&&); |
| 102 | void didPerformServerRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID); |
| 103 | void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceRequest&&, const UserData&); |
| 104 | void didNavigateWithNavigationData(const WebNavigationDataStore&, uint64_t frameID); |
| 105 | void didPerformClientRedirect(const String& sourceURLString, const String& destinationURLString, uint64_t frameID); |
| 106 | void didCreateMainFrame(uint64_t frameID); |
| 107 | void didStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, URL&&, URL&& unreachableURL, const UserData&); |
| 108 | void didCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, const String& mimeType, bool frameHasCustomContentProvider, uint32_t frameLoadType, const WebCore::CertificateInfo&, bool containsPluginDocument, Optional<WebCore::HasInsecureContent> forcedHasInsecureContent, const UserData&); |
| 109 | void didFailProvisionalLoadForFrame(uint64_t frameID, const WebCore::SecurityOriginData& frameSecurityOrigin, uint64_t navigationID, const String& provisionalURL, const WebCore::ResourceError&, WebCore::WillContinueLoading, const UserData&); |
| 110 | void startURLSchemeTask(URLSchemeTaskParameters&&); |
| 111 | void backForwardGoToItem(const WebCore::BackForwardItemIdentifier&, CompletionHandler<void(SandboxExtension::Handle&&)>&&); |
| 112 | void decidePolicyForNavigationActionSync(uint64_t frameID, bool isMainFrame, WebCore::SecurityOriginData&&, WebCore::PolicyCheckIdentifier, uint64_t navigationID, NavigationActionData&&, |
| 113 | FrameInfoData&&, uint64_t originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody, |
| 114 | WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSync::DelayedReply&&); |
| 115 | #if USE(QUICK_LOOK) |
| 116 | void didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName); |
| 117 | #endif |
| 118 | #if PLATFORM(COCOA) |
| 119 | void registerWebProcessAccessibilityToken(const IPC::DataReference&); |
| 120 | #endif |
| 121 | |
| 122 | void initializeWebPage(); |
| 123 | bool validateInput(uint64_t frameID, const Optional<uint64_t>& navigationID = WTF::nullopt); |
| 124 | |
| 125 | WebPageProxy& m_page; |
| 126 | Ref<WebProcessProxy> m_process; |
| 127 | std::unique_ptr<DrawingAreaProxy> m_drawingArea; |
| 128 | RefPtr<WebFrameProxy> m_mainFrame; |
| 129 | uint64_t m_navigationID; |
| 130 | bool m_isServerRedirect; |
| 131 | WebCore::ResourceRequest m_request; |
| 132 | ProcessSwapRequestedByClient m_processSwapRequestedByClient; |
| 133 | bool m_wasCommitted { false }; |
| 134 | URL m_provisionalLoadURL; |
| 135 | |
| 136 | #if PLATFORM(COCOA) |
| 137 | Vector<uint8_t> m_accessibilityToken; |
| 138 | #endif |
| 139 | #if PLATFORM(IOS_FAMILY) |
| 140 | ProcessThrottler::ForegroundActivityToken m_suspensionToken; |
| 141 | #endif |
| 142 | }; |
| 143 | |
| 144 | } // namespace WebKit |
| 145 | |