<!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>[166466] 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/166466">166466</a></dd>
<dt>Author</dt> <dd>aestes@apple.com</dd>
<dt>Date</dt> <dd>2014-03-30 15:33:51 -0700 (Sun, 30 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] Add an originatingWebView property to _WKDownload
https://bugs.webkit.org/show_bug.cgi?id=130945

Reviewed by Anders Carlsson.

Source/WebKit2:

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]): Passed self to WKView's initializer.
* UIProcess/API/Cocoa/_WKDownload.h: Declared originatingWebView as a weak, readonly property.
* UIProcess/API/Cocoa/_WKDownload.mm:
(-[_WKDownload originatingWebView]):
(-[_WKDownload setOriginatingWebView:]):
* UIProcess/API/Cocoa/_WKDownloadInternal.h: Re-declared originatingWebView as readwrite so that
PageClientImpl can call setOriginatingWebView:. Removed some dead code.
* UIProcess/API/mac/WKView.mm:
(-[WKView initWithFrame:context:configuration:webView:]): Updated to accept a webView parameter.
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]): Passed nil for the webView parameter.
* UIProcess/API/mac/WKViewInternal.h:
* UIProcess/Cocoa/DownloadClient.mm:
(WebKit::DownloadClient::decideDestinationWithSuggestedFilename): Ensured allowOverwrite is initialized.
* UIProcess/PageClient.h: Included handleDownloadRequest() on all platforms.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::receivedPolicyDecision): Ditto.
(WebKit::WebPageProxy::handleDownloadRequest): Ditto.
* UIProcess/WebPageProxy.h: Ditto.
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::handleDownloadRequest): Called -[_WKDownload setOriginatingWebView:].
* UIProcess/mac/PageClientImpl.h: Added a m_webView member variable.
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::PageClientImpl): Asserted that m_webView is nil if WK API isn't enabled.
(WebKit::PageClientImpl::handleDownloadRequest): Called -[_WKDownload setOriginatingWebView:].

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm:
(-[DownloadDelegate _downloadDidStart:]):
(-[OriginatingWebViewDownloadDelegate initWithWebView:]):
(-[OriginatingWebViewDownloadDelegate _downloadDidStart:]):
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKDownloadh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKDownloadmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKDownloadInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownloadInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewInternalh">trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaDownloadClientmm">trunk/Source/WebKit2/UIProcess/Cocoa/DownloadClient.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaDownloadmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/ChangeLog        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2014-03-30  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [Cocoa] Add an originatingWebView property to _WKDownload
+        https://bugs.webkit.org/show_bug.cgi?id=130945
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView initWithFrame:configuration:]): Passed self to WKView's initializer.
+        * UIProcess/API/Cocoa/_WKDownload.h: Declared originatingWebView as a weak, readonly property.
+        * UIProcess/API/Cocoa/_WKDownload.mm:
+        (-[_WKDownload originatingWebView]):
+        (-[_WKDownload setOriginatingWebView:]):
+        * UIProcess/API/Cocoa/_WKDownloadInternal.h: Re-declared originatingWebView as readwrite so that
+        PageClientImpl can call setOriginatingWebView:. Removed some dead code.
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView initWithFrame:context:configuration:webView:]): Updated to accept a webView parameter.
+        (-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]): Passed nil for the webView parameter.
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/Cocoa/DownloadClient.mm:
+        (WebKit::DownloadClient::decideDestinationWithSuggestedFilename): Ensured allowOverwrite is initialized.
+        * UIProcess/PageClient.h: Included handleDownloadRequest() on all platforms.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::receivedPolicyDecision): Ditto.
+        (WebKit::WebPageProxy::handleDownloadRequest): Ditto.
+        * UIProcess/WebPageProxy.h: Ditto.
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::handleDownloadRequest): Called -[_WKDownload setOriginatingWebView:].
+        * UIProcess/mac/PageClientImpl.h: Added a m_webView member variable.
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::PageClientImpl): Asserted that m_webView is nil if WK API isn't enabled.
+        (WebKit::PageClientImpl::handleDownloadRequest): Called -[_WKDownload setOriginatingWebView:].
+
</ins><span class="cx"> 2014-03-29  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r166434.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -184,7 +184,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    _wkView = [[WKView alloc] initWithFrame:bounds context:context configuration:std::move(webPageConfiguration)];
</del><ins>+    _wkView = [[WKView alloc] initWithFrame:bounds context:context configuration:std::move(webPageConfiguration) webView:self];
</ins><span class="cx">     [self addSubview:_wkView.get()];
</span><span class="cx">     _page = WebKit::toImpl([_wkView pageRef]);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKDownloadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.h (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.h        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.h        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -29,12 +29,15 @@
</span><span class="cx"> 
</span><span class="cx"> #import &lt;Foundation/Foundation.h&gt;
</span><span class="cx"> 
</span><ins>+@class WKWebView;
+
</ins><span class="cx"> WK_API_CLASS
</span><span class="cx"> @interface _WKDownload : NSObject
</span><span class="cx"> 
</span><span class="cx"> - (void)cancel;
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, readonly) NSURLRequest *request;
</span><ins>+@property (nonatomic, readonly, weak) WKWebView *originatingWebView;
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKDownloadmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.mm (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.mm        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownload.mm        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -29,9 +29,11 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> 
</span><span class="cx"> #import &quot;DownloadProxy.h&quot;
</span><ins>+#import &quot;WeakObjCPtr.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> @implementation _WKDownload {
</span><span class="cx">     API::ObjectStorage&lt;WebKit::DownloadProxy&gt; _download;
</span><ins>+    WebKit::WeakObjCPtr&lt;WKWebView&gt; _originatingWebView;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)dealloc
</span><span class="lines">@@ -51,6 +53,16 @@
</span><span class="cx">     return _download-&gt;request().nsURLRequest(WebCore::DoNotUpdateHTTPBody);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (WKWebView *)originatingWebView
+{
+    return _originatingWebView.getAutoreleased();
+}
+
+- (void)setOriginatingWebView:(WKWebView *)originatingWebView
+{
+    _originatingWebView = originatingWebView;
+}
+
</ins><span class="cx"> #pragma mark WKObject protocol implementation
</span><span class="cx"> 
</span><span class="cx"> - (API::Object&amp;)_apiObject
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKDownloadInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownloadInternal.h (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownloadInternal.h        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKDownloadInternal.h        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -29,17 +29,8 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;WKObject.h&quot;
</span><span class="cx"> 
</span><del>-@protocol _WKDownloadDelegate;
-
-namespace API {
-class DownloadClient;
-}
-
-namespace WebKit {
-std::unique_ptr&lt;API::DownloadClient&gt; createAPIDownloadClient(id &lt;_WKDownloadDelegate&gt;);
-}
-
</del><span class="cx"> @interface _WKDownload () &lt;WKObject&gt;
</span><ins>+@property (nonatomic, weak) WKWebView *originatingWebView;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // WK_API_ENABLED
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -3387,7 +3387,7 @@
</span><span class="cx">     return _data-&gt;_page-&gt;suppressVisibilityUpdates();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (instancetype)initWithFrame:(NSRect)frame context:(WebContext&amp;)context configuration:(WebPageConfiguration)webPageConfiguration
</del><ins>+- (instancetype)initWithFrame:(NSRect)frame context:(WebContext&amp;)context configuration:(WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView
</ins><span class="cx"> {
</span><span class="cx">     self = [super initWithFrame:frame];
</span><span class="cx">     if (!self)
</span><span class="lines">@@ -3412,7 +3412,7 @@
</span><span class="cx">     [trackingArea release];
</span><span class="cx"> 
</span><span class="cx">     _data = [[WKViewData alloc] init];
</span><del>-    _data-&gt;_pageClient = std::make_unique&lt;PageClientImpl&gt;(self);
</del><ins>+    _data-&gt;_pageClient = std::make_unique&lt;PageClientImpl&gt;(self, webView);
</ins><span class="cx">     _data-&gt;_page = context.createWebPage(*_data-&gt;_pageClient, std::move(webPageConfiguration));
</span><span class="cx">     _data-&gt;_page-&gt;setIntrinsicDeviceScaleFactor([self _intrinsicDeviceScaleFactor]);
</span><span class="cx">     _data-&gt;_page-&gt;initializeWebPage();
</span><span class="lines">@@ -3505,7 +3505,7 @@
</span><span class="cx">     webPageConfiguration.pageGroup = toImpl(pageGroupRef);
</span><span class="cx">     webPageConfiguration.relatedPage = toImpl(relatedPage);
</span><span class="cx"> 
</span><del>-    return [self initWithFrame:frame context:*toImpl(contextRef) configuration:webPageConfiguration];
</del><ins>+    return [self initWithFrame:frame context:*toImpl(contextRef) configuration:webPageConfiguration webView:nil];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if __MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 1080
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -54,13 +54,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @class WKFullScreenWindowController;
</span><ins>+@class WKWebView;
</ins><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> @class _WKThumbnailView;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @interface WKView ()
</span><span class="cx"> #if WK_API_ENABLED
</span><del>-- (instancetype)initWithFrame:(CGRect)frame context:(WebKit::WebContext&amp;)context configuration:(WebKit::WebPageConfiguration)webPageConfiguration;
</del><ins>+- (instancetype)initWithFrame:(CGRect)frame context:(WebKit::WebContext&amp;)context configuration:(WebKit::WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> - (std::unique_ptr&lt;WebKit::DrawingAreaProxy&gt;)_createDrawingAreaProxy;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaDownloadClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/DownloadClient.mm (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/DownloadClient.mm        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/DownloadClient.mm        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -77,7 +77,7 @@
</span><span class="cx">     if (!m_delegateMethods.downloadDecideDestinationWithSuggestedFilenameAllowOverwrite)
</span><span class="cx">         return String();
</span><span class="cx">     
</span><del>-    BOOL allowOverwrite;
</del><ins>+    BOOL allowOverwrite = NO;
</ins><span class="cx">     NSString *destination = [m_delegate.get() _download:wrapper(*downloadProxy) decideDestinationWithSuggestedFilename:filename allowOverwrite:&amp;allowOverwrite];
</span><span class="cx">     allowOverwriteParam = allowOverwrite;
</span><span class="cx">     return destination;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -146,9 +146,7 @@
</span><span class="cx">     virtual void updateTextInputState() = 0;
</span><span class="cx"> #endif // PLATFORM(EFL) || PLATOFRM(GTK)
</span><span class="cx"> 
</span><del>-#if PLATFORM(EFL) || PLATFORM(GTK)
</del><span class="cx">     virtual void handleDownloadRequest(DownloadProxy*) = 0;
</span><del>-#endif // PLATFORM(EFL) || PLATFORM(GTK)
</del><span class="cx"> 
</span><span class="cx"> #if PLATFORM(EFL)
</span><span class="cx">     virtual void didChangeContentSize(const WebCore::IntSize&amp;) = 0;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -1530,10 +1530,7 @@
</span><span class="cx">         // Create a download proxy.
</span><span class="cx">         DownloadProxy* download = m_process-&gt;context().createDownloadProxy();
</span><span class="cx">         downloadID = download-&gt;downloadID();
</span><del>-#if PLATFORM(EFL) || PLATFORM(GTK)
-        // Our design does not suppport downloads without a WebPage.
</del><span class="cx">         handleDownloadRequest(download);
</span><del>-#endif
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If we received a policy decision while in decidePolicyForResponse the decision will
</span><span class="lines">@@ -2988,12 +2985,10 @@
</span><span class="cx">     process().send(Messages::WebPage::SetMayStartMediaWhenInWindow(mayStartMedia), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if PLATFORM(EFL) || PLATFORM(GTK)
</del><span class="cx"> void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
</span><span class="cx"> {
</span><span class="cx">     m_pageClient.handleDownloadRequest(download);
</span><span class="cx"> }
</span><del>-#endif // PLATFORM(EFL) || PLATFORM(GTK)
</del><span class="cx"> 
</span><span class="cx"> #if PLATFORM(EFL)
</span><span class="cx"> void WebPageProxy::didChangeContentSize(const IntSize&amp; size)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -920,9 +920,7 @@
</span><span class="cx">     void findZoomableAreaForPoint(const WebCore::IntPoint&amp;, const WebCore::IntSize&amp;);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(EFL) || PLATFORM(GTK)
</del><span class="cx">     void handleDownloadRequest(DownloadProxy*);
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     void advanceToNextMisspelling(bool startBeforeSelection);
</span><span class="cx">     void changeSpellingToWord(const String&amp; word);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     {
</span><span class="cx"> public:
</span><del>-    explicit PageClientImpl(WKContentView *, WKWebView *);
</del><ins>+    PageClientImpl(WKContentView *, WKWebView *);
</ins><span class="cx">     virtual ~PageClientImpl();
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx">     virtual void toolTipChanged(const String&amp;, const String&amp;) override;
</span><span class="cx">     virtual bool decidePolicyForGeolocationPermissionRequest(WebFrameProxy&amp;, WebSecurityOrigin&amp;, GeolocationPermissionRequestProxy&amp;) override;
</span><span class="cx">     virtual void didCommitLoadForMainFrame(const String&amp; mimeType, bool useCustomContentProvider) override;
</span><ins>+    virtual void handleDownloadRequest(DownloadProxy*) override;
</ins><span class="cx">     virtual void setCursor(const WebCore::Cursor&amp;) override;
</span><span class="cx">     virtual void setCursorHiddenUntilMouseMoves(bool) override;
</span><span class="cx">     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&amp;) override;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -28,7 +28,9 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &quot;_WKDownloadInternal.h&quot;
</ins><span class="cx"> #import &quot;DataReference.h&quot;
</span><ins>+#import &quot;DownloadProxy.h&quot;
</ins><span class="cx"> #import &quot;NativeWebKeyboardEvent.h&quot;
</span><span class="cx"> #import &quot;InteractionInformationAtPosition.h&quot;
</span><span class="cx"> #import &quot;WKContentView.h&quot;
</span><span class="lines">@@ -154,6 +156,13 @@
</span><span class="cx">     [m_contentView _didCommitLoadForMainFrame];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
+{
+    ASSERT_ARG(download, download);
+    ASSERT([download-&gt;wrapper() isKindOfClass:[_WKDownload class]]);
+    [static_cast&lt;_WKDownload *&gt;(download-&gt;wrapper()) setOriginatingWebView:m_webView];
+}
+
</ins><span class="cx"> void PageClientImpl::setCursor(const Cursor&amp;)
</span><span class="cx"> {
</span><span class="cx">     notImplemented();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> 
</span><span class="cx"> @class WKEditorUndoTargetObjC;
</span><span class="cx"> @class WKView;
</span><ins>+@class WKWebView;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class AlternativeTextUIController;
</span><span class="lines">@@ -49,7 +50,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     {
</span><span class="cx"> public:
</span><del>-    explicit PageClientImpl(WKView *);
</del><ins>+    PageClientImpl(WKView *, WKWebView *);
</ins><span class="cx">     virtual ~PageClientImpl();
</span><span class="cx">     
</span><span class="cx">     void viewWillMoveToAnotherWindow();
</span><span class="lines">@@ -81,6 +82,7 @@
</span><span class="cx">     virtual void toolTipChanged(const String&amp; oldToolTip, const String&amp; newToolTip);
</span><span class="cx">     virtual void didCommitLoadForMainFrame(const String&amp; mimeType, bool useCustomContentProvider) override;
</span><span class="cx">     virtual void didFinishLoadingDataForCustomContentProvider(const String&amp; suggestedFilename, const IPC::DataReference&amp;) override;
</span><ins>+    virtual void handleDownloadRequest(DownloadProxy*) override;
</ins><span class="cx">     virtual void setCursor(const WebCore::Cursor&amp;);
</span><span class="cx">     virtual void setCursorHiddenUntilMouseMoves(bool);
</span><span class="cx">     virtual void didChangeViewportProperties(const WebCore::ViewportAttributes&amp;);
</span><span class="lines">@@ -166,6 +168,7 @@
</span><span class="cx">     NSView *activeView() const;
</span><span class="cx"> 
</span><span class="cx">     WKView *m_wkView;
</span><ins>+    WKWebView *m_webView;
</ins><span class="cx">     RetainPtr&lt;WKEditorUndoTargetObjC&gt; m_undoTarget;
</span><span class="cx"> #if USE(AUTOCORRECTION_PANEL)
</span><span class="cx">     CorrectionPanel m_correctionPanel;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -28,10 +28,12 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><ins>+#import &quot;_WKDownloadInternal.h&quot;
</ins><span class="cx"> #import &quot;AttributedString.h&quot;
</span><span class="cx"> #import &quot;ColorSpaceData.h&quot;
</span><span class="cx"> #import &quot;DataReference.h&quot;
</span><span class="cx"> #import &quot;DictionaryPopupInfo.h&quot;
</span><ins>+#import &quot;DownloadProxy.h&quot;
</ins><span class="cx"> #import &quot;FindIndicator.h&quot;
</span><span class="cx"> #import &quot;NativeWebKeyboardEvent.h&quot;
</span><span class="cx"> #import &quot;NativeWebWheelEvent.h&quot;
</span><span class="lines">@@ -126,13 +128,17 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><del>-PageClientImpl::PageClientImpl(WKView* wkView)
</del><ins>+PageClientImpl::PageClientImpl(WKView* wkView, WKWebView *webView)
</ins><span class="cx">     : m_wkView(wkView)
</span><ins>+    , m_webView(webView)
</ins><span class="cx">     , m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
</span><span class="cx"> #if USE(DICTATION_ALTERNATIVES)
</span><span class="cx">     , m_alternativeTextUIController(adoptPtr(new AlternativeTextUIController))
</span><span class="cx"> #endif
</span><span class="cx"> {
</span><ins>+#if !WK_API_ENABLED
+    ASSERT_UNUSED(m_webView, !m_webView);
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PageClientImpl::~PageClientImpl()
</span><span class="lines">@@ -293,6 +299,15 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
+{
+    ASSERT_ARG(download, download);
+#if WK_API_ENABLED
+    ASSERT([download-&gt;wrapper() isKindOfClass:[_WKDownload class]]);
+    [static_cast&lt;_WKDownload *&gt;(download-&gt;wrapper()) setOriginatingWebView:m_webView];
+#endif
+}
+
</ins><span class="cx"> void PageClientImpl::setCursor(const WebCore::Cursor&amp; cursor)
</span><span class="cx"> {
</span><span class="cx">     if (![NSApp _cursorRectCursor])
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Tools/ChangeLog        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2014-03-30  Andy Estes  &lt;aestes@apple.com&gt;
+
+        [Cocoa] Add an originatingWebView property to _WKDownload
+        https://bugs.webkit.org/show_bug.cgi?id=130945
+
+        Reviewed by Anders Carlsson.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm:
+        (-[DownloadDelegate _downloadDidStart:]):
+        (-[OriginatingWebViewDownloadDelegate initWithWebView:]):
+        (-[OriginatingWebViewDownloadDelegate _downloadDidStart:]):
+        (TEST):
+
</ins><span class="cx"> 2014-03-28  Filip Pizlo  &lt;fpizlo@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Land the stackmap register liveness glue with the uses of the liveness disabled
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaDownloadmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm (166465 => 166466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm        2014-03-30 20:32:22 UTC (rev 166465)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Download.mm        2014-03-30 22:33:51 UTC (rev 166466)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #import &quot;PlatformUtilities.h&quot;
</span><span class="cx"> #import &quot;Test.h&quot;
</span><span class="cx"> #import &lt;WebCore/FileSystem.h&gt;
</span><ins>+#import &lt;WebKit2/_WKDownload.h&gt;
</ins><span class="cx"> #import &lt;WebKit2/_WKDownloadDelegate.h&gt;
</span><span class="cx"> #import &lt;WebKit2/WKNavigationDelegate.h&gt;
</span><span class="cx"> #import &lt;WebKit2/WKProcessPoolPrivate.h&gt;
</span><span class="lines">@@ -56,6 +57,7 @@
</span><span class="cx"> {
</span><span class="cx">     EXPECT_NULL(_download);
</span><span class="cx">     EXPECT_NOT_NULL(download);
</span><ins>+    EXPECT_TRUE([[[download request] URL] isEqual:sourceURL]);
</ins><span class="cx">     _download = download;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -220,4 +222,50 @@
</span><span class="cx">     runTest(adoptNS([[DownloadNavigationDelegate alloc] init]).get(), adoptNS([[CancelledDownloadDelegate alloc] init]).get(), sourceURL);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+@interface OriginatingWebViewDownloadDelegate : NSObject &lt;_WKDownloadDelegate&gt;
+- (instancetype)initWithWebView:(WKWebView *)webView;
+@end
+
+@implementation OriginatingWebViewDownloadDelegate {
+    RetainPtr&lt;WKWebView&gt; _webView;
+}
+
+- (instancetype)initWithWebView:(WKWebView *)webView
+{
+    if (!(self = [super init]))
+        return nil;
+
+    _webView = webView;
+    return self;
+}
+
+- (void)_downloadDidStart:(_WKDownload *)download
+{
+    @autoreleasepool {
+        EXPECT_EQ([download originatingWebView], _webView);
+    }
+
+    _webView = nullptr;
+    EXPECT_NULL([download originatingWebView]);
+    isDone = true;
+}
+
+@end
+
+TEST(_WKDownload, OriginatingWebView)
+{
+    RetainPtr&lt;DownloadNavigationDelegate&gt; navigationDelegate = adoptNS([[DownloadNavigationDelegate alloc] init]);                 
+    RetainPtr&lt;OriginatingWebViewDownloadDelegate&gt; downloadDelegate;
+    {
+        RetainPtr&lt;WKWebView&gt; webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+        [webView setNavigationDelegate:navigationDelegate.get()];
+        downloadDelegate = adoptNS([[OriginatingWebViewDownloadDelegate alloc] initWithWebView:webView.get()]);
+        [[[webView configuration] processPool] _setDownloadDelegate:downloadDelegate.get()];
+        [webView loadRequest:[NSURLRequest requestWithURL:sourceURL]];
+    }
+
+    isDone = false;
+    TestWebKitAPI::Util::run(&amp;isDone);
+}
+
</ins><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>