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

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: Address comments 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..61a0826b18def5a420c97e0469b3941de6324903 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,16 +57,13 @@ 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;
- download_id_ = item->GetId();
+ const FileSelectedCallback& callback)
+ : download_id_(item->GetId()) {
+ download_manager_ =
+ content::BrowserContext::GetDownloadManager(item->GetBrowserContext());
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,25 @@ 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|
}
+
+DownloadFilePickerFactory::~DownloadFilePickerFactory() {
+}
+
+#if !defined(OS_CHROMEOS)
+void DownloadFilePickerFactory::Create(
+ DownloadItem* item,
+ const base::FilePath& suggested_path,
+ const DownloadFilePicker::FileSelectedCallback& callback) {
+ new DownloadFilePicker(item, suggested_path, callback);
+ // DownloadFilePicker deletes itself.
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698