Changeset 24365 in webkit


Ignore:
Timestamp:
Jul 17, 2007 11:24:36 AM (17 years ago)
Author:
tristan
Message:

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.
Location:
trunk/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/ChangeLog

    r24347 r24365  
     12007-07-17  Tristan O'Tierney  <tristan@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        <rdar://problem/5294691> Source of file is misrepresented if downloaded by typing in URL in Safari address bar
     6
     7        * WebCoreSupport/WebFrameLoaderClient.h:
     8        * WebCoreSupport/WebFrameLoaderClient.mm:
     9        (WebFrameLoaderClient::download):
     10        Revised code to check the initial request's referrer before assuming it has a history to check.
     11
    1122007-07-16  Brady Eidson  <beidson@apple.com>
    213
  • trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.h

    r21793 r24365  
    7676    virtual void detachedFromParent4();
    7777
    78     virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
     78    virtual void download(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
    7979
    8080    virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&);
  • trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.mm

    r24281 r24365  
    239239}
    240240
    241 void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceResponse& response)
     241void WebFrameLoaderClient::download(ResourceHandle* handle, const ResourceRequest& request, const ResourceRequest& initialRequest, const ResourceResponse& response)
    242242{
    243243    id proxy = handle->releaseProxy();
     
    245245   
    246246    WebView *webView = getWebView(m_webFrame.get());
     247    NSURLRequest *initialURLRequest = initialRequest.nsURLRequest();
    247248    WebDownload *download = [WebDownload _downloadWithLoadingConnection:handle->connection()
    248249                                                                request:request.nsURLRequest()
     
    250251                                                               delegate:[webView downloadDelegate]
    251252                                                                  proxy:proxy];
     253   
    252254    NSURL *originalURL = nil;
    253255    WebBackForwardList *history = [webView backForwardList];
     
    256258    int backCount = 0;
    257259   
    258     // find the first item in the history that was originated
    259     // by the user
    260     while (backListCount > 0 && !originalURL) {
    261         currentItem = [history itemAtIndex:backCount--];
    262        
    263         if (![currentItem respondsToSelector:@selector(_wasUserGesture)] || [currentItem _wasUserGesture])
    264             originalURL = [currentItem URL];
    265     }
    266 
    267     if (originalURL && [download respondsToSelector:@selector(_setOriginatingURL:)])
     260    // if there was no referrer, don't traverse the backforward history
     261    // since this download was initiated directly
     262    // <rdar://problem/5294691>
     263    if ([initialURLRequest valueForHTTPHeaderField:@"Referer"]) {
     264        // find the first item in the history that was originated
     265        // by the user
     266        while (backListCount > 0 && !originalURL) {
     267            currentItem = [history itemAtIndex:backCount--];
     268           
     269            if ([currentItem respondsToSelector:@selector(_wasUserGesture)] && [currentItem _wasUserGesture])
     270                originalURL = [currentItem URL];
     271        }
     272    }
     273   
     274    if (!originalURL)
     275        originalURL = [initialURLRequest URL];
     276
     277    if ([download respondsToSelector:@selector(_setOriginatingURL:)])
    268278        [download _setOriginatingURL:originalURL];
    269279}
Note: See TracChangeset for help on using the changeset viewer.