diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 09:49:11 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-05 09:49:11 +0000 |
commit | 5a3b97e598fe61c81080de167c226b09cfe9cdbd (patch) | |
tree | 0800eeb36e16b1e91103baafce8a548cee609538 /chrome/browser/download | |
parent | c0af21786f2d24e7dd11a0500a498c584b237123 (diff) | |
download | chromium_src-5a3b97e598fe61c81080de167c226b09cfe9cdbd.zip chromium_src-5a3b97e598fe61c81080de167c226b09cfe9cdbd.tar.gz chromium_src-5a3b97e598fe61c81080de167c226b09cfe9cdbd.tar.bz2 |
Create the default download directory when a download is starting.
BUG=56021
TEST=see bug
Review URL: http://codereview.chromium.org/3425020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r-- | chrome/browser/download/download_manager.cc | 15 | ||||
-rw-r--r-- | chrome/browser/download/download_manager.h | 3 |
2 files changed, 15 insertions, 3 deletions
diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 88743f0..a0e6dea 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -309,16 +309,27 @@ void DownloadManager::StartDownload(DownloadCreateInfo* info) { // We need to move over to the download thread because we don't want to stat // the suggested path on the UI thread. + // We can only access preferences on the UI thread, so check the download path + // now and pass the value to the FILE thread. ChromeThread::PostTask( ChromeThread::FILE, FROM_HERE, NewRunnableMethod( - this, &DownloadManager::CheckIfSuggestedPathExists, info)); + this, + &DownloadManager::CheckIfSuggestedPathExists, + info, + download_prefs()->download_path())); } -void DownloadManager::CheckIfSuggestedPathExists(DownloadCreateInfo* info) { +void DownloadManager::CheckIfSuggestedPathExists(DownloadCreateInfo* info, + const FilePath& default_path) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); DCHECK(info); + // Make sure the default download directory exists. + // TODO(phajdan.jr): only create the directory when we're sure the user + // is going to save there and not to another directory of his choice. + file_util::CreateDirectory(default_path); + // Check writability of the suggested path. If we can't write to it, default // to the user's "My Documents" directory. We'll prompt them in this case. FilePath dir = info->suggested_path.DirName(); diff --git a/chrome/browser/download/download_manager.h b/chrome/browser/download/download_manager.h index 02c7aa1..9739ccf 100644 --- a/chrome/browser/download/download_manager.h +++ b/chrome/browser/download/download_manager.h @@ -233,7 +233,8 @@ class DownloadManager // Called on the download thread to check whether the suggested file path // exists. We don't check if the file exists on the UI thread to avoid UI // stalls from interacting with the file system. - void CheckIfSuggestedPathExists(DownloadCreateInfo* info); + void CheckIfSuggestedPathExists(DownloadCreateInfo* info, + const FilePath& default_path); // Called on the UI thread once the DownloadManager has determined whether the // suggested file path exists. |