| OLD | NEW |
| 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 class DownloadManager; | 19 class DownloadManager; |
| 19 class WebContents; | 20 class WebContents; |
| 20 } | 21 } |
| 21 | 22 |
| 22 // Handles showing a dialog to the user to ask for the filename for a download. | 23 // Handles showing a dialog to the user to ask for the filename for a download. |
| 23 class DownloadFilePicker : public ui::SelectFileDialog::Listener { | 24 class DownloadFilePicker : public ui::SelectFileDialog::Listener { |
| 24 public: | 25 public: |
| 25 // Callback used to pass the user selection back to the owner of this | 26 // Callback used to pass the user selection back to the owner of this |
| 26 // object. | 27 // object. |
| 27 // |virtual_path|: The path chosen by the user. If the user cancels the file | 28 // |virtual_path|: The path chosen by the user. If the user cancels the file |
| 28 // selection, then this parameter will be the empty path. On Chrome OS, | 29 // selection, then this parameter will be the empty path. On Chrome OS, |
| 29 // this path may contain virtual mount points if the user chose a virtual | 30 // this path may contain virtual mount points if the user chose a virtual |
| 30 // path (e.g. Google Drive). | 31 // path (e.g. Google Drive). |
| 31 typedef base::Callback<void(const base::FilePath& virtual_path)> | 32 typedef base::Callback<void(DownloadConfirmationResult, |
| 33 const base::FilePath& virtual_path)> |
| 32 FileSelectedCallback; | 34 FileSelectedCallback; |
| 33 | 35 |
| 34 // Display a file picker dialog for |item|. The |suggested_path| will be used | 36 // Display a file picker dialog for |item|. The |suggested_path| will be used |
| 35 // as the initial path displayed to the user. |callback| will always be | 37 // as the initial path displayed to the user. |callback| will always be |
| 36 // invoked even if |item| is destroyed prior to the file picker completing. | 38 // invoked even if |item| is destroyed prior to the file picker completing. |
| 37 static void ShowFilePicker(content::DownloadItem* item, | 39 static void ShowFilePicker(content::DownloadItem* item, |
| 38 const base::FilePath& suggested_path, | 40 const base::FilePath& suggested_path, |
| 39 const FileSelectedCallback& callback); | 41 const FileSelectedCallback& callback); |
| 40 | 42 |
| 41 private: | 43 private: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 64 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 66 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| 65 | 67 |
| 66 // True if UMA regarding on the result of the file selection should be | 68 // True if UMA regarding on the result of the file selection should be |
| 67 // recorded. | 69 // recorded. |
| 68 bool should_record_file_picker_result_; | 70 bool should_record_file_picker_result_; |
| 69 | 71 |
| 70 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker); | 72 DISALLOW_COPY_AND_ASSIGN(DownloadFilePicker); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ | 75 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_FILE_PICKER_H_ |
| OLD | NEW |