summaryrefslogtreecommitdiffstats
path: root/content/browser/download/base_file.cc
diff options
context:
space:
mode:
authorasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-15 22:21:01 +0000
committerasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-15 22:21:01 +0000
commit96bfed051ed8212813567b20663a4591d3b4e0e2 (patch)
treee4fea300a4504a24d089831972499f3a69a7050d /content/browser/download/base_file.cc
parentd63b4c7e7e2e2b0b91d16e3acd11dc3b816c54fd (diff)
downloadchromium_src-96bfed051ed8212813567b20663a4591d3b4e0e2.zip
chromium_src-96bfed051ed8212813567b20663a4591d3b4e0e2.tar.gz
chromium_src-96bfed051ed8212813567b20663a4591d3b4e0e2.tar.bz2
Use the user's preferred downloads directory for creating the initial download file.
BUG=132240 Review URL: https://chromiumcodereview.appspot.com/10905284 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/download/base_file.cc')
-rw-r--r--content/browser/download/base_file.cc15
1 files changed, 10 insertions, 5 deletions
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 1d5d1e2..6ada5c8 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -245,15 +245,21 @@ BaseFile::~BaseFile() {
Cancel(); // Will delete the file.
}
-net::Error BaseFile::Initialize() {
+net::Error BaseFile::Initialize(const FilePath& default_directory) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
if (full_path_.empty()) {
+ FilePath initial_directory(default_directory);
FilePath temp_file;
- FilePath download_dir =
- content::GetContentClient()->browser()->GetDefaultDownloadDirectory();
- if (!file_util::CreateTemporaryFileInDir(download_dir, &temp_file) &&
+ if (initial_directory.empty()) {
+ initial_directory =
+ content::GetContentClient()->browser()->GetDefaultDownloadDirectory();
+ }
+ // |initial_directory| can still be empty if ContentBrowserClient returned
+ // an empty path for the downloads directory.
+ if ((initial_directory.empty() ||
+ !file_util::CreateTemporaryFileInDir(initial_directory, &temp_file)) &&
!file_util::CreateTemporaryFile(&temp_file)) {
return LOG_ERROR("unable to create", net::ERR_FILE_NOT_FOUND);
}
@@ -557,4 +563,3 @@ int64 BaseFile::CurrentSpeed() const {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
return CurrentSpeedAtTime(base::TimeTicks::Now());
}
-