blob: 4d24a7c0cf849fa10f2a0f766e4ec3aae772cab8 [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
[email protected]0ffaa482011-07-14 23:41:2810#include "base/memory/ref_counted.h"
[email protected]a53209b2012-01-20 16:48:1611#include "content/public/browser/download_manager_delegate.h"
[email protected]5cd985b62014-05-15 08:32:3312#include "content/public/browser/save_page_type.h"
[email protected]4344a3c2013-01-17 23:49:2013#include "ui/shell_dialogs/select_file_dialog.h"
[email protected]0ffaa482011-07-14 23:41:2814
[email protected]e7557f172011-08-19 23:42:0115class DownloadPrefs;
[email protected]0ffaa482011-07-14 23:41:2816
17// Handles showing a dialog to the user to ask for the filename to save a page.
[email protected]92f54082012-07-31 01:43:1418class SavePackageFilePicker : public ui::SelectFileDialog::Listener {
[email protected]0ffaa482011-07-14 23:41:2819 public:
[email protected]50641fcd2013-05-30 14:15:4520 SavePackageFilePicker(
21 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 const content::SavePackagePathPickedCallback& callback);
[email protected]d089c602011-07-14 23:49:5627 virtual ~SavePackageFilePicker();
[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.
[email protected]650b2d52013-02-10 03:41:4535 virtual void FileSelected(const base::FilePath& path,
[email protected]0d5c08e2011-11-21 16:51:0636 int index,
[email protected]6474b112012-05-04 19:35:2737 void* unused_params) OVERRIDE;
38 virtual void FileSelectionCanceled(void* unused_params) OVERRIDE;
39
40 bool ShouldSaveAsMHTML() const;
[email protected]0ffaa482011-07-14 23:41:2841
[email protected]a53209b2012-01-20 16:48:1642 // Used to look up the renderer process for this request to get the context.
43 int render_process_id_;
44
[email protected]6474b112012-05-04 19:35:2745 // Whether the web page can be saved as a complete HTML file.
46 bool can_save_as_complete_;
47
[email protected]50641fcd2013-05-30 14:15:4548 DownloadPrefs* download_prefs_;
49
[email protected]6474b112012-05-04 19:35:2750 content::SavePackagePathPickedCallback callback_;
[email protected]0ffaa482011-07-14 23:41:2851
[email protected]5cd985b62014-05-15 08:32:3352 std::vector<content::SavePageType> save_types_;
53
[email protected]0ffaa482011-07-14 23:41:2854 // For managing select file dialogs.
[email protected]92f54082012-07-31 01:43:1455 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
[email protected]0ffaa482011-07-14 23:41:2856
57 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker);
58};
59
60#endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_