[Quick Look] Clean up LegacyPreviewLoaderClients
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 04:14:39 +0000 (04:14 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 04:14:39 +0000 (04:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=203472

Reviewed by Brady Eidson.

Source/WebCore:

* loader/ios/LegacyPreviewLoader.mm:
(WebCore::LegacyPreviewLoader::didReceiveBuffer):
* platform/network/ios/LegacyPreviewLoaderClient.h:
(WebCore::LegacyPreviewLoaderClient::didReceiveBuffer):
(WebCore::LegacyPreviewLoaderClient::didReceiveDataArray): Deleted.

Source/WebKit:

Replaced QuickLookDocumentData with ShareableResource.

Removed messages WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame and
WebPage::DidReceivePasswordForQuickLookDocument, replacing them with async message
WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame.

* Shared/ios/QuickLookDocumentData.cpp: Removed.
* Shared/ios/QuickLookDocumentData.h: Removed.
* SourcesCocoa.txt:
* UIProcess/API/APILoaderClient.h:
* UIProcess/API/APINavigationClient.h:
(API::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame):
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame):
* UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame):
(WebKit::ProvisionalPageProxy::didReceiveMessage):
(WebKit::ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted.
* UIProcess/ProvisionalPageProxy.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame):
(WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrame):
(WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrameShared):
(WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted.
(WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrameShared): Deleted.
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp:
(WebKit::WebPreviewLoaderClient::WebPreviewLoaderClient):
(WebKit::WebPreviewLoaderClient::didReceiveBuffer):
(WebKit::WebPreviewLoaderClient::didFinishLoading):
(WebKit::WebPreviewLoaderClient::didFail):
(WebKit::WebPreviewLoaderClient::didRequestPassword):
(WebKit::passwordCallbacks): Deleted.
(WebKit::WebPreviewLoaderClient::~WebPreviewLoaderClient): Deleted.
(WebKit::WebPreviewLoaderClient::didReceiveDataArray): Deleted.
(WebKit::WebPreviewLoaderClient::didReceivePassword): Deleted.
* WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::didStartLoadForQuickLookDocumentInMainFrame):
(WebKit::WebPage::didFinishLoadForQuickLookDocumentInMainFrame):
(WebKit::WebPage::requestPasswordForQuickLookDocumentInMainFrame):
(WebKit::WebPage::didReceivePasswordForQuickLookDocument): Deleted.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::createPreviewLoaderClient):

Tools:

Updated API tests to compare data received in
-_webView:didFinishLoadForQuickLookDocumentInMainFrame: with expected data.

* TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm:
(readFile):
(-[QuickLookDelegate initWithExpectedFileURL:responsePolicy:]):
(-[QuickLookDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]):
(-[QuickLookDelegate verifyDownload]):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251765 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/ios/LegacyPreviewLoader.mm
Source/WebCore/platform/network/ios/LegacyPreviewLoaderClient.h
Source/WebKit/ChangeLog
Source/WebKit/Platform/SharedMemory.cpp [moved from Source/WebKit/Shared/ios/QuickLookDocumentData.h with 62% similarity]
Source/WebKit/Platform/SharedMemory.h
Source/WebKit/Shared/ios/QuickLookDocumentData.cpp [deleted file]
Source/WebKit/Sources.txt
Source/WebKit/SourcesCocoa.txt
Source/WebKit/UIProcess/API/APILoaderClient.h
Source/WebKit/UIProcess/API/APINavigationClient.h
Source/WebKit/UIProcess/Cocoa/NavigationState.h
Source/WebKit/UIProcess/Cocoa/NavigationState.mm
Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
Source/WebKit/UIProcess/ProvisionalPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm

index 0b15ba9..04c03df 100644 (file)
@@ -1,3 +1,16 @@
+2019-10-29  Andy Estes  <aestes@apple.com>
+
+        [Quick Look] Clean up LegacyPreviewLoaderClients
+        https://bugs.webkit.org/show_bug.cgi?id=203472
+
+        Reviewed by Brady Eidson.
+
+        * loader/ios/LegacyPreviewLoader.mm:
+        (WebCore::LegacyPreviewLoader::didReceiveBuffer):
+        * platform/network/ios/LegacyPreviewLoaderClient.h:
+        (WebCore::LegacyPreviewLoaderClient::didReceiveBuffer):
+        (WebCore::LegacyPreviewLoaderClient::didReceiveDataArray): Deleted.
+
 2019-10-29  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         [SVG2] SVGSymbolElement should inherits SVGGraphicsElement
index c7e7c8b..6c9a9a2 100644 (file)
@@ -71,7 +71,7 @@ bool LegacyPreviewLoader::didReceiveBuffer(const SharedBuffer& buffer)
     LOG(Network, "LegacyPreviewLoader appending buffer with size %ld.", buffer.size());
     m_originalData->append(buffer);
     m_converter->updateMainResource();
-    m_client->didReceiveDataArray((__bridge CFArrayRef)buffer.createNSDataArray().get());
+    m_client->didReceiveBuffer(buffer);
     return true;
 }
 
index bb21378..bc4daaf 100644 (file)
 
 namespace WebCore {
 
+class SharedBuffer;
+
 class LegacyPreviewLoaderClient : public RefCounted<LegacyPreviewLoaderClient> {
 public:
     virtual ~LegacyPreviewLoaderClient() = default;
-    virtual void didReceiveDataArray(CFArrayRef) { }
+    virtual void didReceiveBuffer(const SharedBuffer&) { }
     virtual void didFinishLoading() { }
     virtual void didFail() { }
     virtual bool supportsPasswordEntry() const { return false; }
index 304558f..353e098 100644 (file)
@@ -1,3 +1,58 @@
+2019-10-29  Andy Estes  <aestes@apple.com>
+
+        [Quick Look] Clean up LegacyPreviewLoaderClients
+        https://bugs.webkit.org/show_bug.cgi?id=203472
+
+        Reviewed by Brady Eidson.
+
+        Replaced QuickLookDocumentData with ShareableResource.
+
+        Removed messages WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame and
+        WebPage::DidReceivePasswordForQuickLookDocument, replacing them with async message
+        WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame.
+
+        * Shared/ios/QuickLookDocumentData.cpp: Removed.
+        * Shared/ios/QuickLookDocumentData.h: Removed.
+        * SourcesCocoa.txt:
+        * UIProcess/API/APILoaderClient.h:
+        * UIProcess/API/APINavigationClient.h:
+        (API::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame):
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame):
+        * UIProcess/ProvisionalPageProxy.cpp:
+        (WebKit::ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame):
+        (WebKit::ProvisionalPageProxy::didReceiveMessage):
+        (WebKit::ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted.
+        * UIProcess/ProvisionalPageProxy.h:
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame):
+        (WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrame):
+        (WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrameShared):
+        (WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted.
+        (WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrameShared): Deleted.
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp:
+        (WebKit::WebPreviewLoaderClient::WebPreviewLoaderClient):
+        (WebKit::WebPreviewLoaderClient::didReceiveBuffer):
+        (WebKit::WebPreviewLoaderClient::didFinishLoading):
+        (WebKit::WebPreviewLoaderClient::didFail):
+        (WebKit::WebPreviewLoaderClient::didRequestPassword):
+        (WebKit::passwordCallbacks): Deleted.
+        (WebKit::WebPreviewLoaderClient::~WebPreviewLoaderClient): Deleted.
+        (WebKit::WebPreviewLoaderClient::didReceiveDataArray): Deleted.
+        (WebKit::WebPreviewLoaderClient::didReceivePassword): Deleted.
+        * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::didStartLoadForQuickLookDocumentInMainFrame):
+        (WebKit::WebPage::didFinishLoadForQuickLookDocumentInMainFrame):
+        (WebKit::WebPage::requestPasswordForQuickLookDocumentInMainFrame):
+        (WebKit::WebPage::didReceivePasswordForQuickLookDocument): Deleted.
+
 2019-10-29  Jiewen Tan  <jiewen_tan@apple.com>
 
         [WebAuthn] Add more information to _WKWebAuthenticationPanel
similarity index 62%
rename from Source/WebKit/Shared/ios/QuickLookDocumentData.h
rename to Source/WebKit/Platform/SharedMemory.cpp
index 7016f41..1b7f989 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef QuickLookDocumentData_h
-#define QuickLookDocumentData_h
+#include "config.h"
+#include "SharedMemory.h"
 
-#include <wtf/RetainPtr.h>
-#include <wtf/Vector.h>
-
-namespace IPC {
-class Decoder;
-class Encoder;
-}
+#include <WebCore/SharedBuffer.h>
 
 namespace WebKit {
 
-class QuickLookDocumentData {
-public:
-    void append(CFDataRef);
-    CFDataRef decodedData() const;
-    bool isEmpty() const;
-    void clear();
-    void encode(IPC::Encoder&) const;
-    static bool decode(IPC::Decoder&, QuickLookDocumentData&);
-
-private:
-    Vector<RetainPtr<CFDataRef>, 1> m_data;
-};
-} // namespace WebKit
+using namespace WebCore;
+
+RefPtr<SharedMemory> SharedMemory::copyBuffer(const SharedBuffer& buffer)
+{
+    if (buffer.isEmpty())
+        return nullptr;
+
+    auto sharedMemory = allocate(buffer.size());
+    if (!sharedMemory)
+        return nullptr;
 
-#endif // QuickLookDocumentData_h
+    char* const sharedMemoryPtr = reinterpret_cast<char*>(sharedMemory->data());
+    size_t position = 0;
+    while (buffer.size() > position) {
+        auto data = buffer.getSomeData(position);
+        auto result = memcpy(sharedMemoryPtr + position, data.data(), data.size());
+        ASSERT_UNUSED(result, result == sharedMemoryPtr + position);
+        position += data.size();
+    }
+
+    return sharedMemory;
+}
+
+} // namespace WebKit
index a81b07e..7790322 100644 (file)
@@ -44,6 +44,10 @@ class Decoder;
 class Encoder;
 }
 
+namespace WebCore {
+class SharedBuffer;
+}
+
 #if OS(DARWIN)
 namespace WTF {
 class MachSendRight;
@@ -97,6 +101,7 @@ public:
 
     static RefPtr<SharedMemory> allocate(size_t);
     static RefPtr<SharedMemory> create(void*, size_t, Protection);
+    static RefPtr<SharedMemory> copyBuffer(const WebCore::SharedBuffer&);
     static RefPtr<SharedMemory> map(const Handle&, Protection);
 #if USE(UNIX_DOMAIN_SOCKETS)
     static RefPtr<SharedMemory> wrapMap(void*, size_t, int fileDescriptor);
diff --git a/Source/WebKit/Shared/ios/QuickLookDocumentData.cpp b/Source/WebKit/Shared/ios/QuickLookDocumentData.cpp
deleted file mode 100644 (file)
index 8bbda59..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "QuickLookDocumentData.h"
-
-#if USE(QUICK_LOOK)
-
-#include "Decoder.h"
-#include "Encoder.h"
-
-namespace WebKit {
-
-void QuickLookDocumentData::append(CFDataRef data)
-{
-    m_data.append(data);
-}
-
-CFDataRef QuickLookDocumentData::decodedData() const
-{
-    ASSERT(m_data.size() <= 1);
-    if (m_data.isEmpty())
-        return nullptr;
-    return m_data[0].get();
-}
-
-bool QuickLookDocumentData::isEmpty() const
-{
-    return m_data.isEmpty();
-}
-
-void QuickLookDocumentData::clear()
-{
-    m_data.clear();
-}
-
-void QuickLookDocumentData::encode(IPC::Encoder& encoder) const
-{
-    uint64_t size = 0;
-    for (const auto& data : m_data)
-        size += CFDataGetLength(data.get());
-    encoder << size;
-
-    for (const auto& data : m_data)
-        encoder.encodeFixedLengthData(CFDataGetBytePtr(data.get()), CFDataGetLength(data.get()), 1);
-}
-
-bool QuickLookDocumentData::decode(IPC::Decoder& decoder, QuickLookDocumentData& documentData)
-{
-    uint64_t size;
-    if (!decoder.decode(size))
-        return false;
-
-    if (!size)
-        return true;
-
-    uint8_t* const buffer = static_cast<uint8_t*>(CFAllocatorAllocate(kCFAllocatorDefault, size, 0));
-    ASSERT(buffer);
-
-    if (!decoder.decodeFixedLengthData(buffer, size, 1)) {
-        CFAllocatorDeallocate(kCFAllocatorDefault, buffer);
-        return false;
-    }
-
-    documentData.clear();
-    documentData.m_data.append(adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, buffer, size, kCFAllocatorDefault)));
-    return true;
-}
-
-} // namespace WebKit
-
-#endif // USE(QUICK_LOOK)
index 498e91b..9bd5082 100644 (file)
@@ -96,6 +96,7 @@ NetworkProcess/webrtc/NetworkMDNSRegister.cpp
 // TODO: We should unify these files once GTK's PluginProcess2 is removed.
 Platform/Logging.cpp @no-unify
 Platform/Module.cpp @no-unify
+Platform/SharedMemory.cpp @no-unify
 
 // TODO: We should unify these files once GTK's PluginProcess2 is removed.
 Platform/IPC/ArgumentCoders.cpp @no-unify
index 2c95016..d924a13 100644 (file)
@@ -173,7 +173,6 @@ Shared/ios/InteractionInformationRequest.cpp
 Shared/ios/NativeWebKeyboardEventIOS.mm
 Shared/ios/NativeWebMouseEventIOS.mm
 Shared/ios/NativeWebTouchEventIOS.mm
-Shared/ios/QuickLookDocumentData.cpp
 Shared/ios/WebAutocorrectionData.mm
 Shared/ios/WebIconUtilities.mm
 Shared/ios/WebIOSEventFactory.mm
index b2ea41d..c364aef 100644 (file)
@@ -38,7 +38,6 @@ class ResourceError;
 
 namespace WebKit {
 class AuthenticationChallengeProxy;
-class QuickLookDocumentData;
 class WebBackForwardListItem;
 class WebFrameProxy;
 class WebPageProxy;
index 38cc750..94da32f 100644 (file)
@@ -49,12 +49,12 @@ struct ContentRuleListResults;
 class ResourceError;
 class ResourceRequest;
 class ResourceResponse;
+class SharedBuffer;
 struct SecurityOriginData;
 }
 
 namespace WebKit {
 class AuthenticationChallengeProxy;
-class QuickLookDocumentData;
 class WebBackForwardListItem;
 class WebFramePolicyListenerProxy;
 class WebFrameProxy;
@@ -109,7 +109,7 @@ public:
 
 #if USE(QUICK_LOOK)
     virtual void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) { }
-    virtual void didFinishLoadForQuickLookDocumentInMainFrame(const WebKit::QuickLookDocumentData&) { }
+    virtual void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&) { }
 #endif
 
     virtual void decidePolicyForNavigationAction(WebKit::WebPageProxy&, Ref<NavigationAction>&&, Ref<WebKit::WebFramePolicyListenerProxy>&& listener, Object*)
index 0dfde7c..9785106 100644 (file)
@@ -122,7 +122,7 @@ private:
 
 #if USE(QUICK_LOOK)
         void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) override;
-        void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&) override;
+        void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&) override;
 #endif
 
 #if PLATFORM(MAC)
index 94ae9b1..9ada0d9 100644 (file)
 #import <pal/spi/cocoa/LaunchServicesSPI.h>
 #endif
 
-#if USE(QUICK_LOOK)
-#import "QuickLookDocumentData.h"
-#endif
-
 namespace WebKit {
 using namespace WebCore;
 
@@ -1083,7 +1079,7 @@ void NavigationState::NavigationClient::didStartLoadForQuickLookDocumentInMainFr
     [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:fileName uti:uti];
 }
 
-void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
+void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const SharedBuffer& buffer)
 {
     if (!m_navigationState.m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame)
         return;
@@ -1092,7 +1088,7 @@ void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainF
     if (!navigationDelegate)
         return;
 
-    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)data.decodedData()];
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didFinishLoadForQuickLookDocumentInMainFrame:buffer.createNSData().get()];
 }
 #endif
 
index 7ec5a6b..0b804fa 100644 (file)
@@ -354,9 +354,9 @@ void ProvisionalPageProxy::decidePolicyForNavigationActionSync(FrameIdentifier f
 }
 
 #if USE(QUICK_LOOK)
-void ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName)
+void ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
 {
-    m_page.didRequestPasswordForQuickLookDocumentInMainFrameShared(m_process.copyRef(), fileName);
+    m_page.requestPasswordForQuickLookDocumentInMainFrameShared(fileName, WTFMove(completionHandler));
 }
 #endif
 
@@ -469,8 +469,8 @@ void ProvisionalPageProxy::didReceiveMessage(IPC::Connection& connection, IPC::D
     }
 
 #if USE(QUICK_LOOK)
-    if (decoder.messageName() == Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame::name()) {
-        IPC::handleMessage<Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame>(decoder, this, &ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame);
+    if (decoder.messageName() == Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame::name()) {
+        IPC::handleMessageAsync<Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame>(connection, decoder, this, &ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame);
         return;
     }
 #endif
index 9c323af..9f87121 100644 (file)
@@ -115,7 +115,7 @@ private:
         FrameInfoData&&, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody,
         WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&);
 #if USE(QUICK_LOOK)
-    void didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName);
+    void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&);
 #endif
 #if PLATFORM(COCOA)
     void registerWebProcessAccessibilityToken(const IPC::DataReference&);
index f684fcd..3ad2c6c 100644 (file)
@@ -44,6 +44,7 @@
 #include "SandboxExtension.h"
 #include "ShareSheetCallbackID.h"
 #include "ShareableBitmap.h"
+#include "ShareableResource.h"
 #include "SuspendedPageProxy.h"
 #include "SyntheticEditingCommandType.h"
 #include "SystemPreviewController.h"
@@ -329,10 +330,6 @@ enum class ProcessSwapRequestedByClient;
 enum class UndoOrRedo : bool;
 enum class WebContentMode : uint8_t;
 
-#if USE(QUICK_LOOK)
-class QuickLookDocumentData;
-#endif
-
 typedef GenericCallback<API::Data*> DataCallback;
 typedef GenericCallback<uint64_t> UnsignedCallback;
 typedef GenericCallback<EditingRange> EditingRangeCallback;
@@ -1560,7 +1557,7 @@ public:
         FrameInfoData&&, Optional<WebPageProxyIdentifier> originatingPageID, const WebCore::ResourceRequest& originalRequest, WebCore::ResourceRequest&&, IPC::FormDataReference&& requestBody,
         WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&);
 #if USE(QUICK_LOOK)
-    void didRequestPasswordForQuickLookDocumentInMainFrameShared(Ref<WebProcessProxy>&&, const String& fileName);
+    void requestPasswordForQuickLookDocumentInMainFrameShared(const String& fileName, CompletionHandler<void(const String&)>&&);
 #endif
 #if ENABLE(CONTENT_FILTERING)
     void contentFilterDidBlockLoadForFrameShared(Ref<WebProcessProxy>&&, const WebCore::ContentFilterUnblockHandler&, WebCore::FrameIdentifier);
@@ -2052,8 +2049,8 @@ private:
 
 #if USE(QUICK_LOOK)
     void didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti);
-    void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&);
-    void didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName);
+    void didFinishLoadForQuickLookDocumentInMainFrame(const ShareableResource::Handle&);
+    void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&);
 #endif
 
 #if ENABLE(CONTENT_FILTERING)
index a6ce38d..ce72bed 100644 (file)
@@ -467,8 +467,8 @@ messages -> WebPageProxy {
 
 #if USE(QUICK_LOOK)
     DidStartLoadForQuickLookDocumentInMainFrame(String fileName, String uti)
-    DidFinishLoadForQuickLookDocumentInMainFrame(WebKit::QuickLookDocumentData data)
-    DidRequestPasswordForQuickLookDocumentInMainFrame(String fileName)
+    DidFinishLoadForQuickLookDocumentInMainFrame(WebKit::ShareableResource::Handle resource)
+    RequestPasswordForQuickLookDocumentInMainFrame(String fileName) -> (String password) Async
 #endif
 
 #if ENABLE(CONTENT_FILTERING)
index b18272e..8ea1b38 100644 (file)
@@ -47,6 +47,7 @@
 #import "RemoteLayerTreeDrawingAreaProxyMessages.h"
 #import "RemoteLayerTreeTransaction.h"
 #import "RemoteScrollingCoordinatorProxy.h"
+#import "ShareableResource.h"
 #import "UIKitSPI.h"
 #import "UserData.h"
 #import "VersionChecks.h"
@@ -1249,7 +1250,7 @@ void WebPageProxy::didConcludeDrop()
 #endif
 
 #if USE(QUICK_LOOK)
-    
+
 void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
 {
     // Ensure that fileName isn't really a path name
@@ -1257,21 +1258,23 @@ void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fil
     m_navigationClient->didStartLoadForQuickLookDocumentInMainFrame(fileName.substring(fileName.reverseFind('/') + 1), uti);
 }
 
-void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
+void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const ShareableResource::Handle& handle)
 {
-    m_navigationClient->didFinishLoadForQuickLookDocumentInMainFrame(data);
+    auto buffer = handle.tryWrapInSharedBuffer();
+    if (!buffer)
+        return;
+
+    m_navigationClient->didFinishLoadForQuickLookDocumentInMainFrame(*buffer);
 }
 
-void WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName)
+void WebPageProxy::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
 {
-    didRequestPasswordForQuickLookDocumentInMainFrameShared(m_process.copyRef(), fileName);
+    requestPasswordForQuickLookDocumentInMainFrameShared(fileName, WTFMove(completionHandler));
 }
 
-void WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrameShared(Ref<WebProcessProxy>&& process, const String& fileName)
+void WebPageProxy::requestPasswordForQuickLookDocumentInMainFrameShared(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
 {
-    pageClient().requestPasswordForQuickLookDocument(fileName, [process = WTFMove(process), webPageID = m_webPageID](const String& password) {
-        process->send(Messages::WebPage::DidReceivePasswordForQuickLookDocument(password), webPageID);
-    });
+    pageClient().requestPasswordForQuickLookDocument(fileName, WTFMove(completionHandler));
 }
 
 #endif
index 1322d98..33619e2 100644 (file)
                A102A7081EC0EEE900D81D82 /* com.macromedia.Flash Player ESR.plugin.sb in Copy Plug-in Sandbox Profiles */ = {isa = PBXBuildFile; fileRef = 7A5E39491D5BD8A700B4B7CE /* com.macromedia.Flash Player ESR.plugin.sb */; };
                A1046EA12079263100F0C5D8 /* WKPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = A1046E9F2079263100F0C5D8 /* WKPDFView.h */; };
                A115DC72191D82DA00DA8072 /* _WKWebViewPrintFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */; };
                A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A13B3DA2207F39DE0090C58D /* MobileWiFiSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A13B3DA1207F39DE0090C58D /* MobileWiFiSPI.h */; };
                A13DC682207AA6B20066EF72 /* WKApplicationStateTrackingView.h in Headers */ = {isa = PBXBuildFile; fileRef = A13DC680207AA6B20066EF72 /* WKApplicationStateTrackingView.h */; };
                A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE5718DCE9FA00B5EA8A /* _WKDownload.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1A4FE5C18DCE9FA00B5EA8A /* _WKDownloadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */; };
                A1A4FE6118DD54A400B5EA8A /* _WKDownloadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A1ADAFB62368E6A8009CB776 /* SharedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */; };
                A1C512C9190656E500448914 /* WebPreviewLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C512C7190656E500448914 /* WebPreviewLoaderClient.h */; };
                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1DF631118E0B7C8003A3E2A /* DownloadClient.h */; };
                A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1E6886F1F6E2BAB007006A6 /* QuarantineSPI.h */; };
                        compilerSpec = com.apple.compilers.proxy.script;
                        filePatterns = "*.h";
                        fileType = pattern.proxy;
+                       inputFiles = (
+                       );
                        isEditable = 1;
                        outputFiles = (
                                "$(HEADER_OUTPUT_DIR)/$(INPUT_FILE_NAME)",
                A1046EA02079263100F0C5D8 /* WKPDFView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKPDFView.mm; path = ios/WKPDFView.mm; sourceTree = "<group>"; };
                A115DC6D191D82AB00DA8072 /* _WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKWebViewPrintFormatter.mm; sourceTree = "<group>"; };
                A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKWebViewPrintFormatter.h; sourceTree = "<group>"; };
-               A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = QuickLookDocumentData.cpp; path = ios/QuickLookDocumentData.cpp; sourceTree = "<group>"; };
-               A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuickLookDocumentData.h; path = ios/QuickLookDocumentData.h; sourceTree = "<group>"; };
                A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKNSFileManagerExtras.mm; sourceTree = "<group>"; };
                A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKNSFileManagerExtras.h; sourceTree = "<group>"; };
                A13B3DA1207F39DE0090C58D /* MobileWiFiSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MobileWiFiSPI.h; sourceTree = "<group>"; };
                A1A4FE5818DCE9FA00B5EA8A /* _WKDownload.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKDownload.mm; sourceTree = "<group>"; };
                A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadInternal.h; sourceTree = "<group>"; };
                A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadDelegate.h; sourceTree = "<group>"; };
+               A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemory.cpp; sourceTree = "<group>"; };
                A1B89B92221E023300EB4CEA /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; };
                A1B9CA382246E54A003D6DCA /* WebPaymentCoordinatorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPaymentCoordinatorCocoa.mm; sourceTree = "<group>"; };
                A1C512C6190656E500448914 /* WebPreviewLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebPreviewLoaderClient.cpp; path = ios/WebPreviewLoaderClient.cpp; sourceTree = "<group>"; };
                                2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */,
                                1C9EBA5B2087E74E00054429 /* NativeWebMouseEventIOS.mm */,
                                2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */,
-                               A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */,
-                               A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */,
                                4459984122833E6000E61373 /* SyntheticEditingCommandType.h */,
                                F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */,
                                F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */,
                                0FDCD7F61D47E92A009F08BC /* LogInitialization.h */,
                                C0E3AA451209E2BA00A49D01 /* Module.cpp */,
                                C0E3AA441209E2BA00A49D01 /* Module.h */,
+                               A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */,
                                1A24BED3120894D100FBB059 /* SharedMemory.h */,
                        );
                        path = Platform;
                                86E67A251910B9D100004AB7 /* ProcessThrottler.h in Headers */,
                                83048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */,
                                A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */,
-                               A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */,
                                57FD318222B3515E008D0E8B /* RedirectSOAuthorizationSession.h in Headers */,
                                2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */,
                                2DDF731518E95060004F5A66 /* RemoteLayerBackingStoreCollection.h in Headers */,
                                E18E6917169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp in Sources */,
                                41DE7C6C22278F1E00532B65 /* ServiceWorkerFetchTask.cpp in Sources */,
                                2D92A787212B6AB100F493FD /* ShareableBitmap.cpp in Sources */,
+                               A1ADAFB62368E6A8009CB776 /* SharedMemory.cpp in Sources */,
                                2DE6943D18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp in Sources */,
                                1A334DED16DE8F88006A8E38 /* StorageAreaMapMessageReceiver.cpp in Sources */,
                                9368EEDE2303A90200BDB11A /* StorageManagerSetMessageReceiver.cpp in Sources */,
index b6358a1..93d3a24 100644 (file)
 #include "Logging.h"
 #include "WebPageProxyMessages.h"
 #include "WebProcess.h"
-#include <WebCore/QuickLook.h>
+#include <WebCore/SharedBuffer.h>
 #include <wtf/Function.h>
 #include <wtf/HashMap.h>
 #include <wtf/NeverDestroyed.h>
 
 namespace WebKit {
 
-using PasswordCallbackMap = HashMap<WebCore::PageIdentifier, Function<void(const String&)>>;
-static PasswordCallbackMap& passwordCallbacks()
-{
-    static NeverDestroyed<PasswordCallbackMap> callbackMap;
-    return callbackMap.get();
-}
+using namespace WebCore;
 
-WebPreviewLoaderClient::WebPreviewLoaderClient(const String& fileName, const String& uti, WebCore::PageIdentifier pageID)
+WebPreviewLoaderClient::WebPreviewLoaderClient(const String& fileName, const String& uti, PageIdentifier pageID)
     : m_fileName { fileName }
     , m_uti { uti }
     , m_pageID { pageID }
+    , m_buffer { SharedBuffer::create() }
 {
 }
 
-WebPreviewLoaderClient::~WebPreviewLoaderClient()
-{
-    passwordCallbacks().remove(m_pageID);
-}
+WebPreviewLoaderClient::~WebPreviewLoaderClient() = default;
 
-void WebPreviewLoaderClient::didReceiveDataArray(CFArrayRef dataArray)
+void WebPreviewLoaderClient::didReceiveBuffer(const SharedBuffer& buffer)
 {
-    if (m_data.isEmpty())
-        WebProcess::singleton().send(Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame(m_fileName, m_uti), m_pageID);
+    auto webPage = WebProcess::singleton().webPage(m_pageID);
+    if (!webPage)
+        return;
 
-    CFArrayApplyFunction(dataArray, CFRangeMake(0, CFArrayGetCount(dataArray)), [](const void* value, void* context) {
-        ASSERT(CFGetTypeID(value) == CFDataGetTypeID());
-        static_cast<QuickLookDocumentData*>(context)->append((CFDataRef)value);
-    }, &m_data);    
+    if (m_buffer->isEmpty())
+        webPage->didStartLoadForQuickLookDocumentInMainFrame(m_fileName, m_uti);
+
+    m_buffer->append(buffer);
 }
 
 void WebPreviewLoaderClient::didFinishLoading()
 {
-    WebProcess::singleton().send(Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame(m_data), m_pageID);
-    m_data.clear();
+    auto webPage = WebProcess::singleton().webPage(m_pageID);
+    if (!webPage)
+        return;
+
+    webPage->didFinishLoadForQuickLookDocumentInMainFrame(m_buffer.get());
+    m_buffer->clear();
 }
 
 void WebPreviewLoaderClient::didFail()
 {
-    m_data.clear();
+    m_buffer->clear();
 }
 
 void WebPreviewLoaderClient::didRequestPassword(Function<void(const String&)>&& completionHandler)
 {
-    ASSERT(!passwordCallbacks().contains(m_pageID));
-    passwordCallbacks().add(m_pageID, WTFMove(completionHandler));
-    WebProcess::singleton().send(Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame(m_fileName), m_pageID);
-}
+    auto webPage = WebProcess::singleton().webPage(m_pageID);
+    if (!webPage) {
+        completionHandler({ });
+        return;
+    }
 
-void WebPreviewLoaderClient::didReceivePassword(const String& password, WebCore::PageIdentifier pageID)
-{
-    ASSERT(passwordCallbacks().contains(pageID));
-    if (auto completionHandler = passwordCallbacks().take(pageID))
-        completionHandler(password);
-    else
-        RELEASE_LOG_ERROR(Loading, "Discarding a password for a page that did not request one in this process");
+    webPage->requestPasswordForQuickLookDocumentInMainFrame(m_fileName, WTFMove(completionHandler));
 }
 
 } // namespace WebKit
index da3b508..0492cee 100644 (file)
@@ -27,7 +27,6 @@
 
 #if USE(QUICK_LOOK)
 
-#include "QuickLookDocumentData.h"
 #include <WebCore/LegacyPreviewLoaderClient.h>
 #include <WebCore/PageIdentifier.h>
 #include <wtf/text/WTFString.h>
@@ -44,11 +43,9 @@ public:
     }
     ~WebPreviewLoaderClient();
 
-    static void didReceivePassword(const String&, WebCore::PageIdentifier);
-
 private:
     WebPreviewLoaderClient(const String& fileName, const String& uti, WebCore::PageIdentifier);
-    void didReceiveDataArray(CFArrayRef) override;
+    void didReceiveBuffer(const WebCore::SharedBuffer&) override;
     void didFinishLoading() override;
     void didFail() override;
     bool supportsPasswordEntry() const override { return true; }
@@ -57,7 +54,7 @@ private:
     const String m_fileName;
     const String m_uti;
     const WebCore::PageIdentifier m_pageID;
-    QuickLookDocumentData m_data;
+    Ref<WebCore::SharedBuffer> m_buffer;
 };
 
 } // namespace WebKit
index 4a12c5c..44c7f48 100644 (file)
@@ -1234,6 +1234,12 @@ public:
     static WebCore::IntRect rootViewInteractionBoundsForElement(const WebCore::Element&);
 #endif // PLATFORM(IOS_FAMILY)
 
+#if USE(QUICK_LOOK)
+    void didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti);
+    void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&);
+    void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&);
+#endif
+
 private:
     WebPage(WebCore::PageIdentifier, WebPageCreationParameters&&);
 
@@ -1595,10 +1601,6 @@ private:
 
     bool canPluginHandleResponse(const WebCore::ResourceResponse&);
 
-#if USE(QUICK_LOOK)
-    void didReceivePasswordForQuickLookDocument(const String&);
-#endif
-
     void simulateDeviceOrientationChange(double alpha, double beta, double gamma);
 
 #if USE(SYSTEM_PREVIEW)
index adbcf3d..36e3d28 100644 (file)
@@ -532,10 +532,6 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType
     GamepadActivity(Vector<WebKit::GamepadData> gamepadDatas, bool shouldMakeGamepadsVisible)
 #endif
 
-#if USE(QUICK_LOOK)
-    DidReceivePasswordForQuickLookDocument(String password)
-#endif
-
     FrameBecameRemote(WebCore::FrameIdentifier frameID, struct WebCore::GlobalFrameIdentifier remoteFrameIdentifier, struct WebCore::GlobalWindowIdentifier remoteWindowIdentifier)
 
     RegisterURLSchemeHandler(uint64_t identifier, String scheme)
index 1c02adb..325abfa 100644 (file)
@@ -42,6 +42,7 @@
 #import "PrintInfo.h"
 #import "RemoteLayerTreeDrawingArea.h"
 #import "SandboxUtilities.h"
+#import "SharedMemory.h"
 #import "SyntheticEditingCommandType.h"
 #import "TextCheckingControllerProxy.h"
 #import "UIKitSPI.h"
@@ -3843,13 +3844,6 @@ void WebPage::updateStringForFind(const String& findString)
     send(Messages::WebPageProxy::UpdateStringForFind(findString));
 }
 
-#if USE(QUICK_LOOK)
-void WebPage::didReceivePasswordForQuickLookDocument(const String& password)
-{
-    WebPreviewLoaderClient::didReceivePassword(password, m_identifier);
-}
-#endif
-
 bool WebPage::platformPrefersTextLegibilityBasedZoomScaling() const
 {
 #if PLATFORM(WATCHOS)
@@ -4078,6 +4072,40 @@ void WebPage::requestDocumentEditingContext(DocumentEditingContextRequest reques
     completionHandler(context);
 }
 
+#if USE(QUICK_LOOK)
+
+void WebPage::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
+{
+    send(Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame(fileName, uti));
+}
+
+void WebPage::didFinishLoadForQuickLookDocumentInMainFrame(const SharedBuffer& buffer)
+{
+    ASSERT(!buffer.isEmpty());
+
+    // FIXME: In some cases, buffer conains a single segment that wraps an existing ShareableResource.
+    // If we could create a handle from that existing resource then we could avoid this extra
+    // allocation and copy.
+
+    auto sharedMemory = SharedMemory::copyBuffer(buffer);
+    if (!sharedMemory)
+        return;
+
+    ShareableResource::Handle handle;
+    auto shareableResource = ShareableResource::create(sharedMemory.releaseNonNull(), 0, buffer.size());
+    if (!shareableResource->createHandle(handle))
+        return;
+
+    send(Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame(handle));
+}
+
+void WebPage::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
+{
+    sendWithAsyncReply(Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame(fileName), WTFMove(completionHandler));
+}
+
+#endif
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_IF_ALLOWED
index 502164d..ea1844b 100644 (file)
@@ -1,3 +1,13 @@
+2019-10-29  Andy Estes  <aestes@apple.com>
+
+        [Quick Look] Clean up LegacyPreviewLoaderClients
+        https://bugs.webkit.org/show_bug.cgi?id=203472
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::createPreviewLoaderClient):
+
 2019-10-26  Chris Lord  <clord@igalia.com>
 
         Put OffscreenCanvas behind a build flag
index 37b8273..0e223c0 100644 (file)
@@ -2206,9 +2206,10 @@ RefPtr<WebCore::LegacyPreviewLoaderClient> WebFrameLoaderClient::createPreviewLo
         RetainPtr<NSString> m_filePath;
         RetainPtr<NSFileHandle> m_fileHandle;
 
-        void didReceiveDataArray(CFArrayRef dataArray) override
+        void didReceiveBuffer(const WebCore::SharedBuffer& buffer) override
         {
-            for (NSData *data in (NSArray *)dataArray)
+            auto dataArray = buffer.createNSDataArray();
+            for (NSData *data in dataArray.get())
                 [m_fileHandle writeData:data];
         }
 
index 8ef6900..ad8a400 100644 (file)
@@ -1,3 +1,20 @@
+2019-10-29  Andy Estes  <aestes@apple.com>
+
+        [Quick Look] Clean up LegacyPreviewLoaderClients
+        https://bugs.webkit.org/show_bug.cgi?id=203472
+
+        Reviewed by Brady Eidson.
+
+        Updated API tests to compare data received in
+        -_webView:didFinishLoadForQuickLookDocumentInMainFrame: with expected data.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm:
+        (readFile):
+        (-[QuickLookDelegate initWithExpectedFileURL:responsePolicy:]):
+        (-[QuickLookDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]):
+        (-[QuickLookDelegate verifyDownload]):
+        (TEST):
+
 2019-10-29  Jonathan Bedard  <jbedard@apple.com>
 
         results.webkit.org: Fix tooltip with drawer
index 82651fa..b20787b 100644 (file)
@@ -70,6 +70,7 @@ static NSURL * const pagesDocumentURL = [[NSBundle.mainBundle URLForResource:@"p
 @protected
     NSUInteger _downloadFileSize;
     NSUInteger _expectedFileSize;
+    RetainPtr<NSData> _expectedFileData;
     RetainPtr<NSString> _expectedFileName;
     RetainPtr<NSString> _expectedFileType;
     RetainPtr<NSString> _expectedMIMEType;
@@ -77,7 +78,7 @@ static NSURL * const pagesDocumentURL = [[NSBundle.mainBundle URLForResource:@"p
     WKNavigationResponsePolicy _responsePolicy;
 }
 
-static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>& fileName, RetainPtr<NSString>& fileType, RetainPtr<NSString>& mimeType)
+static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>& fileName, RetainPtr<NSString>& fileType, RetainPtr<NSString>& mimeType, RetainPtr<NSData>& fileData)
 {
     if (NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:fileURL.path error:nil])
         fileSize = [attributes[NSFileSize] unsignedIntegerValue];
@@ -89,6 +90,7 @@ static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>&
         fileType = typeIdentifier;
 
     mimeType = adoptCF(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)typeIdentifier, kUTTagClassMIMEType));
+    fileData = [NSData dataWithContentsOfURL:fileURL];
 }
 
 - (instancetype)initWithExpectedFileURL:(NSURL *)fileURL responsePolicy:(WKNavigationResponsePolicy)responsePolicy
@@ -96,7 +98,7 @@ static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>&
     if (!(self = [super init]))
         return nil;
 
-    readFile(fileURL, _expectedFileSize, _expectedFileName, _expectedFileType, _expectedMIMEType);
+    readFile(fileURL, _expectedFileSize, _expectedFileName, _expectedFileType, _expectedMIMEType, _expectedFileData);
 
     _responsePolicy = responsePolicy;
     return self;
@@ -139,6 +141,7 @@ static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>&
 - (void)_webView:(WKWebView *)webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)documentData
 {
     EXPECT_EQ(_expectedFileSize, documentData.length);
+    EXPECT_TRUE([_expectedFileData isEqualToData:documentData]);
     EXPECT_FALSE(_didFinishQuickLookLoad);
     EXPECT_TRUE(_didStartQuickLookLoad);
     _didFinishQuickLookLoad = YES;
@@ -219,12 +222,14 @@ static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>&
     EXPECT_TRUE([NSFileManager.defaultManager fileExistsAtPath:[_downloadDestinationURL path]]);
 
     NSUInteger downloadFileSize;
+    RetainPtr<NSData> downloadFileData;
     RetainPtr<NSString> downloadFileName;
     RetainPtr<NSString> downloadFileType;
     RetainPtr<NSString> downloadMIMEType;
-    readFile(_downloadDestinationURL.get(), downloadFileSize, downloadFileName, downloadFileType, downloadMIMEType);
+    readFile(_downloadDestinationURL.get(), downloadFileSize, downloadFileName, downloadFileType, downloadMIMEType, downloadFileData);
 
     EXPECT_EQ(_expectedFileSize, downloadFileSize);
+    EXPECT_TRUE([_expectedFileData isEqualToData:downloadFileData.get()]);
     EXPECT_WK_STREQ(_expectedFileName.get(), downloadFileName.get());
     EXPECT_WK_STREQ(_expectedFileType.get(), downloadFileType.get());
     EXPECT_WK_STREQ(_expectedMIMEType.get(), downloadMIMEType.get());
@@ -465,10 +470,11 @@ TEST(QuickLook, LegacyQuickLookContent)
     WebThreadLock();
 
     NSUInteger expectedFileSize;
+    RetainPtr<NSData> expectedFileData;
     RetainPtr<NSString> expectedFileName;
     RetainPtr<NSString> expectedFileType;
     RetainPtr<NSString> expectedMIMEType;
-    readFile(pagesDocumentURL, expectedFileSize, expectedFileName, expectedFileType, expectedMIMEType);
+    readFile(pagesDocumentURL, expectedFileSize, expectedFileName, expectedFileType, expectedMIMEType, expectedFileData);
 
     NSDictionary *quickLookContent = mainFrame.dataSource._quickLookContent;
     NSString *filePath = quickLookContent[WebQuickLookFileNameKey];
@@ -478,6 +484,8 @@ TEST(QuickLook, LegacyQuickLookContent)
 
     NSDictionary *fileAttributes = [NSFileManager.defaultManager attributesOfItemAtPath:filePath error:nil];
     EXPECT_EQ(expectedFileSize, [fileAttributes[NSFileSize] unsignedIntegerValue]);
+    
+    EXPECT_TRUE([expectedFileData isEqualToData:[NSData dataWithContentsOfFile:filePath]]);
 
     isDone = false;
     [mainFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]]];