blob: 90e898c7b36595d667ee7c691c3e96a4cbe13950 [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:
[email protected]50641fcd2013-05-30 14:15:4521 SavePackageFilePicker(
22 content::WebContents* web_contents,
23 const base::FilePath& suggested_path,
24 const base::FilePath::StringType& default_extension,
25 bool can_save_as_complete,
26 DownloadPrefs* download_prefs,
27 const content::SavePackagePathPickedCallback& callback);
dcheng0c8ba27e2014-10-21 12:00:5328 ~SavePackageFilePicker() override;
[email protected]0ffaa482011-07-14 23:41:2829
30 // Used to disable prompting the user for a directory/filename of the saved
31 // web page. This is available for testing.
32 static void SetShouldPromptUser(bool should_prompt);
33
34 private:
35 // SelectFileDialog::Listener implementation.
dcheng0c8ba27e2014-10-21 12:00:5336 void FileSelected(const base::FilePath& path,
37 int index,
38 void* unused_params) override;
39 void FileSelectionCanceled(void* unused_params) override;
[email protected]6474b112012-05-04 19:35:2740
Felipe Cerqueira7c364912019-02-20 13:37:3941 bool ShouldSaveAsOnlyHTML(content::WebContents* web_contents) const;
[email protected]6474b112012-05-04 19:35:2742 bool ShouldSaveAsMHTML() const;
[email protected]0ffaa482011-07-14 23:41:2843
[email protected]a53209b2012-01-20 16:48:1644 // Used to look up the renderer process for this request to get the context.
45 int render_process_id_;
46
[email protected]6474b112012-05-04 19:35:2747 // Whether the web page can be saved as a complete HTML file.
48 bool can_save_as_complete_;
49
[email protected]50641fcd2013-05-30 14:15:4550 DownloadPrefs* download_prefs_;
51
[email protected]6474b112012-05-04 19:35:2752 content::SavePackagePathPickedCallback callback_;
[email protected]0ffaa482011-07-14 23:41:2853
[email protected]5cd985b62014-05-15 08:32:3354 std::vector<content::SavePageType> save_types_;
55
[email protected]0ffaa482011-07-14 23:41:2856 // For managing select file dialogs.
[email protected]92f54082012-07-31 01:43:1457 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
[email protected]0ffaa482011-07-14 23:41:2858
59 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker);
60};
61
62#endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_