diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/download_file.cc | 5 | ||||
-rw-r--r-- | chrome/browser/download_file.h | 4 | ||||
-rw-r--r-- | chrome/browser/download_manager.cc | 4 |
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_); |