summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 21:46:07 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 21:46:07 +0000
commit79558c2a026dd800a15d1dd0743a8d9a7e042601 (patch)
tree89af8ea30aedbf6ba3efbc1f0909c29d5ee440e9 /chrome/browser
parentdfc3565886b90b6d5b0cae3f8e48f602d3293cf5 (diff)
downloadchromium_src-79558c2a026dd800a15d1dd0743a8d9a7e042601.zip
chromium_src-79558c2a026dd800a15d1dd0743a8d9a7e042601.tar.gz
chromium_src-79558c2a026dd800a15d1dd0743a8d9a7e042601.tar.bz2
Fix bug 69468: Drag download does not work if there is URL redirection involved.
The fix is to keep track of the original URL. BUG=69468 TEST=Manual test to verify. Review URL: http://codereview.chromium.org/6131009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/download/download_item.cc3
-rw-r--r--chrome/browser/download/download_item.h7
-rw-r--r--chrome/browser/download/drag_download_file.cc2
-rw-r--r--chrome/browser/history/download_create_info.h4
-rw-r--r--chrome/browser/renderer_host/download_resource_handler.cc2
-rw-r--r--chrome/browser/renderer_host/download_resource_handler.h3
6 files changed, 18 insertions, 3 deletions
diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc
index f870451..c496361 100644
--- a/chrome/browser/download/download_item.cc
+++ b/chrome/browser/download/download_item.cc
@@ -79,6 +79,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
full_path_(info.path),
path_uniquifier_(0),
url_(info.url),
+ original_url_(info.original_url),
referrer_url_(info.referrer_url),
mime_type_(info.mime_type),
original_mime_type_(info.original_mime_type),
@@ -115,6 +116,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
full_path_(info.path),
path_uniquifier_(info.path_uniquifier),
url_(info.url),
+ original_url_(info.original_url),
referrer_url_(info.referrer_url),
mime_type_(info.mime_type),
original_mime_type_(info.original_mime_type),
@@ -150,6 +152,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
full_path_(path),
path_uniquifier_(0),
url_(url),
+ original_url_(url),
referrer_url_(GURL()),
mime_type_(std::string()),
original_mime_type_(std::string()),
diff --git a/chrome/browser/download/download_item.h b/chrome/browser/download/download_item.h
index 7471994..bc32f63 100644
--- a/chrome/browser/download/download_item.h
+++ b/chrome/browser/download/download_item.h
@@ -188,6 +188,7 @@ class DownloadItem {
FilePath full_path() const { return full_path_; }
void set_path_uniquifier(int uniquifier) { path_uniquifier_ = uniquifier; }
GURL url() const { return url_; }
+ GURL original_url() const { return original_url_; }
GURL referrer_url() const { return referrer_url_; }
std::string mime_type() const { return mime_type_; }
std::string original_mime_type() const { return original_mime_type_; }
@@ -256,9 +257,13 @@ class DownloadItem {
// path should be used as is.
int path_uniquifier_;
- // The URL from whence we came.
+ // The URL from which we are downloading. This is the final URL after any
+ // redirection by the server for |original_url_|.
GURL url_;
+ // The original URL before any redirection by the server for this URL.
+ GURL original_url_;
+
// The URL of the page that initiated the download.
GURL referrer_url_;
diff --git a/chrome/browser/download/drag_download_file.cc b/chrome/browser/download/drag_download_file.cc
index 3426ef7..004e185 100644
--- a/chrome/browser/download/drag_download_file.cc
+++ b/chrome/browser/download/drag_download_file.cc
@@ -155,7 +155,7 @@ void DragDownloadFile::ModelChanged() {
download_manager_->GetTemporaryDownloads(file_path_.DirName(), &downloads);
for (std::vector<DownloadItem*>::const_iterator i = downloads.begin();
i != downloads.end(); ++i) {
- if (!download_item_observer_added_ && (*i)->url() == url_) {
+ if (!download_item_observer_added_ && (*i)->original_url() == url_) {
download_item_observer_added_ = true;
(*i)->AddObserver(this);
}
diff --git a/chrome/browser/history/download_create_info.h b/chrome/browser/history/download_create_info.h
index 49ac635..0814350 100644
--- a/chrome/browser/history/download_create_info.h
+++ b/chrome/browser/history/download_create_info.h
@@ -36,7 +36,11 @@ struct DownloadCreateInfo {
// DownloadItem fields
FilePath path;
+ // The URL from which we are downloading. This is the final URL after any
+ // redirection by the server for |original_url_|.
GURL url;
+ // The original URL before any redirection by the server for this URL.
+ GURL original_url;
GURL referrer_url;
FilePath suggested_path;
// A number that should be added to the suggested path to make it unique.
diff --git a/chrome/browser/renderer_host/download_resource_handler.cc b/chrome/browser/renderer_host/download_resource_handler.cc
index a75ae97..b186c01 100644
--- a/chrome/browser/renderer_host/download_resource_handler.cc
+++ b/chrome/browser/renderer_host/download_resource_handler.cc
@@ -36,6 +36,7 @@ DownloadResourceHandler::DownloadResourceHandler(
global_id_(render_process_host_id, request_id),
render_view_id_(render_view_id),
url_(url),
+ original_url_(url),
content_length_(0),
download_file_manager_(download_file_manager),
request_(request),
@@ -124,6 +125,7 @@ bool DownloadResourceHandler::OnResponseStarted(int request_id,
// |download_file_manager_| consumes (deletes):
DownloadCreateInfo* info = new DownloadCreateInfo;
info->url = url_;
+ info->original_url = original_url_;
info->referrer_url = GURL(request_->referrer());
info->start_time = base::Time::Now();
info->received_bytes = 0;
diff --git a/chrome/browser/renderer_host/download_resource_handler.h b/chrome/browser/renderer_host/download_resource_handler.h
index bc26989..8301a77 100644
--- a/chrome/browser/renderer_host/download_resource_handler.h
+++ b/chrome/browser/renderer_host/download_resource_handler.h
@@ -102,7 +102,8 @@ class DownloadResourceHandler : public ResourceHandler,
int render_view_id_;
scoped_refptr<net::IOBuffer> read_buffer_;
std::string content_disposition_;
- GURL url_;
+ GURL url_; // final URL from which we're downloading.
+ GURL original_url_; // original URL before any redirection by the server.
int64 content_length_;
DownloadFileManager* download_file_manager_;
net::URLRequest* request_;