[email protected] | 6474b11 | 2012-05-04 19:35:27 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ | ||||
6 | #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ | ||||
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 7 | |
[email protected] | 5cd985b6 | 2014-05-15 08:32:33 | [diff] [blame] | 8 | #include <vector> |
9 | |||||
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 10 | #include "base/memory/raw_ptr.h" |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 12 | #include "content/public/browser/download_manager_delegate.h" |
[email protected] | 5cd985b6 | 2014-05-15 08:32:33 | [diff] [blame] | 13 | #include "content/public/browser/save_page_type.h" |
[email protected] | 4344a3c | 2013-01-17 23:49:20 | [diff] [blame] | 14 | #include "ui/shell_dialogs/select_file_dialog.h" |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 15 | |
[email protected] | e7557f17 | 2011-08-19 23:42:01 | [diff] [blame] | 16 | class DownloadPrefs; |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 17 | |
18 | // Handles showing a dialog to the user to ask for the filename to save a page. | ||||
[email protected] | 92f5408 | 2012-07-31 01:43:14 | [diff] [blame] | 19 | class SavePackageFilePicker : public ui::SelectFileDialog::Listener { |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 20 | public: |
Matt Falkenhagen | afa58d4 | 2019-12-02 22:17:40 | [diff] [blame] | 21 | SavePackageFilePicker(content::WebContents* web_contents, |
22 | const base::FilePath& suggested_path, | ||||
23 | const base::FilePath::StringType& default_extension, | ||||
24 | bool can_save_as_complete, | ||||
25 | DownloadPrefs* download_prefs, | ||||
26 | content::SavePackagePathPickedCallback callback); | ||||
Peter Boström | 53c6c595 | 2021-09-17 09:41:26 | [diff] [blame] | 27 | |
28 | SavePackageFilePicker(const SavePackageFilePicker&) = delete; | ||||
29 | SavePackageFilePicker& operator=(const SavePackageFilePicker&) = delete; | ||||
30 | |||||
dcheng | 0c8ba27e | 2014-10-21 12:00:53 | [diff] [blame] | 31 | ~SavePackageFilePicker() override; |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 32 | |
33 | // Used to disable prompting the user for a directory/filename of the saved | ||||
34 | // web page. This is available for testing. | ||||
35 | static void SetShouldPromptUser(bool should_prompt); | ||||
36 | |||||
37 | private: | ||||
38 | // SelectFileDialog::Listener implementation. | ||||
dcheng | 0c8ba27e | 2014-10-21 12:00:53 | [diff] [blame] | 39 | void FileSelected(const base::FilePath& path, |
40 | int index, | ||||
41 | void* unused_params) override; | ||||
42 | void FileSelectionCanceled(void* unused_params) override; | ||||
[email protected] | 6474b11 | 2012-05-04 19:35:27 | [diff] [blame] | 43 | |
Felipe Cerqueira | 7c36491 | 2019-02-20 13:37:39 | [diff] [blame] | 44 | bool ShouldSaveAsOnlyHTML(content::WebContents* web_contents) const; |
[email protected] | 6474b11 | 2012-05-04 19:35:27 | [diff] [blame] | 45 | bool ShouldSaveAsMHTML() const; |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 46 | |
[email protected] | a53209b | 2012-01-20 16:48:16 | [diff] [blame] | 47 | // Used to look up the renderer process for this request to get the context. |
48 | int render_process_id_; | ||||
49 | |||||
[email protected] | 6474b11 | 2012-05-04 19:35:27 | [diff] [blame] | 50 | // Whether the web page can be saved as a complete HTML file. |
51 | bool can_save_as_complete_; | ||||
52 | |||||
Keishi Hattori | 0e45c02 | 2021-11-27 09:25:52 | [diff] [blame] | 53 | raw_ptr<DownloadPrefs> download_prefs_; |
[email protected] | 50641fcd | 2013-05-30 14:15:45 | [diff] [blame] | 54 | |
[email protected] | 6474b11 | 2012-05-04 19:35:27 | [diff] [blame] | 55 | content::SavePackagePathPickedCallback callback_; |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 56 | |
[email protected] | 5cd985b6 | 2014-05-15 08:32:33 | [diff] [blame] | 57 | std::vector<content::SavePageType> save_types_; |
58 | |||||
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 59 | // For managing select file dialogs. |
[email protected] | 92f5408 | 2012-07-31 01:43:14 | [diff] [blame] | 60 | scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
[email protected] | 0ffaa48 | 2011-07-14 23:41:28 | [diff] [blame] | 61 | }; |
62 | |||||
63 | #endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ |