blob: ee8a27cc205ce0069a4ea2893f093d39d1883ad2 [file] [log] [blame]
[email protected]6474b112012-05-04 19:35:271// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]0ffaa482011-07-14 23:41:282// 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]0ffaa482011-07-14 23:41:287
[email protected]5cd985b62014-05-15 08:32:338#include <vector>
9
Keishi Hattori0e45c022021-11-27 09:25:5210#include "base/memory/raw_ptr.h"
[email protected]0ffaa482011-07-14 23:41:2811#include "base/memory/ref_counted.h"
[email protected]a53209b2012-01-20 16:48:1612#include "content/public/browser/download_manager_delegate.h"
[email protected]5cd985b62014-05-15 08:32:3313#include "content/public/browser/save_page_type.h"
[email protected]4344a3c2013-01-17 23:49:2014#include "ui/shell_dialogs/select_file_dialog.h"
[email protected]0ffaa482011-07-14 23:41:2815
[email protected]e7557f172011-08-19 23:42:0116class DownloadPrefs;
[email protected]0ffaa482011-07-14 23:41:2817
18// Handles showing a dialog to the user to ask for the filename to save a page.
[email protected]92f54082012-07-31 01:43:1419class SavePackageFilePicker : public ui::SelectFileDialog::Listener {
[email protected]0ffaa482011-07-14 23:41:2820 public:
Matt Falkenhagenafa58d42019-12-02 22:17:4021 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öm53c6c5952021-09-17 09:41:2627
28 SavePackageFilePicker(const SavePackageFilePicker&) = delete;
29 SavePackageFilePicker& operator=(const SavePackageFilePicker&) = delete;
30
dcheng0c8ba27e2014-10-21 12:00:5331 ~SavePackageFilePicker() override;
[email protected]0ffaa482011-07-14 23:41:2832
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.
dcheng0c8ba27e2014-10-21 12:00:5339 void FileSelected(const base::FilePath& path,
40 int index,
41 void* unused_params) override;
42 void FileSelectionCanceled(void* unused_params) override;
[email protected]6474b112012-05-04 19:35:2743
Felipe Cerqueira7c364912019-02-20 13:37:3944 bool ShouldSaveAsOnlyHTML(content::WebContents* web_contents) const;
[email protected]6474b112012-05-04 19:35:2745 bool ShouldSaveAsMHTML() const;
[email protected]0ffaa482011-07-14 23:41:2846
[email protected]a53209b2012-01-20 16:48:1647 // Used to look up the renderer process for this request to get the context.
48 int render_process_id_;
49
[email protected]6474b112012-05-04 19:35:2750 // Whether the web page can be saved as a complete HTML file.
51 bool can_save_as_complete_;
52
Keishi Hattori0e45c022021-11-27 09:25:5253 raw_ptr<DownloadPrefs> download_prefs_;
[email protected]50641fcd2013-05-30 14:15:4554
[email protected]6474b112012-05-04 19:35:2755 content::SavePackagePathPickedCallback callback_;
[email protected]0ffaa482011-07-14 23:41:2856
[email protected]5cd985b62014-05-15 08:32:3357 std::vector<content::SavePageType> save_types_;
58
[email protected]0ffaa482011-07-14 23:41:2859 // For managing select file dialogs.
[email protected]92f54082012-07-31 01:43:1460 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
[email protected]0ffaa482011-07-14 23:41:2861};
62
63#endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_