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

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

Issue 12850002: Move download filename determintion into a separate class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 29a1573be53162504397c2b4ad8d6fd19eb9242d..8934db9ee13eb440184761c524a0f135f9212111 100644
--- a/chrome/browser/download/download_file_picker.cc
+++ b/chrome/browser/download/download_file_picker.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
+#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/download_manager.h"
#include "content/public/browser/web_contents.h"
@@ -56,15 +57,12 @@ FilePickerResult ComparePaths(const base::FilePath& suggested_path,
} // namespace
-DownloadFilePicker::DownloadFilePicker() : download_id_(0) {
-}
-
-void DownloadFilePicker::Init(
- DownloadManager* download_manager,
+DownloadFilePicker::DownloadFilePicker(
DownloadItem* item,
const base::FilePath& suggested_path,
- const ChromeDownloadManagerDelegate::FileSelectedCallback& callback) {
- download_manager_ = download_manager;
+ const FileSelectedCallback& callback) : download_id_(0) {
benjhayden 2013/04/09 15:46:32 Why not download_id_(item->GetId())?
asanka 2013/04/16 20:34:01 Done.
+ download_manager_ =
+ content::BrowserContext::GetDownloadManager(item->GetBrowserContext());
download_id_ = item->GetId();
file_selected_callback_ = callback;
InitSuggestedPath(item, suggested_path);
@@ -106,8 +104,9 @@ void DownloadFilePicker::InitSuggestedPath(
set_suggested_path(suggested_path);
}
-void DownloadFilePicker::OnFileSelected(const base::FilePath& path) {
- file_selected_callback_.Run(path);
+void DownloadFilePicker::OnFileSelected(const base::FilePath& virtual_path,
+ const base::FilePath& local_path) {
+ file_selected_callback_.Run(virtual_path, local_path);
delete this;
}
@@ -120,12 +119,22 @@ void DownloadFilePicker::FileSelected(const base::FilePath& path,
int index,
void* params) {
RecordFileSelected(path);
- OnFileSelected(path);
+ OnFileSelected(path, path);
// Deletes |this|
}
void DownloadFilePicker::FileSelectionCanceled(void* params) {
RecordFilePickerResult(download_manager_, FILE_PICKER_CANCEL);
- OnFileSelected(base::FilePath());
+ OnFileSelected(base::FilePath(), base::FilePath());
// Deletes |this|
}
+
+#if !defined(OS_CHROMEOS)
+// static
+void DownloadFilePicker::ShowFilePicker(DownloadItem* item,
+ const base::FilePath& suggested_path,
+ const FileSelectedCallback& callback) {
+ new DownloadFilePicker(item, suggested_path, callback);
+ // DownloadFilePicker deletes itself.
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698