Index: chrome/browser/download/save_package_file_picker_chromeos.cc |
diff --git a/chrome/browser/download/save_package_file_picker_chromeos.cc b/chrome/browser/download/save_package_file_picker_chromeos.cc |
index 6f9f341452fb4725b68e964d7c070a36bc4c057a..9bdd2649e6c206693ce8626b58ee30149ae5259c 100644 |
--- a/chrome/browser/download/save_package_file_picker_chromeos.cc |
+++ b/chrome/browser/download/save_package_file_picker_chromeos.cc |
@@ -13,6 +13,7 @@ |
#include "chrome/browser/platform_util.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/ui/chrome_select_file_policy.h" |
+#include "chrome/common/pref_names.h" |
#include "content/public/browser/download_item.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_view.h" |
@@ -27,22 +28,18 @@ bool g_should_prompt_for_filename = true; |
// Trampoline callback between SubstituteDriveDownloadPath() and |callback|. |
void ContinueSettingUpDriveDownload( |
const content::SavePackagePathPickedCallback& callback, |
- bool is_html, |
+ content::SavePageType save_type, |
Profile* profile, |
const base::FilePath& drive_path, |
const base::FilePath& drive_tmp_download_path) { |
if (drive_tmp_download_path.empty()) // Substitution failed. |
return; |
- callback.Run( |
- drive_tmp_download_path, |
- (is_html ? |
- content::SAVE_PAGE_TYPE_AS_MHTML : |
- content::SAVE_PAGE_TYPE_AS_ONLY_HTML), |
- base::Bind(&drive::DownloadHandler::SetDownloadParams, |
- base::Unretained( |
- drive::DownloadHandler::GetForProfile(profile)), |
- drive_path)); |
+ content::SavePackageDownloadCreatedCallback download_created = base::Bind( |
+ &drive::DownloadHandler::SetDownloadParams, |
+ base::Unretained(drive::DownloadHandler::GetForProfile(profile)), |
+ drive_path); |
+ callback.Run(drive_tmp_download_path, save_type, download_created); |
} |
} // namespace |
@@ -51,13 +48,15 @@ SavePackageFilePickerChromeOS::SavePackageFilePickerChromeOS( |
content::WebContents* web_contents, |
const base::FilePath& suggested_path, |
bool is_html, |
+ const base::Callback<void(const base::FilePath&)>& on_chosen, |
const content::SavePackagePathPickedCallback& callback) |
: content::WebContentsObserver(web_contents), |
+ on_chosen_(on_chosen), |
callback_(callback), |
- is_html_(is_html) { |
- base::FilePath suggested_path_copy(is_html_ ? |
- suggested_path.ReplaceExtension("mhtml") : |
- suggested_path); |
+ save_type_(is_html ? content::SAVE_PAGE_TYPE_AS_MHTML : |
+ content::SAVE_PAGE_TYPE_AS_ONLY_HTML) { |
+ base::FilePath suggested_path_copy( |
+ is_html ? suggested_path.ReplaceExtension("mhtml") : suggested_path); |
if (g_should_prompt_for_filename) { |
select_file_dialog_ = ui::SelectFileDialog::Create( |
this, new ChromeSelectFilePolicy(web_contents)); |
@@ -108,6 +107,8 @@ void SavePackageFilePickerChromeOS::FileSelectedWithExtraInfo( |
web_contents()->GetBrowserContext()); |
DCHECK(profile); |
+ on_chosen_.Run(selected_path); |
+ |
if (drive::util::IsUnderDriveMountPoint(selected_path)) { |
// Here's a map to the callback chain: |
// SubstituteDriveDownloadPath -> |
@@ -121,14 +122,12 @@ void SavePackageFilePickerChromeOS::FileSelectedWithExtraInfo( |
SubstituteDriveDownloadPath(selected_path, NULL, |
base::Bind(&ContinueSettingUpDriveDownload, |
callback_, |
- is_html_, |
+ save_type_, |
profile, |
selected_path)); |
} else { |
callback_.Run(selected_path, |
- (is_html_ ? |
- content::SAVE_PAGE_TYPE_AS_MHTML : |
- content::SAVE_PAGE_TYPE_AS_ONLY_HTML), |
+ save_type_, |
content::SavePackageDownloadCreatedCallback()); |
} |
delete this; |