Commit 270b557d authored by tristan's avatar tristan

Reviewed by Maciej Stachowiak.

        <rdar://problem/5294691> Source of file is misrepresented if downloaded by typing in URL in Safari address bar

        * WebCoreSupport/WebFrameLoaderClient.h:
        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::download):
        Revised code to check the initial request's referrer before assuming it has a history to check.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@24365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b982814f
2007-07-17 Tristan O'Tierney <tristan@apple.com>
Reviewed by Maciej Stachowiak.
<rdar://problem/5294691> Source of file is misrepresented if downloaded by typing in URL in Safari address bar
* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::download):
Revised code to check the initial request's referrer before assuming it has a history to check.
2007-07-16 Brady Eidson <beidson@apple.com>
Reviewed by Adam
......
......@@ -75,7 +75,7 @@ private:
virtual void detachedFromParent3();
virtual void detachedFromParent4();
virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
......
......@@ -238,33 +238,43 @@ void WebFrameLoaderClient::detachedFromParent4()
m_webFrame->_private->bridge = nil;
}
void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceResponse& response)
void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest& initialRequest, const ResourceResponse& response)
{
id proxy = handle->releaseProxy();
ASSERT(proxy);
WebView *webView = getWebView(m_webFrame.get());
NSURLRequest *initialURLRequest = initialRequest.nsURLRequest();
WebDownload *download = [WebDownload _downloadWithLoadingConnection:handle->connection()
request:request.nsURLRequest()
response:response.nsURLResponse()
delegate:[webView downloadDelegate]
proxy:proxy];
NSURL *originalURL = nil;
WebBackForwardList *history = [webView backForwardList];
WebHistoryItem *currentItem = nil;
int backListCount = [history backListCount];
int backCount = 0;
// find the first item in the history that was originated
// by the user
while (backListCount > 0 && !originalURL) {
currentItem = [history itemAtIndex:backCount--];
if (![currentItem respondsToSelector:@selector(_wasUserGesture)] || [currentItem _wasUserGesture])
originalURL = [currentItem URL];
// if there was no referrer, don't traverse the backforward history
// since this download was initiated directly
// <rdar://problem/5294691>
if ([initialURLRequest valueForHTTPHeaderField:@"Referer"]) {
// find the first item in the history that was originated
// by the user
while (backListCount > 0 && !originalURL) {
currentItem = [history itemAtIndex:backCount--];
if ([currentItem respondsToSelector:@selector(_wasUserGesture)] && [currentItem _wasUserGesture])
originalURL = [currentItem URL];
}
}
if (!originalURL)
originalURL = [initialURLRequest URL];
if (originalURL && [download respondsToSelector:@selector(_setOriginatingURL:)])
if ([download respondsToSelector:@selector(_setOriginatingURL:)])
[download _setOriginatingURL:originalURL];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment