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

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: 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
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..13920fe0b59788b1012b8e169a72a6b16abfa16d 100644
--- a/content/browser/download/base_file.cc
+++ b/content/browser/download/base_file.cc
@@ -15,7 +15,6 @@
#include "content/browser/download/download_net_log_parameters.h"
#include "content/browser/download/download_stats.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/content_browser_client.h"
#include "crypto/secure_hash.h"
#include "net/base/file_stream.h"
#include "net/base/net_errors.h"
@@ -203,7 +202,8 @@ net::Error RenameFileAndResetSecurityDescriptor(
// This will initialize the entire array to zero.
const unsigned char BaseFile::kEmptySha256Hash[] = { 0 };
-BaseFile::BaseFile(const FilePath& full_path,
+BaseFile::BaseFile(const FilePath& download_directory,
+ const FilePath& full_path,
const GURL& source_url,
const GURL& referrer_url,
int64 received_bytes,
@@ -211,7 +211,8 @@ BaseFile::BaseFile(const FilePath& full_path,
const std::string& hash_state,
const linked_ptr<net::FileStream>& file_stream,
const net::BoundNetLog& bound_net_log)
- : full_path_(full_path),
+ : download_directory_(download_directory),
+ full_path_(full_path),
source_url_(source_url),
referrer_url_(referrer_url),
file_stream_(file_stream),
@@ -248,12 +249,11 @@ BaseFile::~BaseFile() {
net::Error BaseFile::Initialize() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
DCHECK(!detached_);
+ DCHECK(!full_path_.empty() || !download_directory_.empty());
if (full_path_.empty()) {
FilePath temp_file;
- FilePath download_dir =
- content::GetContentClient()->browser()->GetDefaultDownloadDirectory();
- if (!file_util::CreateTemporaryFileInDir(download_dir, &temp_file) &&
+ if (!file_util::CreateTemporaryFileInDir(download_directory_, &temp_file) &&
!file_util::CreateTemporaryFile(&temp_file)) {
return LOG_ERROR("unable to create", net::ERR_FILE_NOT_FOUND);
}

Powered by Google App Engine
This is Rietveld 408576698