summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-14 23:08:14 +0000
committerpaulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-14 23:08:14 +0000
commitbb69e9b391b68274089c5a6148548683af54bb19 (patch)
tree906dfe005c3b3ebf1765deaa8fd6f7326f0fe745
parent5656af67903d044c131bc07ebf41e0fc20bf1f29 (diff)
downloadchromium_src-bb69e9b391b68274089c5a6148548683af54bb19.zip
chromium_src-bb69e9b391b68274089c5a6148548683af54bb19.tar.gz
chromium_src-bb69e9b391b68274089c5a6148548683af54bb19.tar.bz2
Ensure that the default download directory exists when the
DownloadManager is initialized. BUG=1324355 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@907 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/download_file.cc5
-rw-r--r--chrome/browser/download_file.h4
-rw-r--r--chrome/browser/download_manager.cc4
3 files changed, 13 insertions, 0 deletions
diff --git a/chrome/browser/download_file.cc b/chrome/browser/download_file.cc
index 5f8ab12..032d701 100644
--- a/chrome/browser/download_file.cc
+++ b/chrome/browser/download_file.cc
@@ -609,3 +609,8 @@ void DownloadFileManager::OnFinalDownloadName(int id,
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &DownloadFileManager::StopUpdateTimer));
}
+
+void DownloadFileManager::CreateDirectory(const std::wstring& directory) {
+ if (!file_util::PathExists(directory))
+ file_util::CreateDirectory(directory);
+} \ No newline at end of file
diff --git a/chrome/browser/download_file.h b/chrome/browser/download_file.h
index 53be7c2..398a920 100644
--- a/chrome/browser/download_file.h
+++ b/chrome/browser/download_file.h
@@ -233,6 +233,10 @@ class DownloadFileManager
MessageLoop* file_loop() const { return file_loop_; }
+ // Called by the download manager at initialization to ensure the default
+ // download directory exists.
+ void CreateDirectory(const std::wstring& directory);
+
private:
// Timer helpers for updating the UI about the current progress of a download.
void StartUpdateTimer();
diff --git a/chrome/browser/download_manager.cc b/chrome/browser/download_manager.cc
index a919ee33..6fa8347 100644
--- a/chrome/browser/download_manager.cc
+++ b/chrome/browser/download_manager.cc
@@ -446,6 +446,10 @@ bool DownloadManager::Init(Profile* profile) {
default_download_path);
download_path_.Init(prefs::kDownloadDefaultDirectory, prefs, NULL);
+ // Ensure that the download directory specified in the preferences exists.
+ file_loop_->PostTask(FROM_HERE, NewRunnableMethod(
+ file_manager_, &DownloadFileManager::CreateDirectory, *download_path_));
+
// We store any file extension that should be opened automatically at
// download completion in this pref.
download_util::InitializeExeTypes(&exe_types_);