<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[211355] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/211355">211355</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2017-01-29 17:40:29 -0800 (Sun, 29 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[QuickLook] Add a WebPreference to enable saving QuickLook documents in WebKitLegacy
https://bugs.webkit.org/show_bug.cgi?id=167563
&lt;rdar://problem/30253207&gt;

Reviewed by Andreas Kling.

Source/WebCore:

* loader/ios/QuickLook.h: Removed unused declarations.
(WebCore::QuickLookHandle::firstRequestURL): Deleted.
* loader/ios/QuickLook.mm:
(WebCore::removeQLPreviewConverterForURL): Stopped deleting the temporary file here; that's
now done in QuickLookDocumentWriter.
(addQLPreviewConverterWithFileForURL): Changed from an exported function to a static
function since it's now only called inside QuickLook.mm.
(WebCore::QuickLookHandle::QuickLookHandle): Stopped initializing m_firstRequestURL.
(WebCore::addQLPreviewConverterWithFileForURL): Deleted.
(WebCore::qlPreviewConverterFileNameForURL): Deleted.
(WebCore::qlPreviewConverterUTIForURL): Deleted.
(WebCore::QuickLookHandle::previewRequestURL): Deleted.
(WebCore::QuickLookHandle::converter): Deleted.

Source/WebKit/mac:

Instead of only saving QuickLook documents to a temporary file when the client is
MobileSafari, base this decision on a WebPreference that clients can choose to enable.

This also changes the SPI for accessing the temporary file path and UTI. Instead of
-[WebView quickLookContentForURL:], which requires the client to pass the response URL of
the frame that saved the QuickLook document, the content dictionary is now stored as a
property of WebDataSource.

This also removes the manual lifetime management of the QLPreviewConverter from
QuickLookDocumentWriter. The QLPreviewConverter is kept alive by DocumentLoader these days,
which ensures it lives long enough to respond to subresource requests.

New API test: QuickLook.LegacyQuickLookContent

* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::didCreateQuickLookHandle): Moved the logic of deciding whether to
write a temporary file to here from the QuickLookDocumentWriter constructor.
* WebView/WebDataSource.mm: Declared _quickLookContent.
(-[WebDataSource _quickLookContent]):
(-[WebDataSource _setQuickLookContent:]):
* WebView/WebDataSourceInternal.h: Overrode _quickLookContent as a read/write property.
* WebView/WebDataSourcePrivate.h: Declared _quickLookContent as a readonly property.
* WebView/WebPreferenceKeysPrivate.h: Defined WebKitQuickLookDocumentSavingPreferenceKey.
* WebView/WebPreferences.mm:
(-[WebPreferences quickLookDocumentSavingEnabled]):
(-[WebPreferences setQuickLookDocumentSavingEnabled:]):
* WebView/WebPreferencesPrivate.h: Declared property quickLookDocumentSavingEnabled.
* WebView/WebView.mm:
(-[WebView quickLookContentForURL:]): Changed to always return nil.
* WebView/WebViewPrivate.h: Added a comment stating that clients should use
-[WebDataSource _quickLookContent] instead.

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm:
(-[QuickLookNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]):
(-[QuickLookNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]):
(runTest):
(-[QuickLookFrameLoadDelegate webView:didFinishLoadForFrame:]):
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderiosQuickLookh">trunk/Source/WebCore/loader/ios/QuickLook.h</a></li>
<li><a href="#trunkSourceWebCoreloaderiosQuickLookmm">trunk/Source/WebCore/loader/ios/QuickLook.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm">trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebDataSourcemm">trunk/Source/WebKit/mac/WebView/WebDataSource.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebDataSourceInternalh">trunk/Source/WebKit/mac/WebView/WebDataSourceInternal.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebDataSourcePrivateh">trunk/Source/WebKit/mac/WebView/WebDataSourcePrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesmm">trunk/Source/WebKit/mac/WebView/WebPreferences.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebPreferencesPrivateh">trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewPrivateh">trunk/Source/WebKit/mac/WebView/WebViewPrivate.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaQuickLookmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebCore/ChangeLog        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-01-29  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [QuickLook] Add a WebPreference to enable saving QuickLook documents in WebKitLegacy
+        https://bugs.webkit.org/show_bug.cgi?id=167563
+        &lt;rdar://problem/30253207&gt;
+
+        Reviewed by Andreas Kling.
+
+        * loader/ios/QuickLook.h: Removed unused declarations.
+        (WebCore::QuickLookHandle::firstRequestURL): Deleted.
+        * loader/ios/QuickLook.mm:
+        (WebCore::removeQLPreviewConverterForURL): Stopped deleting the temporary file here; that's
+        now done in QuickLookDocumentWriter.
+        (addQLPreviewConverterWithFileForURL): Changed from an exported function to a static
+        function since it's now only called inside QuickLook.mm.
+        (WebCore::QuickLookHandle::QuickLookHandle): Stopped initializing m_firstRequestURL.
+        (WebCore::addQLPreviewConverterWithFileForURL): Deleted.
+        (WebCore::qlPreviewConverterFileNameForURL): Deleted.
+        (WebCore::qlPreviewConverterUTIForURL): Deleted.
+        (WebCore::QuickLookHandle::previewRequestURL): Deleted.
+        (WebCore::QuickLookHandle::converter): Deleted.
+
</ins><span class="cx"> 2017-01-29  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Simple line layout: PerformanceTests/Layout/simple-line-layout-innertext.html regressed at r211108
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderiosQuickLookh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ios/QuickLook.h (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ios/QuickLook.h        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebCore/loader/ios/QuickLook.h        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -31,15 +31,11 @@
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><del>-OBJC_CLASS NSArray;
</del><span class="cx"> OBJC_CLASS NSData;
</span><del>-OBJC_CLASS NSDictionary;
</del><span class="cx"> OBJC_CLASS NSSet;
</span><span class="cx"> OBJC_CLASS NSString;
</span><span class="cx"> OBJC_CLASS NSURL;
</span><span class="cx"> OBJC_CLASS NSURLRequest;
</span><del>-OBJC_CLASS NSURLResponse;
-OBJC_CLASS QLPreviewConverter;
</del><span class="cx"> OBJC_CLASS WebPreviewConverter;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -49,19 +45,11 @@
</span><span class="cx"> class ResourceRequest;
</span><span class="cx"> class ResourceResponse;
</span><span class="cx"> class SharedBuffer;
</span><del>-class URL;
</del><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT NSSet *QLPreviewGetSupportedMIMETypesSet();
</span><del>-
-WEBCORE_EXPORT void addQLPreviewConverterWithFileForURL(NSURL *, id converter, NSString *fileName);
-WEBCORE_EXPORT NSString *qlPreviewConverterFileNameForURL(NSURL *);
-WEBCORE_EXPORT NSString *qlPreviewConverterUTIForURL(NSURL *);
</del><span class="cx"> WEBCORE_EXPORT void removeQLPreviewConverterForURL(NSURL *);
</span><del>-
</del><span class="cx"> WEBCORE_EXPORT RetainPtr&lt;NSURLRequest&gt; registerQLPreviewConverterIfNeeded(NSURL *, NSString *mimeType, NSData *);
</span><del>-
</del><span class="cx"> WEBCORE_EXPORT const char* QLPreviewProtocol();
</span><del>-
</del><span class="cx"> WEBCORE_EXPORT NSString *createTemporaryFileForQuickLook(NSString *fileName);
</span><span class="cx"> 
</span><span class="cx"> class QuickLookHandle {
</span><span class="lines">@@ -82,15 +70,11 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT String previewFileName() const;
</span><span class="cx">     WEBCORE_EXPORT String previewUTI() const;
</span><del>-    WEBCORE_EXPORT NSURL *previewRequestURL() const;
-    WEBCORE_EXPORT QLPreviewConverter *converter() const;
-    NSURL *firstRequestURL() const { return m_firstRequestURL.get(); }
</del><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     friend std::unique_ptr&lt;QuickLookHandle&gt; std::make_unique&lt;QuickLookHandle&gt;(ResourceLoader&amp;, const ResourceResponse&amp;);
</span><span class="cx">     QuickLookHandle(ResourceLoader&amp;, const ResourceResponse&amp;);
</span><span class="cx"> 
</span><del>-    RetainPtr&lt;NSURL&gt; m_firstRequestURL;
</del><span class="cx">     RetainPtr&lt;WebPreviewConverter&gt; m_converter;
</span><span class="cx">     bool m_finishedLoadingDataIntoConverter { false };
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderiosQuickLookmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ios/QuickLook.mm (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ios/QuickLook.mm        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebCore/loader/ios/QuickLook.mm        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -68,8 +68,15 @@
</span><span class="cx">     return contentDictionary;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebCore::addQLPreviewConverterWithFileForURL(NSURL *url, id converter, NSString *fileName)
</del><ins>+void WebCore::removeQLPreviewConverterForURL(NSURL *url)
</ins><span class="cx"> {
</span><ins>+    LockHolder lock(qlPreviewConverterDictionaryMutex());
+    [QLPreviewConverterDictionary() removeObjectForKey:url];
+    [QLContentDictionary() removeObjectForKey:url];
+}
+
+static void addQLPreviewConverterWithFileForURL(NSURL *url, id converter, NSString *fileName)
+{
</ins><span class="cx">     ASSERT(url);
</span><span class="cx">     ASSERT(converter);
</span><span class="cx">     LockHolder lock(qlPreviewConverterDictionaryMutex());
</span><span class="lines">@@ -77,35 +84,6 @@
</span><span class="cx">     [QLContentDictionary() setObject:(fileName ? fileName : @&quot;&quot;) forKey:url];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSString *WebCore::qlPreviewConverterFileNameForURL(NSURL *url)
-{
-    return [QLContentDictionary() objectForKey:url];
-}
-
-NSString *WebCore::qlPreviewConverterUTIForURL(NSURL *url)
-{
-    id converter = nil;
-    {
-        LockHolder lock(qlPreviewConverterDictionaryMutex());
-        converter = [QLPreviewConverterDictionary() objectForKey:url];
-    }
-    if (!converter)
-        return nil;
-    return [converter previewUTI];
-}
-
-void WebCore::removeQLPreviewConverterForURL(NSURL *url)
-{
-    LockHolder lock(qlPreviewConverterDictionaryMutex());
-    [QLPreviewConverterDictionary() removeObjectForKey:url];
-
-    // Delete the file when we remove the preview converter
-    NSString *filename = qlPreviewConverterFileNameForURL(url);
-    if ([filename length])
-        [[NSFileManager defaultManager] _web_removeFileOnlyAtPath:filename];
-    [QLContentDictionary() removeObjectForKey:url];
-}
-
</del><span class="cx"> RetainPtr&lt;NSURLRequest&gt; WebCore::registerQLPreviewConverterIfNeeded(NSURL *url, NSString *mimeType, NSData *data)
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;NSString&gt; updatedMIMEType = adoptNS(QLTypeCopyBestMimeTypeForURLAndMimeType(url, mimeType));
</span><span class="lines">@@ -340,8 +318,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> QuickLookHandle::QuickLookHandle(ResourceLoader&amp; loader, const ResourceResponse&amp; response)
</span><del>-    : m_firstRequestURL { loader.originalRequest().nsURLRequest(DoNotUpdateHTTPBody).URL }
-    , m_converter { adoptNS([[WebPreviewConverter alloc] initWithResourceLoader:loader resourceResponse:response quickLookHandle:*this]) }
</del><ins>+    : m_converter { adoptNS([[WebPreviewConverter alloc] initWithResourceLoader:loader resourceResponse:response quickLookHandle:*this]) }
</ins><span class="cx"> {
</span><span class="cx">     loader.didCreateQuickLookHandle(*this);
</span><span class="cx"> }
</span><span class="lines">@@ -421,16 +398,6 @@
</span><span class="cx">     return [m_converter platformConverter].previewUTI;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSURL *QuickLookHandle::previewRequestURL() const
-{
-    return [m_converter platformConverter].previewRequest.URL;
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-QLPreviewConverter *QuickLookHandle::converter() const
-{
-    return [m_converter platformConverter];
-}
-
-}
-
</del><span class="cx"> #endif // USE(QUICK_LOOK)
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/ChangeLog        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2017-01-29  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [QuickLook] Add a WebPreference to enable saving QuickLook documents in WebKitLegacy
+        https://bugs.webkit.org/show_bug.cgi?id=167563
+        &lt;rdar://problem/30253207&gt;
+
+        Reviewed by Andreas Kling.
+
+        Instead of only saving QuickLook documents to a temporary file when the client is
+        MobileSafari, base this decision on a WebPreference that clients can choose to enable.
+
+        This also changes the SPI for accessing the temporary file path and UTI. Instead of
+        -[WebView quickLookContentForURL:], which requires the client to pass the response URL of
+        the frame that saved the QuickLook document, the content dictionary is now stored as a
+        property of WebDataSource.
+
+        This also removes the manual lifetime management of the QLPreviewConverter from
+        QuickLookDocumentWriter. The QLPreviewConverter is kept alive by DocumentLoader these days,
+        which ensures it lives long enough to respond to subresource requests.
+
+        New API test: QuickLook.LegacyQuickLookContent
+
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::didCreateQuickLookHandle): Moved the logic of deciding whether to
+        write a temporary file to here from the QuickLookDocumentWriter constructor.
+        * WebView/WebDataSource.mm: Declared _quickLookContent.
+        (-[WebDataSource _quickLookContent]):
+        (-[WebDataSource _setQuickLookContent:]):
+        * WebView/WebDataSourceInternal.h: Overrode _quickLookContent as a read/write property.
+        * WebView/WebDataSourcePrivate.h: Declared _quickLookContent as a readonly property.
+        * WebView/WebPreferenceKeysPrivate.h: Defined WebKitQuickLookDocumentSavingPreferenceKey.
+        * WebView/WebPreferences.mm:
+        (-[WebPreferences quickLookDocumentSavingEnabled]):
+        (-[WebPreferences setQuickLookDocumentSavingEnabled:]):
+        * WebView/WebPreferencesPrivate.h: Declared property quickLookDocumentSavingEnabled.
+        * WebView/WebView.mm:
+        (-[WebView quickLookContentForURL:]): Changed to always return nil.
+        * WebView/WebViewPrivate.h: Added a comment stating that clients should use
+        -[WebDataSource _quickLookContent] instead.
+
</ins><span class="cx"> 2017-01-28  Yoav Weiss  &lt;yoav@yoav.ws&gt;
</span><span class="cx"> 
</span><span class="cx">         Add Link Preload as an off-by-default experimental feature menu item.
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebFrameLoaderClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -149,7 +149,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if USE(QUICK_LOOK)
</span><del>-#import &lt;WebCore/FileSystemIOS.h&gt;
</del><span class="cx"> #import &lt;WebCore/NSFileManagerSPI.h&gt;
</span><span class="cx"> #import &lt;WebCore/QuickLook.h&gt;
</span><span class="cx"> #import &lt;WebCore/QuickLookHandleClient.h&gt;
</span><span class="lines">@@ -2230,43 +2229,26 @@
</span><span class="cx"> {
</span><span class="cx">     class QuickLookDocumentWriter : public WebCore::QuickLookHandleClient {
</span><span class="cx">     public:
</span><del>-        explicit QuickLookDocumentWriter(const WebCore::QuickLookHandle&amp; handle)
-            : m_firstRequestURL(handle.firstRequestURL())
</del><ins>+        explicit QuickLookDocumentWriter(NSString *filePath)
+            : m_filePath { filePath }
+            , m_fileHandle { [NSFileHandle fileHandleForWritingAtPath:filePath] }
</ins><span class="cx">         {
</span><del>-            NSURL *previewRequestURL = handle.previewRequestURL();
-            if (!IOSApplication::isMobileSafari()) {
-                // This keeps the QLPreviewConverter alive to serve any subresource requests.
-                // It is removed by -[WebDataSource dealloc].
-                addQLPreviewConverterWithFileForURL(previewRequestURL, handle.converter(), nil);
-                return;
-            }
-
-            // QuickLook consumes the incoming data, we need to store it so that it can be opened in the handling application.
-            NSString *quicklookContentPath = createTemporaryFileForQuickLook(handle.previewFileName());
-
-            if (quicklookContentPath) {
-                m_fileHandle = [NSFileHandle fileHandleForWritingAtPath:quicklookContentPath];
-                // previewRequestURL should match the URL removed from -[WebDataSource dealloc].
-                addQLPreviewConverterWithFileForURL(previewRequestURL, handle.converter(), quicklookContentPath);
-            }
</del><ins>+            ASSERT(filePath.length);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        virtual ~QuickLookDocumentWriter()
</del><ins>+        ~QuickLookDocumentWriter()
</ins><span class="cx">         {
</span><del>-            if (m_fileHandle)
-                removeQLPreviewConverterForURL(m_firstRequestURL.get());
</del><ins>+            [[NSFileManager defaultManager] _web_removeFileOnlyAtPath:m_filePath.get()];
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">     private:
</span><ins>+        RetainPtr&lt;NSString&gt; m_filePath;
</ins><span class="cx">         RetainPtr&lt;NSFileHandle&gt; m_fileHandle;
</span><del>-        RetainPtr&lt;NSURL&gt; m_firstRequestURL;
</del><span class="cx"> 
</span><span class="cx">         void didReceiveDataArray(CFArrayRef dataArray) override
</span><span class="cx">         {
</span><del>-            if (m_fileHandle) {
-                for (NSData *data in (NSArray *)dataArray)
-                    [m_fileHandle writeData:data];
-            }
</del><ins>+            for (NSData *data in (NSArray *)dataArray)
+                [m_fileHandle writeData:data];
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         void didFinishLoading() override
</span><span class="lines">@@ -2276,12 +2258,19 @@
</span><span class="cx"> 
</span><span class="cx">         void didFail() override
</span><span class="cx">         {
</span><del>-            m_fileHandle = nil;
-            // removeQLPreviewConverterForURL deletes the temporary file created.
-            removeQLPreviewConverterForURL(m_firstRequestURL.get());
</del><ins>+            [m_fileHandle closeFile];
</ins><span class="cx">         }
</span><span class="cx">     };
</span><del>-    handle.setClient(adoptRef(*new QuickLookDocumentWriter(handle)));
</del><ins>+
+    if (![m_webFrame webView].preferences.quickLookDocumentSavingEnabled)
+        return;
+
+    NSString *filePath = createTemporaryFileForQuickLook(handle.previewFileName());
+    if (!filePath)
+        return;
+
+    [m_webFrame provisionalDataSource]._quickLookContent = @{ WebQuickLookFileNameKey : filePath, WebQuickLookUTIKey : handle.previewUTI() };
+    handle.setClient(adoptRef(*new QuickLookDocumentWriter(filePath)));
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebDataSourcemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebDataSource.mm (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebDataSource.mm        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebDataSource.mm        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -109,6 +109,9 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     NSObject&lt;WebDataSourcePrivateDelegate&gt; *_dataSourceDelegate;
</span><span class="cx"> #endif
</span><ins>+#if USE(QUICK_LOOK)
+    RetainPtr&lt;NSDictionary&gt; _quickLookContent;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> static inline WebDataSourcePrivate* toPrivate(void* privateAttribute)
</span><span class="lines">@@ -225,6 +228,17 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+- (NSDictionary *)_quickLookContent
+{
+#if USE(QUICK_LOOK)
+    return toPrivate(_private)-&gt;_quickLookContent.get();
+#else
+    return nil;
+#endif
+}
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WebDataSource (WebInternal)
</span><span class="lines">@@ -410,6 +424,13 @@
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(QUICK_LOOK)
+- (void)_setQuickLookContent:(NSDictionary *)quickLookContent
+{
+    toPrivate(_private)-&gt;_quickLookContent = adoptNS([quickLookContent copy]);
+}
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WebDataSource
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebDataSourceInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebDataSourceInternal.h (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebDataSourceInternal.h        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebDataSourceInternal.h        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -57,4 +57,7 @@
</span><span class="cx"> - (void)_revertToProvisionalState;
</span><span class="cx"> - (void)_setMainDocumentError:(NSError *)error;
</span><span class="cx"> - (WebCore::DocumentLoader*)_documentLoader;
</span><ins>+#if USE(QUICK_LOOK)
+@property (nonatomic, copy, setter=_setQuickLookContent:) NSDictionary *_quickLookContent;
+#endif
</ins><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebDataSourcePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebDataSourcePrivate.h (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebDataSourcePrivate.h        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebDataSourcePrivate.h        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -52,4 +52,8 @@
</span><span class="cx"> - (void)setDataSourceDelegate:(NSObject&lt;WebDataSourcePrivateDelegate&gt; *)dataSourceDelegate;
</span><span class="cx"> - (NSObject&lt;WebDataSourcePrivateDelegate&gt; *)dataSourceDelegate;
</span><span class="cx"> 
</span><ins>+#if TARGET_OS_IPHONE
+@property (nonatomic, readonly) NSDictionary *_quickLookContent;
+#endif
+
</ins><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferenceKeysPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005-2016 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -215,6 +215,7 @@
</span><span class="cx"> #define WebKitPasswordEchoDurationPreferenceKey @&quot;WebKitPasswordEchoDurationPreferenceKey&quot;
</span><span class="cx"> #define WebKitNetworkDataUsageTrackingEnabledPreferenceKey @&quot;WebKitNetworkDataUsageTrackingEnabledPreferenceKey&quot;
</span><span class="cx"> #define WebKitNetworkInterfaceNamePreferenceKey @&quot;WebKitNetworkInterfaceNamePreferenceKey&quot;
</span><ins>+#define WebKitQuickLookDocumentSavingPreferenceKey @&quot;WebKitQuickLookDocumentSavingPreferenceKey&quot;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #define WebKitEnableInheritURIQueryComponentPreferenceKey @&quot;WebKitEnableInheritURIQueryComponent&quot;
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *           (C) 2006 Graham Dennis (graham.dennis@gmail.com)
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -2945,6 +2945,18 @@
</span><span class="cx">     [self _setBoolValue:flag forKey:WebKitUserTimingEnabledPreferenceKey];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+- (BOOL)quickLookDocumentSavingEnabled
+{
+    return [self _boolValueForKey:WebKitQuickLookDocumentSavingPreferenceKey];
+}
+
+- (void)setQuickLookDocumentSavingEnabled:(BOOL)flag
+{
+    [self _setBoolValue:flag forKey:WebKitQuickLookDocumentSavingPreferenceKey];
+}
+#endif
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WebPreferences (WebInternal)
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebPreferencesPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005-2016 Apple Inc.  All rights reserved.
</del><ins>+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -531,4 +531,8 @@
</span><span class="cx"> @property (nonatomic) BOOL userTimingEnabled;
</span><span class="cx"> @property (nonatomic) BOOL linkPreloadEnabled;
</span><span class="cx"> 
</span><ins>+#if TARGET_OS_IPHONE
+@property (nonatomic) BOOL quickLookDocumentSavingEnabled;
+#endif
+
</ins><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2005-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2006 David Smith (catfish.man@gmail.com)
</span><span class="cx">  * Copyright (C) 2010 Igalia S.L
</span><span class="cx">  *
</span><span class="lines">@@ -4030,19 +4030,7 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> - (NSDictionary *)quickLookContentForURL:(NSURL *)url
</span><span class="cx"> {
</span><del>-#if USE(QUICK_LOOK)
-    NSString *uti = qlPreviewConverterUTIForURL(url);
-    if (!uti)
-        return nil;
-
-    NSString *fileName = qlPreviewConverterFileNameForURL(url);
-    if (!fileName)
-        return nil;
-
-    return [NSDictionary dictionaryWithObjectsAndKeys: fileName, WebQuickLookFileNameKey, uti, WebQuickLookUTIKey, nil];
-#else
</del><span class="cx">     return nil;
</span><del>-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_isStopping
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -462,6 +462,7 @@
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><ins>+// Deprecated. Use -[WebDataSource _quickLookContent] instead.
</ins><span class="cx"> - (NSDictionary *)quickLookContentForURL:(NSURL *)url;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Tools/ChangeLog        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2017-01-29  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [QuickLook] Add a WebPreference to enable saving QuickLook documents in WebKitLegacy
+        https://bugs.webkit.org/show_bug.cgi?id=167563
+        &lt;rdar://problem/30253207&gt;
+
+        Reviewed by Andreas Kling.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm:
+        (-[QuickLookNavigationDelegate _webView:didStartLoadForQuickLookDocumentInMainFrameWithFileName:uti:]):
+        (-[QuickLookNavigationDelegate _webView:didFinishLoadForQuickLookDocumentInMainFrame:]):
+        (runTest):
+        (-[QuickLookFrameLoadDelegate webView:didFinishLoadForFrame:]):
+        (TEST):
+
</ins><span class="cx"> 2017-01-29  Dan Bernstein  &lt;mitz@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Expose WebCore::DataDetection::detectContentInRange WKWebProcessPlugInRangeHandle
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaQuickLookmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm (211354 => 211355)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm        2017-01-30 00:26:36 UTC (rev 211354)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/QuickLook.mm        2017-01-30 01:40:29 UTC (rev 211355)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -28,14 +28,27 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PlatformUtilities.h&quot;
</span><ins>+#import &quot;Test.h&quot;
+#import &lt;WebCore/WebCoreThread.h&gt;
</ins><span class="cx"> #import &lt;WebKit/WKNavigationDelegatePrivate.h&gt;
</span><del>-#import &lt;WebKit/WKWebView.h&gt;
</del><ins>+#import &lt;WebKit/WebDataSourcePrivate.h&gt;
+#import &lt;WebKit/WebKit.h&gt;
+#import &lt;WebKit/WebPreferencesPrivate.h&gt;
+#import &lt;WebKit/WebUIKitSupport.h&gt;
+#import &lt;WebKit/WebViewPrivate.h&gt;
</ins><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="cx"> 
</span><ins>+using namespace TestWebKitAPI;
+
</ins><span class="cx"> static bool isDone;
</span><span class="cx"> static bool didStartQuickLookLoad;
</span><span class="cx"> static bool didFinishQuickLookLoad;
</span><span class="cx"> 
</span><ins>+static const NSUInteger expectedFileSize = 274143;
+static NSString * const expectedFileName = @&quot;pages.pages&quot;;
+static NSString * const expectedUTI = @&quot;com.apple.iwork.pages.sffpages&quot;;
+static NSURLRequest * const pagesDocumentRequest = [[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;pages&quot; withExtension:@&quot;pages&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]] retain];
+
</ins><span class="cx"> @interface QuickLookNavigationDelegate : NSObject &lt;WKNavigationDelegatePrivate&gt;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="lines">@@ -43,14 +56,14 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)_webView:(WKWebView *)webView didStartLoadForQuickLookDocumentInMainFrameWithFileName:(NSString *)fileName uti:(NSString *)uti
</span><span class="cx"> {
</span><del>-    EXPECT_WK_STREQ(fileName, @&quot;pages.pages&quot;);
-    EXPECT_WK_STREQ(uti, @&quot;com.apple.iwork.pages.sffpages&quot;);
</del><ins>+    EXPECT_WK_STREQ(expectedFileName, fileName);
+    EXPECT_WK_STREQ(expectedUTI, uti);
</ins><span class="cx">     didStartQuickLookLoad = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_webView:(WKWebView *)webView didFinishLoadForQuickLookDocumentInMainFrame:(NSData *)documentData
</span><span class="cx"> {
</span><del>-    EXPECT_EQ(documentData.length, 274143U);
</del><ins>+    EXPECT_EQ(expectedFileSize, documentData.length);
</ins><span class="cx">     didFinishQuickLookLoad = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -66,10 +79,10 @@
</span><span class="cx">     auto webView = adoptNS([[WKWebView alloc] init]);
</span><span class="cx">     auto navigationDelegate = adoptNS([[navigationDelegateClass alloc] init]);
</span><span class="cx">     [webView setNavigationDelegate:navigationDelegate.get()];
</span><del>-    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@&quot;pages&quot; withExtension:@&quot;pages&quot; subdirectory:@&quot;TestWebKitAPI.resources&quot;]]];
</del><ins>+    [webView loadRequest:pagesDocumentRequest];
</ins><span class="cx"> 
</span><span class="cx">     isDone = false;
</span><del>-    TestWebKitAPI::Util::run(&amp;isDone);
</del><ins>+    Util::run(&amp;isDone);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TEST(QuickLook, NavigationDelegate)
</span><span class="lines">@@ -96,9 +109,59 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+@interface QuickLookFrameLoadDelegate : NSObject &lt;WebFrameLoadDelegate&gt;
+@end
+
+@implementation QuickLookFrameLoadDelegate
+
+- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
+{
+    isDone = true;
+}
+
+@end
+
</ins><span class="cx"> TEST(QuickLook, CancelNavigationAfterResponse)
</span><span class="cx"> {
</span><span class="cx">     runTest([QuickLookDecidePolicyDelegate class]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+TEST(QuickLook, LegacyQuickLookContent)
+{
+    WebKitInitialize();
+    WebThreadLock();
+
+    auto webView = adoptNS([[WebView alloc] init]);
+
+    auto frameLoadDelegate = adoptNS([[QuickLookFrameLoadDelegate alloc] init]);
+    [webView setFrameLoadDelegate:frameLoadDelegate.get()];
+
+    auto webPreferences = adoptNS([[WebPreferences alloc] initWithIdentifier:@&quot;LegacyQuickLookContent&quot;]);
+    [webPreferences setQuickLookDocumentSavingEnabled:YES];
+    [webView setPreferences:webPreferences.get()];
+
+    WebFrame *mainFrame = [webView mainFrame];
+
+    isDone = false;
+    [mainFrame loadRequest:pagesDocumentRequest];
+    Util::run(&amp;isDone);
+    WebThreadLock();
+
+    NSDictionary *quickLookContent = mainFrame.dataSource._quickLookContent;
+    NSString *filePath = quickLookContent[WebQuickLookFileNameKey];
+    EXPECT_TRUE([[NSFileManager defaultManager] fileExistsAtPath:filePath]);
+    EXPECT_WK_STREQ(expectedFileName, filePath.lastPathComponent);
+    EXPECT_WK_STREQ(expectedUTI, quickLookContent[WebQuickLookUTIKey]);
+
+    NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil];
+    EXPECT_EQ(expectedFileSize, [fileAttributes[NSFileSize] unsignedIntegerValue]);
+
+    isDone = false;
+    [mainFrame loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@&quot;about:blank&quot;]]];
+    Util::run(&amp;isDone);
+    WebThreadLock();
+
+    EXPECT_NULL(mainFrame.dataSource._quickLookContent);
+}
+
</ins><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre>
</div>
</div>

</body>
</html>