blob: c14bb358bf3d12f3d77901a6c6e06252a189a1ef [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
avie4d7b6f2015-12-26 00:59:1810#include "base/macros.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);
dcheng0c8ba27e2014-10-21 12:00:5327 ~SavePackageFilePicker() override;
[email protected]0ffaa482011-07-14 23:41:2828
29 // Used to disable prompting the user for a directory/filename of the saved
30 // web page. This is available for testing.
31 static void SetShouldPromptUser(bool should_prompt);
32
33 private:
34 // SelectFileDialog::Listener implementation.
dcheng0c8ba27e2014-10-21 12:00:5335 void FileSelected(const base::FilePath& path,
36 int index,
37 void* unused_params) override;
38 void FileSelectionCanceled(void* unused_params) override;
[email protected]6474b112012-05-04 19:35:2739
Felipe Cerqueira7c364912019-02-20 13:37:3940 bool ShouldSaveAsOnlyHTML(content::WebContents* web_contents) const;
[email protected]6474b112012-05-04 19:35:2741 bool ShouldSaveAsMHTML() const;
[email protected]0ffaa482011-07-14 23:41:2842
[email protected]a53209b2012-01-20 16:48:1643 // Used to look up the renderer process for this request to get the context.
44 int render_process_id_;
45
[email protected]6474b112012-05-04 19:35:2746 // Whether the web page can be saved as a complete HTML file.
47 bool can_save_as_complete_;
48
[email protected]50641fcd2013-05-30 14:15:4549 DownloadPrefs* download_prefs_;
50
[email protected]6474b112012-05-04 19:35:2751 content::SavePackagePathPickedCallback callback_;
[email protected]0ffaa482011-07-14 23:41:2852
[email protected]5cd985b62014-05-15 08:32:3353 std::vector<content::SavePageType> save_types_;
54
[email protected]0ffaa482011-07-14 23:41:2855 // For managing select file dialogs.
[email protected]92f54082012-07-31 01:43:1456 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
[email protected]0ffaa482011-07-14 23:41:2857
58 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker);
59};
60
61#endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_