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

Side by Side Diff: chrome/browser/download/download_file_picker.h

Issue 2453633006: [downloads] Move platform specific code out of DownloadTargetDeterminer. (Closed)
Patch Set: . Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "chrome/browser/download/download_confirmation_result.h"
10 #include "ui/shell_dialogs/select_file_dialog.h" 11 #include "ui/shell_dialogs/select_file_dialog.h"
11 12
12 namespace base { 13 namespace base {
13 class FilePath; 14 class FilePath;
14 } 15 }
15 16
16 namespace content { 17 namespace content {
17 class DownloadItem; 18 class DownloadItem;
18 } 19 }
19 20
20 // Handles showing a dialog to the user to ask for the filename for a download. 21 // Handles showing a dialog to the user to ask for the filename for a download.
21 class DownloadFilePicker : public ui::SelectFileDialog::Listener { 22 class DownloadFilePicker : public ui::SelectFileDialog::Listener {
22 public: 23 public:
23 // Callback used to pass the user selection back to the owner of this 24 // Callback used to pass the user selection back to the owner of this
24 // object. 25 // object.
25 // |virtual_path|: The path chosen by the user. If the user cancels the file 26 // |virtual_path|: The path chosen by the user. If the user cancels the file
26 // selection, then this parameter will be the empty path. On Chrome OS, 27 // selection, then this parameter will be the empty path. On Chrome OS,
27 // this path may contain virtual mount points if the user chose a virtual 28 // this path may contain virtual mount points if the user chose a virtual
28 // path (e.g. Google Drive). 29 // path (e.g. Google Drive).
29 typedef base::Callback<void(const base::FilePath& virtual_path)> 30 typedef base::Callback<void(DownloadConfirmationResult,
30 FileSelectedCallback; 31 const base::FilePath& virtual_path)>
32 ConfirmationCallback;
31 33
32 // Display a file picker dialog for |item|. The |suggested_path| will be used 34 // Display a file picker dialog for |item|. The |suggested_path| will be used
33 // as the initial path displayed to the user. |callback| will always be 35 // as the initial path displayed to the user. |callback| will always be
34 // invoked even if |item| is destroyed prior to the file picker completing. 36 // invoked even if |item| is destroyed prior to the file picker completing.
35 static void ShowFilePicker(content::DownloadItem* item, 37 static void ShowFilePicker(content::DownloadItem* item,
36 const base::FilePath& suggested_path, 38 const base::FilePath& suggested_path,
37 const FileSelectedCallback& callback); 39 const ConfirmationCallback& callback);
38 40
39 private: 41 private:
40 DownloadFilePicker(content::DownloadItem* item, 42 DownloadFilePicker(content::DownloadItem* item,
41 const base::FilePath& suggested_path, 43 const base::FilePath& suggested_path,
42 const FileSelectedCallback& callback); 44 const ConfirmationCallback& callback);
43 ~DownloadFilePicker() override; 45 ~DownloadFilePicker() override;
44 46
45 // Runs |file_selected_callback_| with |virtual_path| and then deletes this 47 // Runs |file_selected_callback_| with |virtual_path| and then deletes this
46 // object. 48 // object.
47 void OnFileSelected(const base::FilePath& virtual_path); 49 void OnFileSelected(const base::FilePath& virtual_path);
48 50
49 // SelectFileDialog::Listener implementation. 51 // SelectFileDialog::Listener implementation.
50 void FileSelected(const base::FilePath& path, 52 void FileSelected(const base::FilePath& path,
51 int index, 53 int index,
52 void* params) override; 54 void* params) override;
53 void FileSelectionCanceled(void* params) override; 55 void FileSelectionCanceled(void* params) override;
54 56
55 // Initially suggested path. 57 // Initially suggested path.
56 base::FilePath suggested_path_; 58 base::FilePath suggested_path_;
57 59
58 // Callback invoked when a file selection is complete. 60 // Callback invoked when a file selection is complete.
59 FileSelectedCallback file_selected_callback_; 61 ConfirmationCallback file_selected_callback_;
60 62
61 // For managing select file dialogs. 63 // For managing select file dialogs.
62 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; 64 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
63 65
64 // True if UMA regarding on the result of the file selection should be 66 // True if UMA regarding on the result of the file selection should be
65 // recorded. 67 // recorded.
66 bool should_record_file_picker_result_; 68 bool should_record_file_picker_result_;
67 69
68 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker); 70 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker);
69 }; 71 };
70 72
71 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ 73 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_confirmation_result.h ('k') | chrome/browser/download/download_file_picker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698