[iOS] Implement WebQuickLookHandleClient for WebKit2
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Apr 2014 20:02:41 +0000 (20:02 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Apr 2014 20:02:41 +0000 (20:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132157

Reviewed by Darin Adler.

Source/WebCore:
* WebCore.exp.in: Exported QuickLookHandle::previewUTI().
* platform/network/ios/QuickLook.h:
* platform/network/ios/QuickLook.mm:
(WebCore::QuickLookHandle::previewFileName): Changed to return a WTF::String.
(WebCore::QuickLookHandle::previewUTI): Added.

Source/WebKit2:
* Shared/API/Cocoa/_WKNSFileManagerExtras.h: Added.
* Shared/API/Cocoa/_WKNSFileManagerExtras.mm: Added.
(+[NSFileManager _web_createTemporaryFileForQuickLook:]): Called WebCore::createTemporaryFileForQuickLook().
* Shared/ios/QuickLookDocumentData.cpp: Added.
(WebKit::QuickLookDocumentData::QuickLookDocumentData):
(WebKit::QuickLookDocumentData::append): Appened each CFDataRef to m_data and added their sizes to m_size.
(WebKit::QuickLookDocumentData::decodedData): Returned the combined CFDataRef created by decode().
Named this method 'decodedData' to indicate that it should only be called on objects populated by decode().
(WebKit::QuickLookDocumentData::clear): Cleared m_data and reset m_size to 0.
(WebKit::QuickLookDocumentData::encode): Implemented a custom encoding function to avoid having to combine
m_data into contiguous memory at encoding time. Encoded m_size then sequentially encoded each member of m_data.
(WebKit::QuickLookDocumentData::decode): Decoded the byte stream into a single CFDataRef. Eagerly copied the
decoded data rather than using a DataReference since we know this will outlive the decoder.
* Shared/ios/QuickLookDocumentData.h: Added.
* UIProcess/API/APILoaderClient.h:
(API::LoaderClient::didStartLoadForQuickLookDocumentInMainFrame):
(API::LoaderClient::didFinishLoadForQuickLookDocumentInMainFrame):
* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate):
(WebKit::NavigationState::LoaderClient::didStartLoadForQuickLookDocumentInMainFrame):
(WebKit::NavigationState::LoaderClient::didFinishLoadForQuickLookDocumentInMainFrame):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame):
(WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm:
(WebKit::WebFrameLoaderClient::didCreateQuickLookHandle):
* WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.cpp: Added.
(WebKit::WebQuickLookHandleClient::WebQuickLookHandleClient): Sent DidStartLoadForQuickLookDocumentInMainFrame
to WebPageProxy.
(WebKit::WebQuickLookHandleClient::didReceiveDataArray): Appended dataArray to m_data.
(WebKit::WebQuickLookHandleClient::didFinishLoading): Sent DidFinishLoadForQuickLookDocumentInMainFrame to
WebPageProxy and then cleared m_data.
(WebKit::WebQuickLookHandleClient::didFail): Cleared m_data.
* WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.h: Added.
(WebKit::WebQuickLookHandleClient::create):

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

21 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/network/ios/QuickLook.h
Source/WebCore/platform/network/ios/QuickLook.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/Cocoa/_WKNSFileManagerExtras.h [new file with mode: 0644]
Source/WebKit2/Shared/API/Cocoa/_WKNSFileManagerExtras.mm [new file with mode: 0644]
Source/WebKit2/Shared/ios/QuickLookDocumentData.cpp [new file with mode: 0644]
Source/WebKit2/Shared/ios/QuickLookDocumentData.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/APILoaderClient.h
Source/WebKit2/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h
Source/WebKit2/UIProcess/Cocoa/NavigationState.h
Source/WebKit2/UIProcess/Cocoa/NavigationState.mm
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit2/WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm
Source/WebKit2/WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.h [new file with mode: 0644]

index f7fa621..b3c5317 100644 (file)
@@ -1,3 +1,16 @@
+2014-04-24  Andy Estes  <aestes@apple.com>
+
+        [iOS] Implement WebQuickLookHandleClient for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=132157
+
+        Reviewed by Darin Adler.
+
+        * WebCore.exp.in: Exported QuickLookHandle::previewUTI().
+        * platform/network/ios/QuickLook.h:
+        * platform/network/ios/QuickLook.mm:
+        (WebCore::QuickLookHandle::previewFileName): Changed to return a WTF::String.
+        (WebCore::QuickLookHandle::previewUTI): Added.
+
 2014-04-28  Chris Fleizach  <cfleizach@apple.com>
 
         REGRESSION: Intermittent crash in SpeechSynthesis::didFinishSpeaking
index 99013f7..b85d782 100644 (file)
@@ -3231,6 +3231,7 @@ __ZN7WebCore32qlPreviewConverterFileNameForURLEP5NSURL
 __ZN7WebCore33QLPreviewGetSupportedMIMETypesSetEv
 __ZN7WebCore34registerQLPreviewConverterIfNeededEP5NSURLP8NSStringP6NSData
 __ZN7WebCore35addQLPreviewConverterWithFileForURLEP5NSURLP11objc_objectP8NSString
+__ZNK7WebCore15QuickLookHandle10previewUTIEv
 __ZNK7WebCore15QuickLookHandle15previewFileNameEv
 __ZNK7WebCore15QuickLookHandle17previewRequestURLEv
 #endif
index 57405c6..f52401c 100644 (file)
@@ -101,7 +101,8 @@ public:
 
     void setClient(PassRefPtr<QuickLookHandleClient> client) { m_client = client; }
 
-    NSString *previewFileName() const;
+    String previewFileName() const;
+    String previewUTI() const;
     NSURL *firstRequestURL() const { return m_firstRequestURL.get(); }
     NSURL *previewRequestURL() const;
     QLPreviewConverter *converter() const { return m_converter.get(); }
index 218d68e..89df408 100644 (file)
@@ -515,11 +515,16 @@ QuickLookHandle::~QuickLookHandle()
     [m_delegate clearHandle];
 }
 
-NSString *QuickLookHandle::previewFileName() const
+String QuickLookHandle::previewFileName() const
 {
     return [m_converter previewFileName];
 }
 
+String QuickLookHandle::previewUTI() const
+{
+    return [m_converter previewUTI];
+}
+
 NSURL *QuickLookHandle::previewRequestURL() const
 {
     return [[m_converter previewRequest] URL];
index 4ee331c..4ddd2f9 100644 (file)
@@ -1,3 +1,52 @@
+2014-04-24  Andy Estes  <aestes@apple.com>
+
+        [iOS] Implement WebQuickLookHandleClient for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=132157
+
+        Reviewed by Darin Adler.
+
+        * Shared/API/Cocoa/_WKNSFileManagerExtras.h: Added.
+        * Shared/API/Cocoa/_WKNSFileManagerExtras.mm: Added.
+        (+[NSFileManager _web_createTemporaryFileForQuickLook:]): Called WebCore::createTemporaryFileForQuickLook().
+        * Shared/ios/QuickLookDocumentData.cpp: Added.
+        (WebKit::QuickLookDocumentData::QuickLookDocumentData):
+        (WebKit::QuickLookDocumentData::append): Appened each CFDataRef to m_data and added their sizes to m_size.
+        (WebKit::QuickLookDocumentData::decodedData): Returned the combined CFDataRef created by decode().
+        Named this method 'decodedData' to indicate that it should only be called on objects populated by decode().
+        (WebKit::QuickLookDocumentData::clear): Cleared m_data and reset m_size to 0.
+        (WebKit::QuickLookDocumentData::encode): Implemented a custom encoding function to avoid having to combine
+        m_data into contiguous memory at encoding time. Encoded m_size then sequentially encoded each member of m_data.
+        (WebKit::QuickLookDocumentData::decode): Decoded the byte stream into a single CFDataRef. Eagerly copied the
+        decoded data rather than using a DataReference since we know this will outlive the decoder.
+        * Shared/ios/QuickLookDocumentData.h: Added.
+        * UIProcess/API/APILoaderClient.h:
+        (API::LoaderClient::didStartLoadForQuickLookDocumentInMainFrame):
+        (API::LoaderClient::didFinishLoadForQuickLookDocumentInMainFrame):
+        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::setNavigationDelegate):
+        (WebKit::NavigationState::LoaderClient::didStartLoadForQuickLookDocumentInMainFrame):
+        (WebKit::NavigationState::LoaderClient::didFinishLoadForQuickLookDocumentInMainFrame):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame):
+        (WebKit::WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame):
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        * WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm:
+        (WebKit::WebFrameLoaderClient::didCreateQuickLookHandle):
+        * WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.cpp: Added.
+        (WebKit::WebQuickLookHandleClient::WebQuickLookHandleClient): Sent DidStartLoadForQuickLookDocumentInMainFrame
+        to WebPageProxy.
+        (WebKit::WebQuickLookHandleClient::didReceiveDataArray): Appended dataArray to m_data.
+        (WebKit::WebQuickLookHandleClient::didFinishLoading): Sent DidFinishLoadForQuickLookDocumentInMainFrame to
+        WebPageProxy and then cleared m_data.
+        (WebKit::WebQuickLookHandleClient::didFail): Cleared m_data.
+        * WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.h: Added.
+        (WebKit::WebQuickLookHandleClient::create):
+
 2014-04-28  Brady Eidson  <beidson@apple.com>
 
         Hide service controls for selection behind a runtime switch
diff --git a/Source/WebKit2/Shared/API/Cocoa/_WKNSFileManagerExtras.h b/Source/WebKit2/Shared/API/Cocoa/_WKNSFileManagerExtras.h
new file mode 100644 (file)
index 0000000..ec028e0
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#import <WebKit2/WKFoundation.h>
+
+#if TARGET_OS_IPHONE
+
+@interface NSFileManager (WKExtras)
+
++ (NSString *)_web_createTemporaryFileForQuickLook:(NSString *)fileName;
+
+@end
+
+#endif // TARGET_OS_IPHONE
diff --git a/Source/WebKit2/Shared/API/Cocoa/_WKNSFileManagerExtras.mm b/Source/WebKit2/Shared/API/Cocoa/_WKNSFileManagerExtras.mm
new file mode 100644 (file)
index 0000000..84609f0
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+#import "_WKNSFileManagerExtras.h"
+
+#if USE(QUICK_LOOK)
+
+#import <WebCore/QuickLook.h>
+
+@implementation NSFileManager (WKExtras)
+
++ (NSString *)_web_createTemporaryFileForQuickLook:(NSString *)fileName
+{
+    return WebCore::createTemporaryFileForQuickLook(fileName);
+}
+
+@end
+
+#endif // USE(QUICK_LOOK)
diff --git a/Source/WebKit2/Shared/ios/QuickLookDocumentData.cpp b/Source/WebKit2/Shared/ios/QuickLookDocumentData.cpp
new file mode 100644 (file)
index 0000000..b256c38
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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 "ArgumentDecoder.h"
+#include "ArgumentEncoder.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();
+}
+
+void QuickLookDocumentData::clear()
+{
+    m_data.clear();
+}
+
+void QuickLookDocumentData::encode(IPC::ArgumentEncoder& 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::ArgumentDecoder& 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)
diff --git a/Source/WebKit2/Shared/ios/QuickLookDocumentData.h b/Source/WebKit2/Shared/ios/QuickLookDocumentData.h
new file mode 100644 (file)
index 0000000..6e7155c
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+#ifndef QuickLookDocumentData_h
+#define QuickLookDocumentData_h
+
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+
+namespace IPC {
+class ArgumentDecoder;
+class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class QuickLookDocumentData {
+public:
+    void append(CFDataRef);
+    CFDataRef decodedData() const;
+    void clear();
+    void encode(IPC::ArgumentEncoder&) const;
+    static bool decode(IPC::ArgumentDecoder&, QuickLookDocumentData&);
+
+private:
+    Vector<RetainPtr<CFDataRef>, 1> m_data;
+};
+} // namespace WebKit
+
+#endif // QuickLookDocumentData_h
index 69e9eee..3b97b38 100644 (file)
@@ -39,6 +39,7 @@ class ResourceError;
 namespace WebKit {
 class AuthenticationChallengeProxy;
 class ImmutableDictionary;
+class QuickLookDocumentData;
 class WebBackForwardListItem;
 class WebFrameProxy;
 class WebPageProxy;
@@ -100,6 +101,11 @@ public:
     virtual WebCore::WebGLLoadPolicy webGLLoadPolicy(WebKit::WebPageProxy*, const WTF::String&) const { return WebCore::WebGLLoadPolicy::WebGLAllowCreation; }
     virtual WebCore::WebGLLoadPolicy resolveWebGLLoadPolicy(WebKit::WebPageProxy*, const WTF::String&) const { return WebCore::WebGLLoadPolicy::WebGLAllowCreation; }
 #endif // ENABLE(WEBGL)
+
+#if USE(QUICK_LOOK)
+    virtual void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) { }
+    virtual void didFinishLoadForQuickLookDocumentInMainFrame(const WebKit::QuickLookDocumentData&) { }
+#endif
 };
 
 } // namespace API
index ffb40f2..2857f3c 100644 (file)
@@ -45,6 +45,11 @@ static const WKNavigationResponsePolicy _WKNavigationResponsePolicyBecomeDownloa
 
 - (void)_webViewWebProcessDidCrash:(WKWebView *)webView;
 
+#if TARGET_OS_IPHONE
+- (void)_webView:(WKWebView *)webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:(NSString *)fileName uti:(NSString *)uti;
+- (void)_webView:(WKWebView *)webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)documentData;
+#endif
+
 @end
 
 #endif
index 054ca0e..4824c94 100644 (file)
@@ -103,6 +103,10 @@ private:
         virtual void didReceiveAuthenticationChallengeInFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::AuthenticationChallengeProxy*) override;
         virtual void processDidCrash(WebKit::WebPageProxy*) override;
         virtual void didChangeBackForwardList(WebKit::WebPageProxy*, WebKit::WebBackForwardListItem* addedItem, Vector<RefPtr<WebKit::WebBackForwardListItem>> removedItems) override;
+#if USE(QUICK_LOOK)
+        virtual void didStartLoadForQuickLookDocumentInMainFrame(const WTF::String& fileName, const WTF::String& uti) override;
+        virtual void didFinishLoadForQuickLookDocumentInMainFrame(const WebKit::QuickLookDocumentData&) override;
+#endif
 
         NavigationState& m_navigationState;
     };
@@ -138,6 +142,10 @@ private:
         bool webViewCanAuthenticateAgainstProtectionSpace : 1;
         bool webViewDidReceiveAuthenticationChallenge : 1;
         bool webViewWebProcessDidCrash : 1;
+#if USE(QUICK_LOOK)
+        bool webViewDidStartLoadForQuickLookDocumentInMainFrame : 1;
+        bool webViewDidFinishLoadForQuickLookDocumentInMainFrame : 1;
+#endif
     } m_navigationDelegateMethods;
 
     HashMap<uint64_t, RetainPtr<WKNavigation>> m_navigations;
index 003665e..4b55197 100644 (file)
 #import "WebPageProxy.h"
 #import <wtf/NeverDestroyed.h>
 
+#if USE(QUICK_LOOK)
+#import "QuickLookDocumentData.h"
+#endif
+
 namespace WebKit {
 
 static HashMap<WebPageProxy*, NavigationState*>& navigationStates()
@@ -123,6 +127,10 @@ void NavigationState::setNavigationDelegate(id <WKNavigationDelegate> delegate)
     m_navigationDelegateMethods.webViewCanAuthenticateAgainstProtectionSpace = [delegate respondsToSelector:@selector(_webView:canAuthenticateAgainstProtectionSpace:)];
     m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallenge = [delegate respondsToSelector:@selector(_webView:didReceiveAuthenticationChallenge:)];
     m_navigationDelegateMethods.webViewWebProcessDidCrash = [delegate respondsToSelector:@selector(_webViewWebProcessDidCrash:)];
+#if USE(QUICK_LOOK)
+    m_navigationDelegateMethods.webViewDidStartLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:)];
+    m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame = [delegate respondsToSelector:@selector(_webView:didFinishLoadForQuickLookDocumentInMainFrame:)];
+#endif
 }
 
 RetainPtr<id <WKHistoryDelegatePrivate> > NavigationState::historyDelegate()
@@ -567,6 +575,32 @@ void NavigationState::LoaderClient::didChangeBackForwardList(WebKit::WebPageProx
     [[NSNotificationCenter defaultCenter] postNotificationName:_WKBackForwardListDidChangeNotification object:wrapper(m_navigationState.m_webView->_page->backForwardList())];
 }
 
+#if USE(QUICK_LOOK)
+void NavigationState::LoaderClient::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
+{
+    if (!m_navigationState.m_navigationDelegateMethods.webViewDidStartLoadForQuickLookDocumentInMainFrame)
+        return;
+
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:fileName uti:uti];
+}
+
+void NavigationState::LoaderClient::didFinishLoadForQuickLookDocumentInMainFrame(const WebKit::QuickLookDocumentData& data)
+{
+    if (!m_navigationState.m_navigationDelegateMethods.webViewDidFinishLoadForQuickLookDocumentInMainFrame)
+        return;
+
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)data.decodedData()];
+}
+#endif
+
 void NavigationState::willChangeIsLoading()
 {
     [m_webView willChangeValueForKey:@"loading"];
index bec0d85..e7fc3dc 100644 (file)
@@ -173,6 +173,10 @@ struct WebPopupItem;
 class WebVibrationProxy;
 #endif
 
+#if USE(QUICK_LOOK)
+class QuickLookDocumentData;
+#endif
+
 typedef GenericCallback<uint64_t> UnsignedCallback;
 typedef GenericCallback<EditingRange> EditingRangeCallback;
 typedef GenericCallback<StringImpl*> StringCallback;
@@ -1394,6 +1398,11 @@ private:
     void findPlugin(const String& mimeType, uint32_t processType, const String& urlString, const String& frameURLString, const String& pageURLString, bool allowOnlyApplicationPlugins, uint64_t& pluginProcessToken, String& newMIMEType, uint32_t& pluginLoadPolicy, String& unavailabilityDescription);
 #endif
 
+#if USE(QUICK_LOOK)
+    void didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti);
+    void didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData&);
+#endif
+
     uint64_t generateNavigationID();
 
     PageClient& m_pageClient;
index 3129be2..18836a8 100644 (file)
@@ -367,4 +367,9 @@ messages -> WebPageProxy {
     ShowTelephoneNumberMenu(String telephoneNumber, WebCore::IntPoint point)
 #endif
 #endif
+
+#if USE(QUICK_LOOK)
+    DidStartLoadForQuickLookDocumentInMainFrame(String fileName, String uti)
+    DidFinishLoadForQuickLookDocumentInMainFrame(WebKit::QuickLookDocumentData data)
+#endif
 }
index 5251e48..3f4683b 100644 (file)
 #import <WebCore/SharedBuffer.h>
 #import <WebCore/UserAgent.h>
 
+#if USE(QUICK_LOOK)
+#import "APILoaderClient.h"
+#import <wtf/text/WTFString.h>
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -575,6 +580,21 @@ void WebPageProxy::zoomToRect(FloatRect rect, double minimumScale, double maximu
     m_pageClient.zoomToRect(rect, minimumScale, maximumScale);
 }
 
+#if USE(QUICK_LOOK)
+    
+void WebPageProxy::didStartLoadForQuickLookDocumentInMainFrame(const String& fileName, const String& uti)
+{
+    // Ensure that fileName isn't really a path name
+    static_assert(notFound + 1 == 0, "The following line assumes WTF::notFound equals -1");
+    m_loaderClient->didStartLoadForQuickLookDocumentInMainFrame(fileName.substring(fileName.reverseFind('/') + 1), uti);
+}
+
+void WebPageProxy::didFinishLoadForQuickLookDocumentInMainFrame(const QuickLookDocumentData& data)
+{
+    m_loaderClient->didFinishLoadForQuickLookDocumentInMainFrame(data);
+}
+#endif
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)
index 238c2ed..7032e96 100644 (file)
                9F54F8951648AE0F007DF81A /* PluginProcessManagerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9F54F8941648AE0E007DF81A /* PluginProcessManagerMac.mm */; };
                9FB5F394169E6A80002C25BF /* WKContextPrivateMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9FB5F392169E6A80002C25BF /* WKContextPrivateMac.mm */; };
                9FB5F395169E6A80002C25BF /* WKContextPrivateMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 9FB5F393169E6A80002C25BF /* WKContextPrivateMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A118A9EE1907AD6F00F7C92B /* QuickLookDocumentData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */; };
+               A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */; };
+               A118A9F21908B8EA00F7C92B /* _WKNSFileManagerExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */; };
+               A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE5718DCE9FA00B5EA8A /* _WKDownload.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1A4FE5B18DCE9FA00B5EA8A /* _WKDownload.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1A4FE5818DCE9FA00B5EA8A /* _WKDownload.mm */; };
                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, ); }; };
+               A1C512C8190656E500448914 /* WebQuickLookHandleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1C512C6190656E500448914 /* WebQuickLookHandleClient.cpp */; };
+               A1C512C9190656E500448914 /* WebQuickLookHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C512C7190656E500448914 /* WebQuickLookHandleClient.h */; };
                A1DF631218E0B7C8003A3E2A /* DownloadClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */; };
                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1DF631118E0B7C8003A3E2A /* DownloadClient.h */; };
                A5EFD38C16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = A5EFD38B16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                9F54F8941648AE0E007DF81A /* PluginProcessManagerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PluginProcessManagerMac.mm; sourceTree = "<group>"; };
                9FB5F392169E6A80002C25BF /* WKContextPrivateMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKContextPrivateMac.mm; path = mac/WKContextPrivateMac.mm; sourceTree = "<group>"; };
                9FB5F393169E6A80002C25BF /* WKContextPrivateMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKContextPrivateMac.h; path = mac/WKContextPrivateMac.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>"; };
                A1A4FE5718DCE9FA00B5EA8A /* _WKDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDownload.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>"; };
+               A1C512C6190656E500448914 /* WebQuickLookHandleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebQuickLookHandleClient.cpp; path = ios/WebQuickLookHandleClient.cpp; sourceTree = "<group>"; };
+               A1C512C7190656E500448914 /* WebQuickLookHandleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebQuickLookHandleClient.h; path = ios/WebQuickLookHandleClient.h; sourceTree = "<group>"; };
                A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadClient.mm; sourceTree = "<group>"; };
                A1DF631118E0B7C8003A3E2A /* DownloadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadClient.h; sourceTree = "<group>"; };
                A1EDD2D91884ACE000BBFE98 /* All.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = All.xcconfig; sourceTree = "<group>"; };
                                2D28F3E11885CCC1004B9EAE /* WebDatabaseManagerIOS.mm */,
                                2D28F3E21885CCC1004B9EAE /* WebEditorClientIOS.mm */,
                                2D28F3E31885CCC1004B9EAE /* WebFrameLoaderClientIOS.mm */,
+                               A1C512C6190656E500448914 /* WebQuickLookHandleClient.cpp */,
+                               A1C512C7190656E500448914 /* WebQuickLookHandleClient.h */,
                        );
                        name = ios;
                        sourceTree = "<group>";
                                2DA9449D1884E4F000ED86DB /* GestureTypes.h */,
                                2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */,
                                2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */,
+                               A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */,
+                               A118A9ED1907AD6F00F7C92B /* QuickLookDocumentData.h */,
                                2DA944991884E4F000ED86DB /* WebIOSEventFactory.h */,
                                2DA9449A1884E4F000ED86DB /* WebIOSEventFactory.mm */,
                                2DA9449B1884E4F000ED86DB /* WebPlatformTouchPointIOS.cpp */,
                                373D122118A473010066D9CC /* _WKFrameHandle.h */,
                                373D122018A473010066D9CC /* _WKFrameHandle.mm */,
                                373D122618A473F60066D9CC /* _WKFrameHandleInternal.h */,
+                               A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */,
+                               A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */,
                                1A9E328B182165A900F5D04C /* _WKRemoteObjectInterface.h */,
                                1A9E328C182165A900F5D04C /* _WKRemoteObjectInterface.mm */,
                                1AABFE391829C1ED005B070E /* _WKRemoteObjectInterfaceInternal.h */,
                                BCB0AEE9122F53E300B1341E /* MutableDictionary.h in Headers */,
                                1A6FBA2A11E6862700DB1371 /* NetscapeBrowserFuncs.h in Headers */,
                                1A6FBD2811E69BC200DB1371 /* NetscapePlugin.h in Headers */,
+                               A1C512C9190656E500448914 /* WebQuickLookHandleClient.h in Headers */,
                                1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */,
                                1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */,
                                E1798C7A16E6818800240139 /* NetworkBlobRegistry.h in Headers */,
                                5106D7C418BDBE73000AB166 /* ContextMenuContextData.h in Headers */,
                                BC8ACA1516670D89004C1941 /* ObjCObjectGraphCoders.h in Headers */,
                                BCCF672D12C7EDF7008F9C35 /* OriginAndDatabases.h in Headers */,
+                               A118A9EF1907AD6F00F7C92B /* QuickLookDocumentData.h in Headers */,
                                1A5B1C511898606F004FCF9B /* WKNavigation.h in Headers */,
                                7CF47FFB17275C57008ACB91 /* PageBanner.h in Headers */,
                                BC6EDAA6111271C600E7678B /* PageClient.h in Headers */,
                                BCCF6AC312C91F34008F9C35 /* WKImage.h in Headers */,
                                BCCF6ACA12C91F59008F9C35 /* WKImageCG.h in Headers */,
                                1C8E293912761E5B00BC7BD0 /* WKInspector.h in Headers */,
+                               A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */,
                                6EE849C81368D9390038D481 /* WKInspectorPrivateMac.h in Headers */,
                                51A9E10B1315CD18009E7031 /* WKKeyValueStorageManager.h in Headers */,
                                33D3A3B61339600B00709BE4 /* WKMediaCacheManager.h in Headers */,
                                BC82844D16B5081C00A278FE /* PluginServiceEntryPoint.mm in Sources */,
                                1A6FB7AE11E64B6800DB1371 /* PluginView.cpp in Sources */,
                                E18C92F412DB9E7100CF2AEB /* PrintInfo.cpp in Sources */,
+                               A1C512C8190656E500448914 /* WebQuickLookHandleClient.cpp in Sources */,
                                E1CC1B9112D7EADF00625838 /* PrintInfoMac.mm in Sources */,
                                1AC1336E18565D2B00F3EC05 /* APIPageHandle.cpp in Sources */,
                                1AE117F611DBB30900981615 /* ProcessLauncher.cpp in Sources */,
                                BC032DBA10F4380F0058C15A /* WebEventConversion.cpp in Sources */,
                                2D140EAF18F37BE0005E75A0 /* PageOverlayController.cpp in Sources */,
                                BC111B5E112F629800337BAB /* WebEventFactory.mm in Sources */,
+                               A118A9EE1907AD6F00F7C92B /* QuickLookDocumentData.cpp in Sources */,
                                1A3DD1FD125E59F3004515E6 /* WebFindClient.cpp in Sources */,
                                BCE469531214E6CB000B98EB /* WebFormClient.cpp in Sources */,
                                BCE469551214E6CB000B98EB /* WebFormSubmissionListenerProxy.cpp in Sources */,
                                512E34E4130B4D0500ABD19A /* WKApplicationCacheManager.cpp in Sources */,
                                51C96118183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp in Sources */,
                                BC4075F3124FF0270068F20A /* WKArray.cpp in Sources */,
+                               A118A9F21908B8EA00F7C92B /* _WKNSFileManagerExtras.mm in Sources */,
                                512F58F512A88A5400629530 /* WKAuthenticationChallenge.cpp in Sources */,
                                51E351CA180F2CCC00E53BE9 /* IDBUtilities.cpp in Sources */,
                                512F58F712A88A5400629530 /* WKAuthenticationDecisionListener.cpp in Sources */,
index 92404e9..f715c26 100644 (file)
@@ -229,6 +229,10 @@ private:
 
     virtual void forcePageTransitionIfNeeded() override;
 
+#if USE(QUICK_LOOK)
+    virtual void didCreateQuickLookHandle(WebCore::QuickLookHandle&) override;
+#endif
+
     WebFrame* m_frame;
     RefPtr<PluginView> m_pluginView;
     bool m_hasSentResponseToPluginView;
index adebafd..a03a2cb 100644 (file)
 
 #import <WebCore/NotImplemented.h>
 
+#if USE(QUICK_LOOK)
+#import "WebFrame.h"
+#import "WebPage.h"
+#import "WebQuickLookHandleClient.h"
+#import <WebCore/QuickLook.h>
+#endif
+
 using namespace WebCore;
 
 namespace WebKit {
@@ -50,6 +57,20 @@ RetainPtr<CFDictionaryRef> WebFrameLoaderClient::connectionProperties(DocumentLo
     return nullptr;
 }
 
+#if USE(QUICK_LOOK)
+void WebFrameLoaderClient::didCreateQuickLookHandle(WebCore::QuickLookHandle& handle)
+{
+    if (!m_frame->isMainFrame())
+        return;
+
+    WebPage* webPage = m_frame->page();
+    if (!webPage)
+        return;
+
+    handle.setClient(WebQuickLookHandleClient::create(handle, webPage->pageID()));
+}
+#endif
+
 } // namespace WebKit
 
 #endif // PLATFORM(IOS)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.cpp
new file mode 100644 (file)
index 0000000..016df4c
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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 "WebQuickLookHandleClient.h"
+
+#if USE(QUICK_LOOK)
+
+#include "WebPageProxyMessages.h"
+#include "WebProcess.h"
+#include <WebCore/QuickLook.h>
+
+namespace WebKit {
+
+WebQuickLookHandleClient::WebQuickLookHandleClient(const WebCore::QuickLookHandle& handle, uint64_t pageID)
+    : m_fileName(handle.previewFileName())
+    , m_uti(handle.previewUTI())
+    , m_pageID(pageID)
+{
+    WebProcess::shared().send(Messages::WebPageProxy::DidStartLoadForQuickLookDocumentInMainFrame(m_fileName, m_uti), m_pageID);
+}
+
+void WebQuickLookHandleClient::didReceiveDataArray(CFArrayRef dataArray)
+{
+    CFArrayApplyFunction(dataArray, CFRangeMake(0, CFArrayGetCount(dataArray)), [](const void* value, void* context) {
+        ASSERT(CFGetTypeID(value) == CFDataGetTypeID());
+        static_cast<QuickLookDocumentData*>(context)->append((CFDataRef)value);
+    }, this);
+}
+
+void WebQuickLookHandleClient::didFinishLoading()
+{
+    WebProcess::shared().send(Messages::WebPageProxy::DidFinishLoadForQuickLookDocumentInMainFrame(m_data), m_pageID);
+    m_data.clear();
+}
+
+void WebQuickLookHandleClient::didFail()
+{
+    m_data.clear();
+}
+
+} // namespace WebKit
+
+#endif // USE(QUICK_LOOK)
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebQuickLookHandleClient.h
new file mode 100644 (file)
index 0000000..7d448ff
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+#ifndef WebQuickLookHandleClient_h
+#define WebQuickLookHandleClient_h
+
+#if USE(QUICK_LOOK)
+
+#include "QuickLookDocumentData.h"
+#include <WebCore/QuickLookHandleClient.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+class QuickLookHandle;
+}
+
+namespace WebKit {
+
+class WebFrame;
+
+class WebQuickLookHandleClient final : public WebCore::QuickLookHandleClient {
+public:
+    static PassRefPtr<WebQuickLookHandleClient> create(const WebCore::QuickLookHandle& handle, uint64_t pageID)
+    {
+        return adoptRef(new WebQuickLookHandleClient(handle, pageID));
+    }
+
+private:
+    WebQuickLookHandleClient(const WebCore::QuickLookHandle&, uint64_t pageID);
+    virtual void didReceiveDataArray(CFArrayRef) override;
+    virtual void didFinishLoading() override;
+    virtual void didFail() override;
+
+    const String m_fileName;
+    const String m_uti;
+    const uint64_t m_pageID;
+    QuickLookDocumentData m_data;
+};
+
+} // namespace WebKit
+
+#endif // USE(QUICK_LOOK)
+
+#endif // WebQuickLookHandleClient_h