<!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>[165908] trunk/Source</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/165908">165908</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-03-19 12:24:30 -0700 (Wed, 19 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] WebKit2 Quicklook.
https://bugs.webkit.org/show_bug.cgi?id=130360

Source/WebCore:

Patch by Yongjun Zhang &lt;yongjun_zhang@apple.com&gt; on 2014-03-19
Reviewed by Tim Horton.

Since ResourceLoaders using WebKit2 network process don't have ResourceHandle any more, we
need to make it possible to create QuickLookHandle from ResourceLoader.

* WebCore.exp.in: Make some QuickLookHandle methods visible from WebKit2.
* loader/ResourceLoader.h: Add m_quickLookHandle data member to ResourceLoader.
(WebCore::ResourceLoader::quickLookHandle):
(WebCore::ResourceLoader::setQuickLookHandle):
* platform/network/ios/QuickLook.h: Add a new method to create QuickLookHandle from ResourceLoader.
* platform/network/ios/QuickLook.mm:
(WebCore::QuickLookHandle::create):

Source/WebKit2:

For WebKit2 resource loads, if we detect a quicklook content that QLConverter is able to
convert, handle the response data to QLConverter and use its delegate WKWebResourceQuickLookDelegate
to rounte the converted results (HTML) back into WebCore.  Thie similiar logic has been in place
for WebKit1.

Patch by Yongjun Zhang &lt;yongjun_zhang@apple.com&gt; on 2014-03-19
Reviewed by Tim Horton.

* WebKit2.xcodeproj/project.pbxproj: Add WebResourceLoaderIOS.mm to the project.
* WebProcess/Network/WebResourceLoadScheduler.cpp:
* WebProcess/ios/WebResourceLoaderIOS.mm: Added.
(-[WKWebResourceQuickLookDelegate initWithWebResourceLoader:WebKit::]): WKWebResourceQuickLookDelegate holds
    the original WebResourceLoader so that we could send converted result to WebCore.
(-[WKWebResourceQuickLookDelegate connection:didReceiveDataArray:]):
(-[WKWebResourceQuickLookDelegate connection:didReceiveData:lengthReceived:]):
(-[WKWebResourceQuickLookDelegate connectionDidFinishLoading:]):
(-[WKWebResourceQuickLookDelegate connection:didFailWithError:]):
(-[WKWebResourceQuickLookDelegate clearHandle]):
(WebKit::WebResourceLoader::setUpQuickLookHandleIfNeeded):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoaderh">trunk/Source/WebCore/loader/ResourceLoader.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkiosQuickLookh">trunk/Source/WebCore/platform/network/ios/QuickLook.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkiosQuickLookmm">trunk/Source/WebCore/platform/network/ios/QuickLook.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoadercpp">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessNetworkWebResourceLoaderh">trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2WebProcessiosWebResourceLoaderIOSmm">trunk/Source/WebKit2/WebProcess/ios/WebResourceLoaderIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebCore/ChangeLog        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2014-03-19  Yongjun Zhang  &lt;yongjun_zhang@apple.com&gt;
+
+        [iOS] WebKit2 Quicklook.
+        https://bugs.webkit.org/show_bug.cgi?id=130360
+
+        Reviewed by Tim Horton.
+
+        Since ResourceLoaders using WebKit2 network process don't have ResourceHandle any more, we
+        need to make it possible to create QuickLookHandle from ResourceLoader.
+
+        * WebCore.exp.in: Make some QuickLookHandle methods visible from WebKit2.
+        * loader/ResourceLoader.h: Add m_quickLookHandle data member to ResourceLoader.
+        (WebCore::ResourceLoader::quickLookHandle):
+        (WebCore::ResourceLoader::setQuickLookHandle):
+        * platform/network/ios/QuickLook.h: Add a new method to create QuickLookHandle from ResourceLoader.
+        * platform/network/ios/QuickLook.mm:
+        (WebCore::QuickLookHandle::create):
+
</ins><span class="cx"> 2014-03-19  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix cue rendering test and include support for left/right alignment
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -2471,6 +2471,12 @@
</span><span class="cx"> __ZN7WebCore15GraphicsContext22setEmojiDrawingEnabledEb
</span><span class="cx"> __ZN7WebCore15GraphicsContext23setIsAcceleratedContextEb
</span><span class="cx"> __ZN7WebCore15GraphicsContextC1EP9CGContextb
</span><ins>+__ZN7WebCore15QuickLookHandle10nsResponseEv
+__ZN7WebCore15QuickLookHandle14didReceiveDataEPK8__CFData
+__ZN7WebCore15QuickLookHandle16didFinishLoadingEv
+__ZN7WebCore15QuickLookHandle6createEPNS_14ResourceLoaderEP13NSURLResponseP11objc_object
+__ZN7WebCore15QuickLookHandle7didFailEv
+__ZN7WebCore15QuickLookHandleD1Ev
</ins><span class="cx"> __ZN7WebCore15ResourceRequest39updateFromDelegatePreservingOldHTTPBodyERKS0_
</span><span class="cx"> __ZN7WebCore15StringTruncator12leftTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotERfbf
</span><span class="cx"> __ZN7WebCore15StringTruncator13rightTruncateERKN3WTF6StringEfRKNS_4FontENS0_24EnableRoundingHacksOrNotERfbf
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.h (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.h        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebCore/loader/ResourceLoader.h        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -38,6 +38,10 @@
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><span class="cx"> #include &lt;wtf/RefCounted.h&gt;
</span><span class="cx"> 
</span><ins>+#if USE(QUICK_LOOK)
+#include &quot;QuickLook.h&quot;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class AuthenticationChallenge;
</span><span class="lines">@@ -154,6 +158,11 @@
</span><span class="cx"> 
</span><span class="cx">     void setDataBufferingPolicy(DataBufferingPolicy);
</span><span class="cx"> 
</span><ins>+#if USE(QUICK_LOOK)
+    QuickLookHandle* quickLookHandle() const { return m_quickLookHandle.get(); }
+    void setQuickLookHandle(PassOwnPtr&lt;QuickLookHandle&gt; handle) { m_quickLookHandle = handle; }
+#endif
+
</ins><span class="cx"> protected:
</span><span class="cx">     ResourceLoader(Frame*, ResourceLoaderOptions);
</span><span class="cx"> 
</span><span class="lines">@@ -202,6 +211,9 @@
</span><span class="cx">     bool m_defersLoading;
</span><span class="cx">     ResourceRequest m_deferredRequest;
</span><span class="cx">     ResourceLoaderOptions m_options;
</span><ins>+#if USE(QUICK_LOOK)
+    OwnPtr&lt;QuickLookHandle&gt; m_quickLookHandle;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline const ResourceResponse&amp; ResourceLoader::response() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkiosQuickLookh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.h (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ios/QuickLook.h        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.h        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -60,6 +60,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class ResourceHandle;
</span><ins>+class ResourceLoader;
</ins><span class="cx"> class SynchronousResourceHandleCFURLConnectionDelegate;
</span><span class="cx"> 
</span><span class="cx"> Class QLPreviewConverterClass();
</span><span class="lines">@@ -91,6 +92,7 @@
</span><span class="cx"> #if USE(CFNETWORK)
</span><span class="cx">     static PassOwnPtr&lt;QuickLookHandle&gt; create(ResourceHandle*, SynchronousResourceHandleCFURLConnectionDelegate*, CFURLResponseRef);
</span><span class="cx"> #endif
</span><ins>+    static PassOwnPtr&lt;QuickLookHandle&gt; create(ResourceLoader*, NSURLResponse *, id delegate);
</ins><span class="cx">     ~QuickLookHandle();
</span><span class="cx"> 
</span><span class="cx">     bool didReceiveDataArray(CFArrayRef);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkiosQuickLookmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ios/QuickLook.mm (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ios/QuickLook.mm        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebCore/platform/network/ios/QuickLook.mm        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #import &quot;FileSystemIOS.h&quot;
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><span class="cx"> #import &quot;ResourceHandle.h&quot;
</span><ins>+#import &quot;ResourceLoader.h&quot;
</ins><span class="cx"> #import &quot;RuntimeApplicationChecksIOS.h&quot;
</span><span class="cx"> #import &quot;SoftLinking.h&quot;
</span><span class="cx"> #import &quot;SynchronousResourceHandleCFURLConnectionDelegate.h&quot;
</span><span class="lines">@@ -392,6 +393,14 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+PassOwnPtr&lt;QuickLookHandle&gt; QuickLookHandle::create(ResourceLoader* loader, NSURLResponse *response, id delegate)
+{
+    if (loader-&gt;request().isMainResourceRequest() &amp;&amp; [WebCore::QLPreviewGetSupportedMIMETypesSet() containsObject:[response MIMEType]])
+        return adoptPtr(new QuickLookHandle(NULL, nil, response, delegate));
+
+    return nullptr;
+}
+
</ins><span class="cx"> NSURLResponse *QuickLookHandle::nsResponse()
</span><span class="cx"> {
</span><span class="cx">     return m_nsResponse;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2014-03-19  Yongjun Zhang  &lt;yongjun_zhang@apple.com&gt;
+
+        [iOS] WebKit2 Quicklook.
+        https://bugs.webkit.org/show_bug.cgi?id=130360
+
+        For WebKit2 resource loads, if we detect a quicklook content that QLConverter is able to
+        convert, handle the response data to QLConverter and use its delegate WKWebResourceQuickLookDelegate
+        to rounte the converted results (HTML) back into WebCore.  Thie similiar logic has been in place
+        for WebKit1.
+
+        Reviewed by Tim Horton.
+
+        * WebKit2.xcodeproj/project.pbxproj: Add WebResourceLoaderIOS.mm to the project.
+        * WebProcess/Network/WebResourceLoadScheduler.cpp:
+        * WebProcess/ios/WebResourceLoaderIOS.mm: Added.
+        (-[WKWebResourceQuickLookDelegate initWithWebResourceLoader:WebKit::]): WKWebResourceQuickLookDelegate holds
+            the original WebResourceLoader so that we could send converted result to WebCore.
+        (-[WKWebResourceQuickLookDelegate connection:didReceiveDataArray:]):
+        (-[WKWebResourceQuickLookDelegate connection:didReceiveData:lengthReceived:]):
+        (-[WKWebResourceQuickLookDelegate connectionDidFinishLoading:]):
+        (-[WKWebResourceQuickLookDelegate connection:didFailWithError:]):
+        (-[WKWebResourceQuickLookDelegate clearHandle]):
+        (WebKit::WebResourceLoader::setUpQuickLookHandleIfNeeded):
+
</ins><span class="cx"> 2014-03-19  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         WebKit2 View Gestures: Swipe gesture can track vertical movement instead of horizontal movement
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -451,6 +451,7 @@
</span><span class="cx">                 1F7506B61859165700EC0FF7 /* WKWebProcessPlugInNodeHandleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F0181711858DC1600F92884 /* WKWebProcessPlugInNodeHandleInternal.h */; };
</span><span class="cx">                 1F7506B71859165A00EC0FF7 /* WKWebProcessPlugInHitTestResultInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F01816E1858DC1600F92884 /* WKWebProcessPlugInHitTestResultInternal.h */; };
</span><span class="cx">                 1F7506B81859165D00EC0FF7 /* WKWebProcessPlugInFrameInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F01816B1858DC1500F92884 /* WKWebProcessPlugInFrameInternal.h */; };
</span><ins>+                1F8724B718D7632B0076D4B4 /* WebResourceLoaderIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F8724B318D7631D0076D4B4 /* WebResourceLoaderIOS.mm */; };
</ins><span class="cx">                 1FB00AC7185F76460019142E /* WKWebProcessPlugInPageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FB00AC4185F76460019142E /* WKWebProcessPlugInPageGroup.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1FB00AC8185F76460019142E /* WKWebProcessPlugInPageGroup.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FB00AC5185F76460019142E /* WKWebProcessPlugInPageGroup.mm */; };
</span><span class="cx">                 1FB00AC9185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FB00AC6185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h */; };
</span><span class="lines">@@ -2210,6 +2211,7 @@
</span><span class="cx">                 1F335BBF185B84D8001A201A /* WKWebProcessPlugInLoadDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInLoadDelegate.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1F604BA61889FA7400EE0395 /* WKRenderingProgressEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRenderingProgressEvents.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1F604BA71889FA7400EE0395 /* WKRenderingProgressEventsInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKRenderingProgressEventsInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                1F8724B318D7631D0076D4B4 /* WebResourceLoaderIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebResourceLoaderIOS.mm; path = ios/WebResourceLoaderIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 1FB00AC4185F76460019142E /* WKWebProcessPlugInPageGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInPageGroup.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1FB00AC5185F76460019142E /* WKWebProcessPlugInPageGroup.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebProcessPlugInPageGroup.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1FB00AC6185F76460019142E /* WKWebProcessPlugInPageGroupInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInPageGroupInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -4290,6 +4292,14 @@
</span><span class="cx">                         path = Cocoa;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="cx">                 };
</span><ins>+                1F8724B218D763040076D4B4 /* ios */ = {
+                        isa = PBXGroup;
+                        children = (
+                                1F8724B318D7631D0076D4B4 /* WebResourceLoaderIOS.mm */,
+                        );
+                        name = ios;
+                        sourceTree = &quot;&lt;group&gt;&quot;;
+                };
</ins><span class="cx">                 2989A40E167D1813004F96D2 /* CustomProtocols */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="lines">@@ -4646,6 +4656,7 @@
</span><span class="cx">                 5105B0D2162F7A5E00E27709 /* Network */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                1F8724B218D763040076D4B4 /* ios */,
</ins><span class="cx">                                 5105B0D4162F7A7A00E27709 /* NetworkProcessConnection.cpp */,
</span><span class="cx">                                 5105B0D5162F7A7A00E27709 /* NetworkProcessConnection.h */,
</span><span class="cx">                                 51FB0902163A3B1C00EC324A /* NetworkProcessConnection.messages.in */,
</span><span class="lines">@@ -8410,6 +8421,7 @@
</span><span class="cx">                                 37948403150C350600E52CE9 /* WebRenderLayer.cpp in Sources */,
</span><span class="cx">                                 2D28F3E61885CCC1004B9EAE /* WebEditorClientIOS.mm in Sources */,
</span><span class="cx">                                 3760881E150413E900FC82C7 /* WebRenderObject.cpp in Sources */,
</span><ins>+                                1F8724B718D7632B0076D4B4 /* WebResourceLoaderIOS.mm in Sources */,
</ins><span class="cx">                                 51217464164C21370037A5C1 /* WebResourceBuffer.cpp in Sources */,
</span><span class="cx">                                 3336762F130C9998006C9DE2 /* WebResourceCacheManager.cpp in Sources */,
</span><span class="cx">                                 33F9D5B91312F1EE000D683F /* WebResourceCacheManagerCFNet.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -106,6 +106,13 @@
</span><span class="cx">     Ref&lt;WebResourceLoader&gt; protect(*this);
</span><span class="cx"> 
</span><span class="cx">     ResourceResponse responseCopy(response);
</span><ins>+
+#if USE(QUICK_LOOK)
+    setUpQuickLookHandleIfNeeded(response);
+    if (QuickLookHandle* quickLookHandle = m_coreLoader-&gt;quickLookHandle())
+        responseCopy = ResourceResponse(quickLookHandle-&gt;nsResponse());
+#endif
+
</ins><span class="cx">     // FIXME: This should use CertificateInfo to avoid the platform ifdefs. See https://bugs.webkit.org/show_bug.cgi?id=124724.
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     responseCopy.setCertificateChain(certificateInfo.certificateChain());
</span><span class="lines">@@ -126,12 +133,26 @@
</span><span class="cx"> void WebResourceLoader::didReceiveData(const IPC::DataReference&amp; data, int64_t encodedDataLength)
</span><span class="cx"> {
</span><span class="cx">     LOG(Network, &quot;(WebProcess) WebResourceLoader::didReceiveData of size %i for '%s'&quot;, (int)data.size(), m_coreLoader-&gt;url().string().utf8().data());
</span><ins>+
+#if USE(QUICK_LOOK)
+    if (QuickLookHandle* quickLookHandle = m_coreLoader-&gt;quickLookHandle()) {
+        RetainPtr&lt;CFDataRef&gt; rawData = adoptCF(CFDataCreateWithBytesNoCopy(0, data.data(), data.size(), kCFAllocatorNull));
+        if (quickLookHandle-&gt;didReceiveData(rawData.get()))
+            return;
+    }
+#endif
</ins><span class="cx">     m_coreLoader-&gt;didReceiveData(reinterpret_cast&lt;const char*&gt;(data.data()), data.size(), encodedDataLength, DataPayloadBytes);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebResourceLoader::didFinishResourceLoad(double finishTime)
</span><span class="cx"> {
</span><span class="cx">     LOG(Network, &quot;(WebProcess) WebResourceLoader::didFinishResourceLoad for '%s'&quot;, m_coreLoader-&gt;url().string().utf8().data());
</span><ins>+
+#if USE(QUICK_LOOK)
+    QuickLookHandle* quickLookHandle = resourceLoader()-&gt;quickLookHandle();
+    if (quickLookHandle &amp;&amp; quickLookHandle-&gt;didFinishLoading())
+        return;
+#endif
</ins><span class="cx">     m_coreLoader-&gt;didFinishLoading(finishTime);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -139,6 +160,10 @@
</span><span class="cx"> {
</span><span class="cx">     LOG(Network, &quot;(WebProcess) WebResourceLoader::didFailResourceLoad for '%s'&quot;, m_coreLoader-&gt;url().string().utf8().data());
</span><span class="cx">     
</span><ins>+#if USE(QUICK_LOOK)
+    if (QuickLookHandle *quickLookHandle = resourceLoader()-&gt;quickLookHandle())
+        quickLookHandle-&gt;didFail();
+#endif
</ins><span class="cx">     m_coreLoader-&gt;didFail(error);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessNetworkWebResourceLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h (165907 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h        2014-03-19 19:21:03 UTC (rev 165907)
+++ trunk/Source/WebKit2/WebProcess/Network/WebResourceLoader.h        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -88,6 +88,10 @@
</span><span class="cx">     void canAuthenticateAgainstProtectionSpace(const WebCore::ProtectionSpace&amp;);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(QUICK_LOOK)
+    void setUpQuickLookHandleIfNeeded(const WebCore::ResourceResponse&amp;);
+#endif
+
</ins><span class="cx">     RefPtr&lt;WebCore::ResourceLoader&gt; m_coreLoader;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessiosWebResourceLoaderIOSmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/WebProcess/ios/WebResourceLoaderIOS.mm (0 => 165908)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/ios/WebResourceLoaderIOS.mm                                (rev 0)
+++ trunk/Source/WebKit2/WebProcess/ios/WebResourceLoaderIOS.mm        2014-03-19 19:24:30 UTC (rev 165908)
</span><span class="lines">@@ -0,0 +1,116 @@
</span><ins>+/*
+ * 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 &quot;config.h&quot;
+#import &quot;WebResourceLoader.h&quot;
+
+#if ENABLE(NETWORK_PROCESS)
+#include &quot;DataReference.h&quot;
+#include &lt;WebCore/ResourceError.h&gt;
+#include &lt;WebCore/ResourceLoader.h&gt;
+
+using namespace WebCore;
+
+#if USE(QUICK_LOOK)
+
+@interface WKWebResourceQuickLookDelegate : NSObject &lt;NSURLConnectionDelegate&gt; {
+    RefPtr&lt;WebKit::WebResourceLoader&gt; _webResourceLoader;
+}
+@end
+
+@implementation WKWebResourceQuickLookDelegate
+
+- (id)initWithWebResourceLoader:(PassRefPtr&lt;WebKit::WebResourceLoader&gt;)loader
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _webResourceLoader = loader;
+    return self;
+}
+
+#if USE(NETWORK_CFDATA_ARRAY_CALLBACK)
+- (void)connection:(NSURLConnection *)connection didReceiveDataArray:(NSArray *)dataArray
+{
+    UNUSED_PARAM(connection);
+    if (!_webResourceLoader)
+        return;
+    _webResourceLoader-&gt;resourceLoader()-&gt;didReceiveDataArray(reinterpret_cast&lt;CFArrayRef&gt;(dataArray));
+}
+#endif
+
+- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data lengthReceived:(long long)lengthReceived
+{
+    UNUSED_PARAM(connection);
+    if (!_webResourceLoader)
+        return;
+
+    // QuickLook code sends us a nil data at times. The check below is the same as the one in
+    // ResourceHandleMac.cpp added for a different bug.
+    if (![data length])
+        return;
+    _webResourceLoader-&gt;resourceLoader()-&gt;didReceiveData(reinterpret_cast&lt;const char*&gt;([data bytes]), [data length], lengthReceived, DataPayloadBytes);
+}
+
+- (void)connectionDidFinishLoading:(NSURLConnection *)connection
+{
+    UNUSED_PARAM(connection);
+    if (!_webResourceLoader)
+        return;
+
+    _webResourceLoader-&gt;resourceLoader()-&gt;didFinishLoading(0);
+}
+
+- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
+{
+    UNUSED_PARAM(connection);
+
+    _webResourceLoader-&gt;resourceLoader()-&gt;didFail(ResourceError(error));
+}
+
+- (void)clearHandle
+{
+    _webResourceLoader = nullptr;
+}
+
+@end
+
+namespace WebKit {
+
+void WebResourceLoader::setUpQuickLookHandleIfNeeded(const ResourceResponse&amp; response)
+{
+    ResourceLoader *coreLoader = resourceLoader();
+    RetainPtr&lt;WKWebResourceQuickLookDelegate&gt; delegate = adoptNS([[WKWebResourceQuickLookDelegate alloc] initWithWebResourceLoader:this]);
+    OwnPtr&lt;QuickLookHandle&gt; quickLookHandle = QuickLookHandle::create(coreLoader, response.nsURLResponse(), delegate.get());
+    if (quickLookHandle)
+        coreLoader-&gt;setQuickLookHandle(quickLookHandle.release());
+}
+
+} // namespace WebKit
+
+#endif
+
+#endif // ENABLE(NETWORK_PROCESS)
</ins></span></pre>
</div>
</div>

</body>
</html>