Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3466)

Unified Diff: chrome/browser/download/download_file_picker.cc

Issue 10704052: Download filename determination refactor (3/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r148594 to and resolve conflicts with r148576 Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_file_picker.cc
diff --git a/chrome/browser/download/download_file_picker.cc b/chrome/browser/download/download_file_picker.cc
index c115cab2da8e40b4c35c470c1ed340da72366f49..cb47b2dd11775208dde5c918a4fc563d6b4eddf5 100644
--- a/chrome/browser/download/download_file_picker.cc
+++ b/chrome/browser/download/download_file_picker.cc
@@ -58,11 +58,15 @@ FilePickerResult ComparePaths(const FilePath& suggested_path,
DownloadFilePicker::DownloadFilePicker() : download_id_(0) {
}
-void DownloadFilePicker::Init(DownloadManager* download_manager,
- DownloadItem* item) {
+void DownloadFilePicker::Init(
+ DownloadManager* download_manager,
+ DownloadItem* item,
+ const FilePath& suggested_path,
+ const ChromeDownloadManagerDelegate::FileSelectedCallback& callback) {
download_manager_ = download_manager;
download_id_ = item->GetId();
- InitSuggestedPath(item);
+ file_selected_callback_ = callback;
+ InitSuggestedPath(item, suggested_path);
DCHECK(download_manager_);
WebContents* web_contents = item->GetWebContents();
@@ -93,8 +97,14 @@ void DownloadFilePicker::Init(DownloadManager* download_manager,
DownloadFilePicker::~DownloadFilePicker() {
}
-void DownloadFilePicker::InitSuggestedPath(DownloadItem* item) {
- set_suggested_path(item->GetTargetFilePath());
+void DownloadFilePicker::InitSuggestedPath(DownloadItem* item,
+ const FilePath& suggested_path) {
+ set_suggested_path(suggested_path);
+}
+
+void DownloadFilePicker::OnFileSelected(const FilePath& path) {
+ file_selected_callback_.Run(path);
+ delete this;
}
void DownloadFilePicker::RecordFileSelected(const FilePath& path) {
@@ -106,15 +116,12 @@ void DownloadFilePicker::FileSelected(const FilePath& path,
int index,
void* params) {
RecordFileSelected(path);
-
- if (download_manager_)
- download_manager_->FileSelected(path, download_id_);
- delete this;
+ OnFileSelected(path);
+ // Deletes |this|
}
void DownloadFilePicker::FileSelectionCanceled(void* params) {
RecordFilePickerResult(download_manager_, FILE_PICKER_CANCEL);
- if (download_manager_)
- download_manager_->FileSelectionCanceled(download_id_);
- delete this;
+ OnFileSelected(FilePath());
+ // Deletes |this|
}
« no previous file with comments | « chrome/browser/download/download_file_picker.h ('k') | chrome/browser/download/download_file_picker_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698