Changeset 251765 in webkit


Ignore:
Timestamp:
Oct 29, 2019 9:14:39 PM (5 years ago)
Author:
aestes@apple.com
Message:

[Quick Look] Clean up LegacyPreviewLoaderClients
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):

Location:
trunk
Files:
1 deleted
26 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251764 r251765  
     12019-10-29  Andy Estes  <aestes@apple.com>
     2
     3        [Quick Look] Clean up LegacyPreviewLoaderClients
     4        https://bugs.webkit.org/show_bug.cgi?id=203472
     5
     6        Reviewed by Brady Eidson.
     7
     8        * loader/ios/LegacyPreviewLoader.mm:
     9        (WebCore::LegacyPreviewLoader::didReceiveBuffer):
     10        * platform/network/ios/LegacyPreviewLoaderClient.h:
     11        (WebCore::LegacyPreviewLoaderClient::didReceiveBuffer):
     12        (WebCore::LegacyPreviewLoaderClient::didReceiveDataArray): Deleted.
     13
    1142019-10-29  Said Abou-Hallawa  <sabouhallawa@apple.com>
    215
  • trunk/Source/WebCore/loader/ios/LegacyPreviewLoader.mm

    r251623 r251765  
    7272    m_originalData->append(buffer);
    7373    m_converter->updateMainResource();
    74     m_client->didReceiveDataArray((__bridge CFArrayRef)buffer.createNSDataArray().get());
     74    m_client->didReceiveBuffer(buffer);
    7575    return true;
    7676}
  • trunk/Source/WebCore/platform/network/ios/LegacyPreviewLoaderClient.h

    r251488 r251765  
    3232namespace WebCore {
    3333
     34class SharedBuffer;
     35
    3436class LegacyPreviewLoaderClient : public RefCounted<LegacyPreviewLoaderClient> {
    3537public:
    3638    virtual ~LegacyPreviewLoaderClient() = default;
    37     virtual void didReceiveDataArray(CFArrayRef) { }
     39    virtual void didReceiveBuffer(const SharedBuffer&) { }
    3840    virtual void didFinishLoading() { }
    3941    virtual void didFail() { }
  • trunk/Source/WebKit/ChangeLog

    r251762 r251765  
     12019-10-29  Andy Estes  <aestes@apple.com>
     2
     3        [Quick Look] Clean up LegacyPreviewLoaderClients
     4        https://bugs.webkit.org/show_bug.cgi?id=203472
     5
     6        Reviewed by Brady Eidson.
     7
     8        Replaced QuickLookDocumentData with ShareableResource.
     9
     10        Removed messages WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame and
     11        WebPage::DidReceivePasswordForQuickLookDocument, replacing them with async message
     12        WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame.
     13
     14        * Shared/ios/QuickLookDocumentData.cpp: Removed.
     15        * Shared/ios/QuickLookDocumentData.h: Removed.
     16        * SourcesCocoa.txt:
     17        * UIProcess/API/APILoaderClient.h:
     18        * UIProcess/API/APINavigationClient.h:
     19        (API::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame):
     20        * UIProcess/Cocoa/NavigationState.h:
     21        * UIProcess/Cocoa/NavigationState.mm:
     22        (WebKit::NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame):
     23        * UIProcess/ProvisionalPageProxy.cpp:
     24        (WebKit::ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame):
     25        (WebKit::ProvisionalPageProxy::didReceiveMessage):
     26        (WebKit::ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted.
     27        * UIProcess/ProvisionalPageProxy.h:
     28        * UIProcess/WebPageProxy.h:
     29        * UIProcess/WebPageProxy.messages.in:
     30        * UIProcess/ios/WebPageProxyIOS.mm:
     31        (WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame):
     32        (WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrame):
     33        (WebKit::WebPageProxy::requestPasswordForQuickLookDocumentInMainFrameShared):
     34        (WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame): Deleted.
     35        (WebKit::WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrameShared): Deleted.
     36        * WebKit.xcodeproj/project.pbxproj:
     37        * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp:
     38        (WebKit::WebPreviewLoaderClient::WebPreviewLoaderClient):
     39        (WebKit::WebPreviewLoaderClient::didReceiveBuffer):
     40        (WebKit::WebPreviewLoaderClient::didFinishLoading):
     41        (WebKit::WebPreviewLoaderClient::didFail):
     42        (WebKit::WebPreviewLoaderClient::didRequestPassword):
     43        (WebKit::passwordCallbacks): Deleted.
     44        (WebKit::WebPreviewLoaderClient::~WebPreviewLoaderClient): Deleted.
     45        (WebKit::WebPreviewLoaderClient::didReceiveDataArray): Deleted.
     46        (WebKit::WebPreviewLoaderClient::didReceivePassword): Deleted.
     47        * WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h:
     48        * WebProcess/WebPage/WebPage.h:
     49        * WebProcess/WebPage/WebPage.messages.in:
     50        * WebProcess/WebPage/ios/WebPageIOS.mm:
     51        (WebKit::WebPage::didStartLoadForQuickLookDocumentInMainFrame):
     52        (WebKit::WebPage::didFinishLoadForQuickLookDocumentInMainFrame):
     53        (WebKit::WebPage::requestPasswordForQuickLookDocumentInMainFrame):
     54        (WebKit::WebPage::didReceivePasswordForQuickLookDocument): Deleted.
     55
    1562019-10-29  Jiewen Tan  <jiewen_tan@apple.com>
    257
  • trunk/Source/WebKit/Platform/SharedMemory.cpp

    r251764 r251765  
    11/*
    2  * Copyright (C) 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #ifndef QuickLookDocumentData_h
    27 #define QuickLookDocumentData_h
     26#include "config.h"
     27#include "SharedMemory.h"
    2828
    29 #include <wtf/RetainPtr.h>
    30 #include <wtf/Vector.h>
    31 
    32 namespace IPC {
    33 class Decoder;
    34 class Encoder;
    35 }
     29#include <WebCore/SharedBuffer.h>
    3630
    3731namespace WebKit {
    3832
    39 class QuickLookDocumentData {
    40 public:
    41     void append(CFDataRef);
    42     CFDataRef decodedData() const;
    43     bool isEmpty() const;
    44     void clear();
    45     void encode(IPC::Encoder&) const;
    46     static bool decode(IPC::Decoder&, QuickLookDocumentData&);
     33using namespace WebCore;
    4734
    48 private:
    49     Vector<RetainPtr<CFDataRef>, 1> m_data;
    50 };
     35RefPtr<SharedMemory> SharedMemory::copyBuffer(const SharedBuffer& buffer)
     36{
     37    if (buffer.isEmpty())
     38        return nullptr;
     39
     40    auto sharedMemory = allocate(buffer.size());
     41    if (!sharedMemory)
     42        return nullptr;
     43
     44    char* const sharedMemoryPtr = reinterpret_cast<char*>(sharedMemory->data());
     45    size_t position = 0;
     46    while (buffer.size() > position) {
     47        auto data = buffer.getSomeData(position);
     48        auto result = memcpy(sharedMemoryPtr + position, data.data(), data.size());
     49        ASSERT_UNUSED(result, result == sharedMemoryPtr + position);
     50        position += data.size();
     51    }
     52
     53    return sharedMemory;
     54}
     55
    5156} // namespace WebKit
    52 
    53 #endif // QuickLookDocumentData_h
  • trunk/Source/WebKit/Platform/SharedMemory.h

    r249335 r251765  
    4343class Decoder;
    4444class Encoder;
     45}
     46
     47namespace WebCore {
     48class SharedBuffer;
    4549}
    4650
     
    98102    static RefPtr<SharedMemory> allocate(size_t);
    99103    static RefPtr<SharedMemory> create(void*, size_t, Protection);
     104    static RefPtr<SharedMemory> copyBuffer(const WebCore::SharedBuffer&);
    100105    static RefPtr<SharedMemory> map(const Handle&, Protection);
    101106#if USE(UNIX_DOMAIN_SOCKETS)
  • trunk/Source/WebKit/Sources.txt

    r251547 r251765  
    9797Platform/Logging.cpp @no-unify
    9898Platform/Module.cpp @no-unify
     99Platform/SharedMemory.cpp @no-unify
    99100
    100101// TODO: We should unify these files once GTK's PluginProcess2 is removed.
  • trunk/Source/WebKit/SourcesCocoa.txt

    r251600 r251765  
    174174Shared/ios/NativeWebMouseEventIOS.mm
    175175Shared/ios/NativeWebTouchEventIOS.mm
    176 Shared/ios/QuickLookDocumentData.cpp
    177176Shared/ios/WebAutocorrectionData.mm
    178177Shared/ios/WebIconUtilities.mm
  • trunk/Source/WebKit/UIProcess/API/APILoaderClient.h

    r248762 r251765  
    3939namespace WebKit {
    4040class AuthenticationChallengeProxy;
    41 class QuickLookDocumentData;
    4241class WebBackForwardListItem;
    4342class WebFrameProxy;
  • trunk/Source/WebKit/UIProcess/API/APINavigationClient.h

    r251220 r251765  
    5050class ResourceRequest;
    5151class ResourceResponse;
     52class SharedBuffer;
    5253struct SecurityOriginData;
    5354}
     
    5556namespace WebKit {
    5657class AuthenticationChallengeProxy;
    57 class QuickLookDocumentData;
    5858class WebBackForwardListItem;
    5959class WebFramePolicyListenerProxy;
     
    110110#if USE(QUICK_LOOK)
    111111    virtual void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) { }
    112     virtual void didFinishLoadForQuickLookDocumentInMainFrame(const WebKit::QuickLookDocumentData&) { }
     112    virtual void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&) { }
    113113#endif
    114114
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h

    r251220 r251765  
    123123#if USE(QUICK_LOOK)
    124124        void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) override;
    125         void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&) override;
     125        void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&) override;
    126126#endif
    127127
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r251220 r251765  
    8484#endif
    8585
    86 #if USE(QUICK_LOOK)
    87 #import "QuickLookDocumentData.h"
    88 #endif
    89 
    9086namespace WebKit {
    9187using namespace WebCore;
     
    10841080}
    10851081
    1086 void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
     1082void NavigationState::NavigationClient::didFinishLoadForQuickLookDocumentInMainFrame(const SharedBuffer& buffer)
    10871083{
    10881084    if (!m_navigationState.m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame)
     
    10931089        return;
    10941090
    1095     [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)data.decodedData()];
     1091    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didFinishLoadForQuickLookDocumentInMainFrame:buffer.createNSData().get()];
    10961092}
    10971093#endif
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp

    r251585 r251765  
    355355
    356356#if USE(QUICK_LOOK)
    357 void ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName)
    358 {
    359     m_page.didRequestPasswordForQuickLookDocumentInMainFrameShared(m_process.copyRef(), fileName);
     357void ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
     358{
     359    m_page.requestPasswordForQuickLookDocumentInMainFrameShared(fileName, WTFMove(completionHandler));
    360360}
    361361#endif
     
    470470
    471471#if USE(QUICK_LOOK)
    472     if (decoder.messageName() == Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame::name()) {
    473         IPC::handleMessage<Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame>(decoder, this, &ProvisionalPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame);
     472    if (decoder.messageName() == Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame::name()) {
     473        IPC::handleMessageAsync<Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame>(connection, decoder, this, &ProvisionalPageProxy::requestPasswordForQuickLookDocumentInMainFrame);
    474474        return;
    475475    }
  • trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h

    r251690 r251765  
    116116        WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&);
    117117#if USE(QUICK_LOOK)
    118     void didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName);
     118    void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&);
    119119#endif
    120120#if PLATFORM(COCOA)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r251737 r251765  
    4545#include "ShareSheetCallbackID.h"
    4646#include "ShareableBitmap.h"
     47#include "ShareableResource.h"
    4748#include "SuspendedPageProxy.h"
    4849#include "SyntheticEditingCommandType.h"
     
    329330enum class UndoOrRedo : bool;
    330331enum class WebContentMode : uint8_t;
    331 
    332 #if USE(QUICK_LOOK)
    333 class QuickLookDocumentData;
    334 #endif
    335332
    336333typedef GenericCallback<API::Data*> DataCallback;
     
    15611558        WebCore::ResourceResponse&& redirectResponse, const UserData&, Messages::WebPageProxy::DecidePolicyForNavigationActionSyncDelayedReply&&);
    15621559#if USE(QUICK_LOOK)
    1563     void didRequestPasswordForQuickLookDocumentInMainFrameShared(Ref<WebProcessProxy>&&, const String& fileName);
     1560    void requestPasswordForQuickLookDocumentInMainFrameShared(const String& fileName, CompletionHandler<void(const String&)>&&);
    15641561#endif
    15651562#if ENABLE(CONTENT_FILTERING)
     
    20532050#if USE(QUICK_LOOK)
    20542051    void didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti);
    2055     void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&);
    2056     void didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName);
     2052    void didFinishLoadForQuickLookDocumentInMainFrame(const ShareableResource::Handle&);
     2053    void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&);
    20572054#endif
    20582055
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r251737 r251765  
    468468#if USE(QUICK_LOOK)
    469469    DidStartLoadForQuickLookDocumentInMainFrame(String fileName, String uti)
    470     DidFinishLoadForQuickLookDocumentInMainFrame(WebKit::QuickLookDocumentData data)
    471     DidRequestPasswordForQuickLookDocumentInMainFrame(String fileName)
     470    DidFinishLoadForQuickLookDocumentInMainFrame(WebKit::ShareableResource::Handle resource)
     471    RequestPasswordForQuickLookDocumentInMainFrame(String fileName) -> (String password) Async
    472472#endif
    473473
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r251676 r251765  
    4848#import "RemoteLayerTreeTransaction.h"
    4949#import "RemoteScrollingCoordinatorProxy.h"
     50#import "ShareableResource.h"
    5051#import "UIKitSPI.h"
    5152#import "UserData.h"
     
    12501251
    12511252#if USE(QUICK_LOOK)
    1252    
     1253
    12531254void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
    12541255{
     
    12581259}
    12591260
    1260 void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
    1261 {
    1262     m_navigationClient->didFinishLoadForQuickLookDocumentInMainFrame(data);
    1263 }
    1264 
    1265 void WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrame(const String& fileName)
    1266 {
    1267     didRequestPasswordForQuickLookDocumentInMainFrameShared(m_process.copyRef(), fileName);
    1268 }
    1269 
    1270 void WebPageProxy::didRequestPasswordForQuickLookDocumentInMainFrameShared(Ref<WebProcessProxy>&& process, const String& fileName)
    1271 {
    1272     pageClient().requestPasswordForQuickLookDocument(fileName, [process = WTFMove(process), webPageID = m_webPageID](const String& password) {
    1273         process->send(Messages::WebPage::DidReceivePasswordForQuickLookDocument(password), webPageID);
    1274     });
     1261void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const ShareableResource::Handle& handle)
     1262{
     1263    auto buffer = handle.tryWrapInSharedBuffer();
     1264    if (!buffer)
     1265        return;
     1266
     1267    m_navigationClient->didFinishLoadForQuickLookDocumentInMainFrame(*buffer);
     1268}
     1269
     1270void WebPageProxy::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
     1271{
     1272    requestPasswordForQuickLookDocumentInMainFrameShared(fileName, WTFMove(completionHandler));
     1273}
     1274
     1275void WebPageProxy::requestPasswordForQuickLookDocumentInMainFrameShared(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
     1276{
     1277    pageClient().requestPasswordForQuickLookDocument(fileName, WTFMove(completionHandler));
    12751278}
    12761279
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r251600 r251765  
    13441344                A1046EA12079263100F0C5D8 /* WKPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = A1046E9F2079263100F0C5D8 /* WKPDFView.h */; };
    13451345                A115DC72191D82DA00DA8072 /* _WKWebViewPrintFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1346                 A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */; };
    13471346                A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13481347                A13B3DA2207F39DE0090C58D /* MobileWiFiSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A13B3DA1207F39DE0090C58D /* MobileWiFiSPI.h */; };
     
    13611360                A1A4FE5C18DCE9FA00B5EA8A /* _WKDownloadInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */; };
    13621361                A1A4FE6118DD54A400B5EA8A /* _WKDownloadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1362                A1ADAFB62368E6A8009CB776 /* SharedMemory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */; };
    13631363                A1C512C9190656E500448914 /* WebPreviewLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C512C7190656E500448914 /* WebPreviewLoaderClient.h */; };
    13641364                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1DF631118E0B7C8003A3E2A /* DownloadClient.h */; };
     
    17351735                        filePatterns = "*.h";
    17361736                        fileType = pattern.proxy;
     1737                        inputFiles = (
     1738                        );
    17371739                        isEditable = 1;
    17381740                        outputFiles = (
     
    40744076                A115DC6D191D82AB00DA8072 /* _WKWebViewPrintFormatter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKWebViewPrintFormatter.mm; sourceTree = "<group>"; };
    40754077                A115DC6E191D82AB00DA8072 /* _WKWebViewPrintFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKWebViewPrintFormatter.h; sourceTree = "<group>"; };
    4076                 A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = QuickLookDocumentData.cpp; path = ios/QuickLookDocumentData.cpp; sourceTree = "<group>"; };
    4077                 A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuickLookDocumentData.h; path = ios/QuickLookDocumentData.h; sourceTree = "<group>"; };
    40784078                A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKNSFileManagerExtras.mm; sourceTree = "<group>"; };
    40794079                A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKNSFileManagerExtras.h; sourceTree = "<group>"; };
     
    41034103                A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadInternal.h; sourceTree = "<group>"; };
    41044104                A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownloadDelegate.h; sourceTree = "<group>"; };
     4105                A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SharedMemory.cpp; sourceTree = "<group>"; };
    41054106                A1B89B92221E023300EB4CEA /* SDKVariant.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = SDKVariant.xcconfig; sourceTree = "<group>"; };
    41064107                A1B9CA382246E54A003D6DCA /* WebPaymentCoordinatorCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPaymentCoordinatorCocoa.mm; sourceTree = "<group>"; };
     
    60736074                                1C9EBA5B2087E74E00054429 /* NativeWebMouseEventIOS.mm */,
    60746075                                2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */,
    6075                                 A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */,
    6076                                 A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */,
    60776076                                4459984122833E6000E61373 /* SyntheticEditingCommandType.h */,
    60786077                                F40D1B68220BDC0F00B49A01 /* WebAutocorrectionContext.h */,
     
    84308429                                C0E3AA451209E2BA00A49D01 /* Module.cpp */,
    84318430                                C0E3AA441209E2BA00A49D01 /* Module.h */,
     8431                                A1ADAFB52368E4B8009CB776 /* SharedMemory.cpp */,
    84328432                                1A24BED3120894D100FBB059 /* SharedMemory.h */,
    84338433                        );
     
    97549754                                83048AE61ACA45DC0082C832 /* ProcessThrottlerClient.h in Headers */,
    97559755                                A1E688701F6E2BAB007006A6 /* QuarantineSPI.h in Headers */,
    9756                                 A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */,
    97579756                                57FD318222B3515E008D0E8B /* RedirectSOAuthorizationSession.h in Headers */,
    97589757                                2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */,
     
    1135611355                                41DE7C6C22278F1E00532B65 /* ServiceWorkerFetchTask.cpp in Sources */,
    1135711356                                2D92A787212B6AB100F493FD /* ShareableBitmap.cpp in Sources */,
     11357                                A1ADAFB62368E6A8009CB776 /* SharedMemory.cpp in Sources */,
    1135811358                                2DE6943D18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp in Sources */,
    1135911359                                1A334DED16DE8F88006A8E38 /* StorageAreaMapMessageReceiver.cpp in Sources */,
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.cpp

    r247786 r251765  
    3232#include "WebPageProxyMessages.h"
    3333#include "WebProcess.h"
    34 #include <WebCore/QuickLook.h>
     34#include <WebCore/SharedBuffer.h>
    3535#include <wtf/Function.h>
    3636#include <wtf/HashMap.h>
     
    3939namespace WebKit {
    4040
    41 using PasswordCallbackMap = HashMap<WebCore::PageIdentifier, Function<void(const String&)>>;
    42 static PasswordCallbackMap& passwordCallbacks()
    43 {
    44     static NeverDestroyed<PasswordCallbackMap> callbackMap;
    45     return callbackMap.get();
    46 }
     41using namespace WebCore;
    4742
    48 WebPreviewLoaderClient::WebPreviewLoaderClient(const String& fileName, const String& uti, WebCore::PageIdentifier pageID)
     43WebPreviewLoaderClient::WebPreviewLoaderClient(const String& fileName, const String& uti, PageIdentifier pageID)
    4944    : m_fileName { fileName }
    5045    , m_uti { uti }
    5146    , m_pageID { pageID }
     47    , m_buffer { SharedBuffer::create() }
    5248{
    5349}
    5450
    55 WebPreviewLoaderClient::~WebPreviewLoaderClient()
     51WebPreviewLoaderClient::~WebPreviewLoaderClient() = default;
     52
     53void WebPreviewLoaderClient::didReceiveBuffer(const SharedBuffer& buffer)
    5654{
    57     passwordCallbacks().remove(m_pageID);
    58 }
     55    auto webPage = WebProcess::singleton().webPage(m_pageID);
     56    if (!webPage)
     57        return;
    5958
    60 void WebPreviewLoaderClient::didReceiveDataArray(CFArrayRef dataArray)
    61 {
    62     if (m_data.isEmpty())
    63         WebProcess::singleton().send(Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame(m_fileName, m_uti), m_pageID);
     59    if (m_buffer->isEmpty())
     60        webPage->didStartLoadForQuickLookDocumentInMainFrame(m_fileName, m_uti);
    6461
    65     CFArrayApplyFunction(dataArray, CFRangeMake(0, CFArrayGetCount(dataArray)), [](const void* value, void* context) {
    66         ASSERT(CFGetTypeID(value) == CFDataGetTypeID());
    67         static_cast<QuickLookDocumentData*>(context)->append((CFDataRef)value);
    68     }, &m_data);   
     62    m_buffer->append(buffer);
    6963}
    7064
    7165void WebPreviewLoaderClient::didFinishLoading()
    7266{
    73     WebProcess::singleton().send(Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame(m_data), m_pageID);
    74     m_data.clear();
     67    auto webPage = WebProcess::singleton().webPage(m_pageID);
     68    if (!webPage)
     69        return;
     70
     71    webPage->didFinishLoadForQuickLookDocumentInMainFrame(m_buffer.get());
     72    m_buffer->clear();
    7573}
    7674
    7775void WebPreviewLoaderClient::didFail()
    7876{
    79     m_data.clear();
     77    m_buffer->clear();
    8078}
    8179
    8280void WebPreviewLoaderClient::didRequestPassword(Function<void(const String&)>&& completionHandler)
    8381{
    84     ASSERT(!passwordCallbacks().contains(m_pageID));
    85     passwordCallbacks().add(m_pageID, WTFMove(completionHandler));
    86     WebProcess::singleton().send(Messages::WebPageProxy::DidRequestPasswordForQuickLookDocumentInMainFrame(m_fileName), m_pageID);
    87 }
     82    auto webPage = WebProcess::singleton().webPage(m_pageID);
     83    if (!webPage) {
     84        completionHandler({ });
     85        return;
     86    }
    8887
    89 void WebPreviewLoaderClient::didReceivePassword(const String& password, WebCore::PageIdentifier pageID)
    90 {
    91     ASSERT(passwordCallbacks().contains(pageID));
    92     if (auto completionHandler = passwordCallbacks().take(pageID))
    93         completionHandler(password);
    94     else
    95         RELEASE_LOG_ERROR(Loading, "Discarding a password for a page that did not request one in this process");
     88    webPage->requestPasswordForQuickLookDocumentInMainFrame(m_fileName, WTFMove(completionHandler));
    9689}
    9790
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebPreviewLoaderClient.h

    r251488 r251765  
    2828#if USE(QUICK_LOOK)
    2929
    30 #include "QuickLookDocumentData.h"
    3130#include <WebCore/LegacyPreviewLoaderClient.h>
    3231#include <WebCore/PageIdentifier.h>
     
    4544    ~WebPreviewLoaderClient();
    4645
    47     static void didReceivePassword(const String&, WebCore::PageIdentifier);
    48 
    4946private:
    5047    WebPreviewLoaderClient(const String& fileName, const String& uti, WebCore::PageIdentifier);
    51     void didReceiveDataArray(CFArrayRef) override;
     48    void didReceiveBuffer(const WebCore::SharedBuffer&) override;
    5249    void didFinishLoading() override;
    5350    void didFail() override;
     
    5855    const String m_uti;
    5956    const WebCore::PageIdentifier m_pageID;
    60     QuickLookDocumentData m_data;
     57    Ref<WebCore::SharedBuffer> m_buffer;
    6158};
    6259
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r251737 r251765  
    12351235#endif // PLATFORM(IOS_FAMILY)
    12361236
     1237#if USE(QUICK_LOOK)
     1238    void didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti);
     1239    void didFinishLoadForQuickLookDocumentInMainFrame(const WebCore::SharedBuffer&);
     1240    void requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&&);
     1241#endif
     1242
    12371243private:
    12381244    WebPage(WebCore::PageIdentifier, WebPageCreationParameters&&);
     
    15961602    bool canPluginHandleResponse(const WebCore::ResourceResponse&);
    15971603
    1598 #if USE(QUICK_LOOK)
    1599     void didReceivePasswordForQuickLookDocument(const String&);
    1600 #endif
    1601 
    16021604    void simulateDeviceOrientationChange(double alpha, double beta, double gamma);
    16031605
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r251737 r251765  
    533533#endif
    534534
    535 #if USE(QUICK_LOOK)
    536     DidReceivePasswordForQuickLookDocument(String password)
    537 #endif
    538 
    539535    FrameBecameRemote(WebCore::FrameIdentifier frameID, struct WebCore::GlobalFrameIdentifier remoteFrameIdentifier, struct WebCore::GlobalWindowIdentifier remoteWindowIdentifier)
    540536
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r251720 r251765  
    4343#import "RemoteLayerTreeDrawingArea.h"
    4444#import "SandboxUtilities.h"
     45#import "SharedMemory.h"
    4546#import "SyntheticEditingCommandType.h"
    4647#import "TextCheckingControllerProxy.h"
     
    38443845}
    38453846
    3846 #if USE(QUICK_LOOK)
    3847 void WebPage::didReceivePasswordForQuickLookDocument(const String& password)
    3848 {
    3849     WebPreviewLoaderClient::didReceivePassword(password, m_identifier);
    3850 }
    3851 #endif
    3852 
    38533847bool WebPage::platformPrefersTextLegibilityBasedZoomScaling() const
    38543848{
     
    40794073}
    40804074
     4075#if USE(QUICK_LOOK)
     4076
     4077void WebPage::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
     4078{
     4079    send(Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame(fileName, uti));
     4080}
     4081
     4082void WebPage::didFinishLoadForQuickLookDocumentInMainFrame(const SharedBuffer& buffer)
     4083{
     4084    ASSERT(!buffer.isEmpty());
     4085
     4086    // FIXME: In some cases, buffer conains a single segment that wraps an existing ShareableResource.
     4087    // If we could create a handle from that existing resource then we could avoid this extra
     4088    // allocation and copy.
     4089
     4090    auto sharedMemory = SharedMemory::copyBuffer(buffer);
     4091    if (!sharedMemory)
     4092        return;
     4093
     4094    ShareableResource::Handle handle;
     4095    auto shareableResource = ShareableResource::create(sharedMemory.releaseNonNull(), 0, buffer.size());
     4096    if (!shareableResource->createHandle(handle))
     4097        return;
     4098
     4099    send(Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame(handle));
     4100}
     4101
     4102void WebPage::requestPasswordForQuickLookDocumentInMainFrame(const String& fileName, CompletionHandler<void(const String&)>&& completionHandler)
     4103{
     4104    sendWithAsyncReply(Messages::WebPageProxy::RequestPasswordForQuickLookDocumentInMainFrame(fileName), WTFMove(completionHandler));
     4105}
     4106
     4107#endif
     4108
    40814109} // namespace WebKit
    40824110
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r251630 r251765  
     12019-10-29  Andy Estes  <aestes@apple.com>
     2
     3        [Quick Look] Clean up LegacyPreviewLoaderClients
     4        https://bugs.webkit.org/show_bug.cgi?id=203472
     5
     6        Reviewed by Brady Eidson.
     7
     8        * WebCoreSupport/WebFrameLoaderClient.mm:
     9        (WebFrameLoaderClient::createPreviewLoaderClient):
     10
    1112019-10-26  Chris Lord  <clord@igalia.com>
    212
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r251488 r251765  
    22072207        RetainPtr<NSFileHandle> m_fileHandle;
    22082208
    2209         void didReceiveDataArray(CFArrayRef dataArray) override
     2209        void didReceiveBuffer(const WebCore::SharedBuffer& buffer) override
    22102210        {
    2211             for (NSData *data in (NSArray *)dataArray)
     2211            auto dataArray = buffer.createNSDataArray();
     2212            for (NSData *data in dataArray.get())
    22122213                [m_fileHandle writeData:data];
    22132214        }
  • trunk/Tools/ChangeLog

    r251763 r251765  
     12019-10-29  Andy Estes  <aestes@apple.com>
     2
     3        [Quick Look] Clean up LegacyPreviewLoaderClients
     4        https://bugs.webkit.org/show_bug.cgi?id=203472
     5
     6        Reviewed by Brady Eidson.
     7
     8        Updated API tests to compare data received in
     9        -_webView:didFinishLoadForQuickLookDocumentInMainFrame: with expected data.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm:
     12        (readFile):
     13        (-[QuickLookDelegate initWithExpectedFileURL:responsePolicy:]):
     14        (-[QuickLookDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]):
     15        (-[QuickLookDelegate verifyDownload]):
     16        (TEST):
     17
    1182019-10-29  Jonathan Bedard  <jbedard@apple.com>
    219
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/QuickLook.mm

    r251223 r251765  
    7171    NSUInteger _downloadFileSize;
    7272    NSUInteger _expectedFileSize;
     73    RetainPtr<NSData> _expectedFileData;
    7374    RetainPtr<NSString> _expectedFileName;
    7475    RetainPtr<NSString> _expectedFileType;
     
    7879}
    7980
    80 static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>& fileName, RetainPtr<NSString>& fileType, RetainPtr<NSString>& mimeType)
     81static void readFile(NSURL *fileURL, NSUInteger& fileSize, RetainPtr<NSString>& fileName, RetainPtr<NSString>& fileType, RetainPtr<NSString>& mimeType, RetainPtr<NSData>& fileData)
    8182{
    8283    if (NSDictionary *attributes = [NSFileManager.defaultManager attributesOfItemAtPath:fileURL.path error:nil])
     
    9091
    9192    mimeType = adoptCF(UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)typeIdentifier, kUTTagClassMIMEType));
     93    fileData = [NSData dataWithContentsOfURL:fileURL];
    9294}
    9395
     
    9799        return nil;
    98100
    99     readFile(fileURL, _expectedFileSize, _expectedFileName, _expectedFileType, _expectedMIMEType);
     101    readFile(fileURL, _expectedFileSize, _expectedFileName, _expectedFileType, _expectedMIMEType, _expectedFileData);
    100102
    101103    _responsePolicy = responsePolicy;
     
    140142{
    141143    EXPECT_EQ(_expectedFileSize, documentData.length);
     144    EXPECT_TRUE([_expectedFileData isEqualToData:documentData]);
    142145    EXPECT_FALSE(_didFinishQuickLookLoad);
    143146    EXPECT_TRUE(_didStartQuickLookLoad);
     
    220223
    221224    NSUInteger downloadFileSize;
     225    RetainPtr<NSData> downloadFileData;
    222226    RetainPtr<NSString> downloadFileName;
    223227    RetainPtr<NSString> downloadFileType;
    224228    RetainPtr<NSString> downloadMIMEType;
    225     readFile(_downloadDestinationURL.get(), downloadFileSize, downloadFileName, downloadFileType, downloadMIMEType);
     229    readFile(_downloadDestinationURL.get(), downloadFileSize, downloadFileName, downloadFileType, downloadMIMEType, downloadFileData);
    226230
    227231    EXPECT_EQ(_expectedFileSize, downloadFileSize);
     232    EXPECT_TRUE([_expectedFileData isEqualToData:downloadFileData.get()]);
    228233    EXPECT_WK_STREQ(_expectedFileName.get(), downloadFileName.get());
    229234    EXPECT_WK_STREQ(_expectedFileType.get(), downloadFileType.get());
     
    466471
    467472    NSUInteger expectedFileSize;
     473    RetainPtr<NSData> expectedFileData;
    468474    RetainPtr<NSString> expectedFileName;
    469475    RetainPtr<NSString> expectedFileType;
    470476    RetainPtr<NSString> expectedMIMEType;
    471     readFile(pagesDocumentURL, expectedFileSize, expectedFileName, expectedFileType, expectedMIMEType);
     477    readFile(pagesDocumentURL, expectedFileSize, expectedFileName, expectedFileType, expectedMIMEType, expectedFileData);
    472478
    473479    NSDictionary *quickLookContent = mainFrame.dataSource._quickLookContent;
     
    479485    NSDictionary *fileAttributes = [NSFileManager.defaultManager attributesOfItemAtPath:filePath error:nil];
    480486    EXPECT_EQ(expectedFileSize, [fileAttributes[NSFileSize] unsignedIntegerValue]);
     487   
     488    EXPECT_TRUE([expectedFileData isEqualToData:[NSData dataWithContentsOfFile:filePath]]);
    481489
    482490    isDone = false;
Note: See TracChangeset for help on using the changeset viewer.