| Index: content/browser/download/save_package.cc
|
| diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc
|
| index 00cf6c63aa405b0f4405e9cd180d56732c4ff185..ee1ee0f6a6c3601f14128419ac1e630884491136 100644
|
| --- a/content/browser/download/save_package.cc
|
| +++ b/content/browser/download/save_package.cc
|
| @@ -1153,6 +1153,8 @@ const FilePath::CharType* SavePackage::ExtensionForMimeType(
|
| }
|
|
|
| void SavePackage::GetSaveInfo() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| // Can't use tab_contents_ in the file thread, so get the data that we need
|
| // before calling to it.
|
| FilePath website_save_dir, download_save_dir;
|
| @@ -1173,17 +1175,15 @@ void SavePackage::CreateDirectoryOnFileThread(
|
| const FilePath& download_save_dir,
|
| const std::string& mime_type,
|
| const std::string& accept_langs) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| +
|
| + FilePath default_downloads_dir =
|
| + download_util::GetDefaultDownloadDirectoryFromPathService();
|
| FilePath save_dir;
|
| - // If the default html/websites save folder doesn't exist...
|
| - if (!file_util::DirectoryExists(website_save_dir)) {
|
| - // If the default download dir doesn't exist, create it.
|
| - if (!file_util::DirectoryExists(download_save_dir))
|
| - file_util::CreateDirectory(download_save_dir);
|
| - save_dir = download_save_dir;
|
| - } else {
|
| - // If it does exist, use the default save dir param.
|
| - save_dir = website_save_dir;
|
| - }
|
| + // Ignores the returned value since the select file dialog should be
|
| + // displayed in any case.
|
| + download_util::ChooseSavableDirectory(
|
| + website_save_dir, download_save_dir, default_downloads_dir, &save_dir);
|
|
|
| bool can_save_as_complete = CanSaveAsComplete(mime_type);
|
| FilePath suggested_filename = GetSuggestedNameForSaveAs(
|
| @@ -1213,6 +1213,8 @@ void SavePackage::CreateDirectoryOnFileThread(
|
|
|
| void SavePackage::ContinueGetSaveInfo(const FilePath& suggested_path,
|
| bool can_save_as_complete) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| // The TabContents which owns this SavePackage may have disappeared during
|
| // the UI->FILE->UI thread hop of
|
| // GetSaveInfo->CreateDirectoryOnFileThread->ContinueGetSaveInfo.
|
| @@ -1226,6 +1228,8 @@ void SavePackage::ContinueGetSaveInfo(const FilePath& suggested_path,
|
| // Called after the save file dialog box returns.
|
| void SavePackage::OnPathPicked(const FilePath& final_name,
|
| SavePackageType type) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| // Ensure the filename is safe.
|
| saved_main_file_path_ = final_name;
|
| download_util::GenerateSafeFileName(tab_contents()->contents_mime_type(),
|
|
|