Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/browser/download/download_manager.cc

Issue 83002: download filename fix (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/download/download_manager.h" 5 #include "chrome/browser/download/download_manager.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 int DownloadManager::RemoveAllDownloads() { 1078 int DownloadManager::RemoveAllDownloads() {
1079 // The null times make the date range unbounded. 1079 // The null times make the date range unbounded.
1080 return RemoveDownloadsBetween(base::Time(), base::Time()); 1080 return RemoveDownloadsBetween(base::Time(), base::Time());
1081 } 1081 }
1082 1082
1083 // Initiate a download of a specific URL. We send the request to the 1083 // Initiate a download of a specific URL. We send the request to the
1084 // ResourceDispatcherHost, and let it send us responses like a regular 1084 // ResourceDispatcherHost, and let it send us responses like a regular
1085 // download. 1085 // download.
1086 void DownloadManager::DownloadUrl(const GURL& url, 1086 void DownloadManager::DownloadUrl(const GURL& url,
1087 const GURL& referrer, 1087 const GURL& referrer,
1088 const std::string& referrer_charset,
1088 WebContents* web_contents) { 1089 WebContents* web_contents) {
1089 DCHECK(web_contents); 1090 DCHECK(web_contents);
1091 request_context_->set_referrer_charset(referrer_charset);
1090 file_manager_->DownloadUrl(url, 1092 file_manager_->DownloadUrl(url,
1091 referrer, 1093 referrer,
1092 web_contents->process()->pid(), 1094 web_contents->process()->pid(),
1093 web_contents->render_view_host()->routing_id(), 1095 web_contents->render_view_host()->routing_id(),
1094 request_context_.get()); 1096 request_context_.get());
1095 } 1097 }
1096 1098
1097 void DownloadManager::GenerateExtension( 1099 void DownloadManager::GenerateExtension(
1098 const FilePath& file_name, 1100 const FilePath& file_name,
1099 const std::string& mime_type, 1101 const std::string& mime_type,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 } 1174 }
1173 1175
1174 generated_extension->swap(extension); 1176 generated_extension->swap(extension);
1175 } 1177 }
1176 1178
1177 void DownloadManager::GenerateFilename(DownloadCreateInfo* info, 1179 void DownloadManager::GenerateFilename(DownloadCreateInfo* info,
1178 FilePath* generated_name) { 1180 FilePath* generated_name) {
1179 *generated_name = FilePath::FromWStringHack( 1181 *generated_name = FilePath::FromWStringHack(
1180 net::GetSuggestedFilename(GURL(info->url), 1182 net::GetSuggestedFilename(GURL(info->url),
1181 info->content_disposition, 1183 info->content_disposition,
1184 info->referrer_charset,
1182 L"download")); 1185 L"download"));
1183 DCHECK(!generated_name->empty()); 1186 DCHECK(!generated_name->empty());
1184 1187
1185 GenerateSafeFilename(info->mime_type, generated_name); 1188 GenerateSafeFilename(info->mime_type, generated_name);
1186 } 1189 }
1187 1190
1188 void DownloadManager::AddObserver(Observer* observer) { 1191 void DownloadManager::AddObserver(Observer* observer) {
1189 observers_.AddObserver(observer); 1192 observers_.AddObserver(observer);
1190 observer->ModelChanged(); 1193 observer->ModelChanged();
1191 } 1194 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 searched_downloads.push_back(dit->second); 1495 searched_downloads.push_back(dit->second);
1493 } 1496 }
1494 1497
1495 requestor->SetDownloads(searched_downloads); 1498 requestor->SetDownloads(searched_downloads);
1496 } 1499 }
1497 1500
1498 // Clears the last download path, used to initialize "save as" dialogs. 1501 // Clears the last download path, used to initialize "save as" dialogs.
1499 void DownloadManager::ClearLastDownloadPath() { 1502 void DownloadManager::ClearLastDownloadPath() {
1500 last_download_path_ = FilePath(); 1503 last_download_path_ = FilePath();
1501 } 1504 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.h ('k') | chrome/browser/download/download_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698