[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 15:56:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 019b365fbf8fb08ab2fb5b36eca8e32dbe495b0e
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Nov 16 23:52:41 2010 +0000

    Set the original URL for downloads
    https://bugs.webkit.org/show_bug.cgi?id=49628
    
    Reviewed by John Sullivan.
    
    WebCore:
    
    Export symbols needed by WebKit2.
    
    * WebCore.exp.in:
    
    WebKit2:
    
    * WebProcess/Downloads/DownloadManager.cpp:
    (WebKit::DownloadManager::startDownload):
    * WebProcess/Downloads/DownloadManager.h:
    startDownload now takes the originating web page.
    
    * WebProcess/Downloads/cf/DownloadCFNet.cpp:
    (WebKit::Download::start):
    start now takes the originating web page.
    
    * WebProcess/Downloads/mac/DownloadMac.mm:
    (WebKit::originatingURL):
    (WebKit::setOriginalURLForDownload):
    Port code over from WebKit1 that sets the download URL.
    
    (WebKit::Download::start):
    Call setOriginalURLForDownload.
    
    * WebProcess/Downloads/qt/DownloadQt.cpp:
    (WebKit::Download::start):
    start now takes the originating web page.
    
    * WebProcess/WebPage/WebFrame.cpp:
    (WebKit::WebFrame::startDownload):
    Pass the web page to DownloadManager::startDownload.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@72145 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6df97b9..607b9cd 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-16  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by John Sullivan.
+
+        Set the original URL for downloads
+        https://bugs.webkit.org/show_bug.cgi?id=49628
+
+        Export symbols needed by WebKit2.
+
+        * WebCore.exp.in:
+
 2010-11-16  Dave Hyatt  <hyatt at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebCore/WebCore.exp.in b/WebCore/WebCore.exp.in
index d2602d2..4862394 100644
--- a/WebCore/WebCore.exp.in
+++ b/WebCore/WebCore.exp.in
@@ -932,6 +932,7 @@ __ZNK7WebCore11HistoryItem10visitCountEv
 __ZNK7WebCore11HistoryItem11hasChildrenEv
 __ZNK7WebCore11HistoryItem11scrollPointEv
 __ZNK7WebCore11HistoryItem12isTargetItemEv
+__ZNK7WebCore11HistoryItem11originalURLEv
 __ZNK7WebCore11HistoryItem12redirectURLsEv
 __ZNK7WebCore11HistoryItem14alternateTitleEv
 __ZNK7WebCore11HistoryItem15lastVisitedTimeEv
@@ -1022,6 +1023,7 @@ __ZNK7WebCore16VisibleSelection5isAllENS_21StayInEditableContentE
 __ZNK7WebCore17ResourceErrorBase8lazyInitEv
 __ZNK7WebCore19AnimationController24numberOfActiveAnimationsEv
 __ZNK7WebCore19ResourceRequestBase10httpMethodEv
+__ZNK7WebCore19ResourceRequestBase15httpHeaderFieldEPKc
 __ZNK7WebCore19ResourceRequestBase3urlEv
 __ZNK7WebCore19ResourceRequestBase7isEmptyEv
 __ZNK7WebCore19SelectionController11currentFormEv
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 74a1eaf..26b422d 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,35 @@
+2010-11-16  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by John Sullivan.
+
+        Set the original URL for downloads
+        https://bugs.webkit.org/show_bug.cgi?id=49628
+
+        * WebProcess/Downloads/DownloadManager.cpp:
+        (WebKit::DownloadManager::startDownload):
+        * WebProcess/Downloads/DownloadManager.h:
+        startDownload now takes the originating web page.
+
+        * WebProcess/Downloads/cf/DownloadCFNet.cpp:
+        (WebKit::Download::start):
+        start now takes the originating web page.
+
+        * WebProcess/Downloads/mac/DownloadMac.mm:
+        (WebKit::originatingURL):
+        (WebKit::setOriginalURLForDownload):
+        Port code over from WebKit1 that sets the download URL.
+
+        (WebKit::Download::start):
+        Call setOriginalURLForDownload.
+
+        * WebProcess/Downloads/qt/DownloadQt.cpp:
+        (WebKit::Download::start):
+        start now takes the originating web page.
+
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::startDownload):
+        Pass the web page to DownloadManager::startDownload.
+
 2010-11-16  Dave Hyatt  <hyatt at apple.com>
 
         Reviewed by Dan Bernstein.
diff --git a/WebKit2/WebProcess/Downloads/Download.h b/WebKit2/WebProcess/Downloads/Download.h
index c70f1f8..45e272c 100644
--- a/WebKit2/WebProcess/Downloads/Download.h
+++ b/WebKit2/WebProcess/Downloads/Download.h
@@ -48,6 +48,8 @@ namespace WebCore {
 
 namespace WebKit {
 
+class WebPage;
+
 class Download : public CoreIPC::MessageSender<Download> {
     WTF_MAKE_NONCOPYABLE(Download);
 
@@ -59,7 +61,7 @@ public:
     CoreIPC::Connection* connection() const;
     uint64_t destinationID() const { return m_downloadID; }
 
-    void start();
+    void start(WebPage* initiatingWebPage);
 
     void didStart();
     void didReceiveResponse(const WebCore::ResourceResponse&);
diff --git a/WebKit2/WebProcess/Downloads/DownloadManager.cpp b/WebKit2/WebProcess/Downloads/DownloadManager.cpp
index 2c85f15..cfe90e5 100644
--- a/WebKit2/WebProcess/Downloads/DownloadManager.cpp
+++ b/WebKit2/WebProcess/Downloads/DownloadManager.cpp
@@ -43,10 +43,10 @@ DownloadManager::DownloadManager()
 {
 }
 
-void DownloadManager::startDownload(uint64_t downloadID, const ResourceRequest& request)
+void DownloadManager::startDownload(uint64_t downloadID, WebPage* initiatingPage, const ResourceRequest& request)
 {
     OwnPtr<Download> download = Download::create(downloadID, request);
-    download->start();
+    download->start(initiatingPage);
 
     ASSERT(!m_downloads.contains(downloadID));
     m_downloads.set(downloadID, download.leakPtr());
diff --git a/WebKit2/WebProcess/Downloads/DownloadManager.h b/WebKit2/WebProcess/Downloads/DownloadManager.h
index 9a5d730..1a48944 100644
--- a/WebKit2/WebProcess/Downloads/DownloadManager.h
+++ b/WebKit2/WebProcess/Downloads/DownloadManager.h
@@ -36,6 +36,7 @@ namespace WebCore {
 namespace WebKit {
 
 class Download;
+class WebPage;
 
 class DownloadManager {
     WTF_MAKE_NONCOPYABLE(DownloadManager);
@@ -43,7 +44,7 @@ class DownloadManager {
 public:
     static DownloadManager& shared();
 
-    void startDownload(uint64_t downloadID, const WebCore::ResourceRequest&);
+    void startDownload(uint64_t downloadID, WebPage* initiatingPage, const WebCore::ResourceRequest&);
 
 private:
     DownloadManager();
diff --git a/WebKit2/WebProcess/Downloads/cf/DownloadCFNet.cpp b/WebKit2/WebProcess/Downloads/cf/DownloadCFNet.cpp
index 9a1d921..505f069 100644
--- a/WebKit2/WebProcess/Downloads/cf/DownloadCFNet.cpp
+++ b/WebKit2/WebProcess/Downloads/cf/DownloadCFNet.cpp
@@ -31,7 +31,7 @@ using namespace WebCore;
 
 namespace WebKit {
 
-void Download::start()
+void Download::start(WebPage* initiatingWebPage)
 {
     notImplemented();
 }
diff --git a/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm b/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm
index 91b1a13..0d106f0 100644
--- a/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm
+++ b/WebKit2/WebProcess/Downloads/mac/DownloadMac.mm
@@ -25,8 +25,16 @@
 
 #include "Download.h"
 
+#include <WebCore/BackForwardController.h>
+#include <WebCore/HistoryItem.h>
+#include <WebCore/Page.h>
 #include <WebCore/ResourceResponse.h>
 #include "NotImplemented.h"
+#include "WebPage.h"
+
+ at interface NSURLDownload (WebNSURLDownloadDetails)
+- (void)_setOriginatingURL:(NSURL *)originatingURL;
+ at end
 
 @interface WKDownloadAsDelegate : NSObject <NSURLConnectionDelegate> {
     WebKit::Download* _download;
@@ -35,12 +43,68 @@
 - (void)invalidate;
 @end
 
-
 using namespace WebCore;
 
 namespace WebKit {
 
-void Download::start()
+static KURL originatingURLFromBackForwardList(WebPage *webPage)
+{
+    if (!webPage)
+        return KURL();
+
+    Page* page = webPage->corePage();
+    if (!page)
+        return KURL();
+
+    KURL originalURL;
+    int backCount = page->backForward()->backCount();
+    for (int backIndex = 0; backIndex <= backCount; backIndex++) {
+        // FIXME: At one point we had code here to check a "was user gesture" flag.
+        // Do we need to restore that logic?
+        originalURL = page->backForward()->itemAtIndex(-backIndex)->originalURL(); 
+        if (!originalURL.isNull()) 
+            return originalURL;
+    }
+
+    return KURL();
+}
+
+static void setOriginalURLForDownload(WebPage *webPage, NSURLDownload *download, const ResourceRequest& initialRequest)
+{
+    KURL originalURL;
+    
+    // If there was no referrer, don't traverse the back/forward history
+    // since this download was initiated directly. <rdar://problem/5294691>
+    if (!initialRequest.httpReferrer().isNull()) {
+        // find the first item in the history that was originated by the user
+        originalURL = originatingURLFromBackForwardList(webPage);
+    }
+
+    if (originalURL.isNull())
+        originalURL = initialRequest.url();
+
+    NSURL *originalNSURL = originalURL;
+
+    NSString *scheme = [originalNSURL scheme];
+    NSString *host = [originalNSURL host];
+    if (scheme && host && [scheme length] && [host length]) {
+        NSNumber *port = [originalNSURL port];
+        if (port && [port intValue] < 0)
+            port = nil;
+        RetainPtr<NSString> hostOnlyURLString;
+        if (port)
+            hostOnlyURLString.adoptNS([[NSString alloc] initWithFormat:@"%@://%@:%d", scheme, host, [port intValue]]);
+        else
+            hostOnlyURLString.adoptNS([[NSString alloc] initWithFormat:@"%@://%@", scheme, host]);
+
+        RetainPtr<NSURL> hostOnlyURL = [[NSURL alloc] initWithString:hostOnlyURLString.get()];
+
+        ASSERT([download respondsToSelector:@selector(_setOriginatingURL:)]);
+        [download _setOriginatingURL:hostOnlyURL.get()];
+    }
+}
+
+void Download::start(WebPage* initiatingPage)
 {
     ASSERT(!m_nsURLDownload);
     ASSERT(!m_delegate);
@@ -50,6 +114,8 @@ void Download::start()
 
     // FIXME: Allow this to be changed by the client.
     [m_nsURLDownload.get() setDeletesFileUponFailure:NO];
+
+    setOriginalURLForDownload(initiatingPage, m_nsURLDownload.get(), m_request);
 }
 
 void Download::platformInvalidate()
diff --git a/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp b/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp
index 9a1d921..505f069 100644
--- a/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp
+++ b/WebKit2/WebProcess/Downloads/qt/DownloadQt.cpp
@@ -31,7 +31,7 @@ using namespace WebCore;
 
 namespace WebKit {
 
-void Download::start()
+void Download::start(WebPage* initiatingWebPage)
 {
     notImplemented();
 }
diff --git a/WebKit2/WebProcess/WebPage/WebFrame.cpp b/WebKit2/WebProcess/WebPage/WebFrame.cpp
index 175da38..a71ce32 100644
--- a/WebKit2/WebProcess/WebPage/WebFrame.cpp
+++ b/WebKit2/WebProcess/WebPage/WebFrame.cpp
@@ -212,7 +212,7 @@ void WebFrame::startDownload(const WebCore::ResourceRequest& request)
 {
     ASSERT(m_policyDownloadID);
 
-    DownloadManager::shared().startDownload(m_policyDownloadID, request);
+    DownloadManager::shared().startDownload(m_policyDownloadID, page(), request);
 
     m_policyDownloadID = 0;
 }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list