1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_
6 #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_
10 #include "base/memory/ref_counted.h"
11 #include "content/public/browser/download_manager_delegate.h"
12 #include "content/public/browser/save_page_type.h"
13 #include "ui/shell_dialogs/select_file_dialog.h"
17 // Handles showing a dialog to the user to ask for the filename to save a page.
18 class SavePackageFilePicker
: public ui::SelectFileDialog::Listener
{
20 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
);
27 ~SavePackageFilePicker() override
;
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
);
34 // SelectFileDialog::Listener implementation.
35 void FileSelected(const base::FilePath
& path
,
37 void* unused_params
) override
;
38 void FileSelectionCanceled(void* unused_params
) override
;
40 bool ShouldSaveAsMHTML() const;
42 // Used to look up the renderer process for this request to get the context.
43 int render_process_id_
;
45 // Whether the web page can be saved as a complete HTML file.
46 bool can_save_as_complete_
;
48 DownloadPrefs
* download_prefs_
;
50 content::SavePackagePathPickedCallback callback_
;
52 std::vector
<content::SavePageType
> save_types_
;
54 // For managing select file dialogs.
55 scoped_refptr
<ui::SelectFileDialog
> select_file_dialog_
;
57 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker
);
60 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_