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

Unified Diff: content/browser/download/base_file.cc

Issue 10905284: Use the user's preferred downloads directory for creating the initial download file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows path check Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/download/base_file.h ('k') | content/browser/download/base_file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/base_file.cc
diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc
index 1d5d1e2e1ba3318bd7ae74a51a152d1d9508acbe..6ada5c8205123888fae51a78ce7973873acbe9e6 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());
}
-
« no previous file with comments | « content/browser/download/base_file.h ('k') | content/browser/download/base_file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698