blob: fad058c94f506fa97ae49cb52ec46ddadf5e56c4 [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]0ffaa482011-07-14 23:41:288#include "base/memory/ref_counted.h"
[email protected]a53209b2012-01-20 16:48:169#include "content/public/browser/download_manager_delegate.h"
[email protected]92f54082012-07-31 01:43:1410#include "ui/base/dialogs/select_file_dialog.h"
[email protected]0ffaa482011-07-14 23:41:2811
[email protected]e7557f172011-08-19 23:42:0112class DownloadPrefs;
[email protected]0ffaa482011-07-14 23:41:2813
14// Handles showing a dialog to the user to ask for the filename to save a page.
[email protected]92f54082012-07-31 01:43:1415class SavePackageFilePicker : public ui::SelectFileDialog::Listener {
[email protected]0ffaa482011-07-14 23:41:2816 public:
[email protected]a53209b2012-01-20 16:48:1617 SavePackageFilePicker(content::WebContents* web_contents,
[email protected]0ffaa482011-07-14 23:41:2818 const FilePath& suggested_path,
[email protected]a53209b2012-01-20 16:48:1619 const FilePath::StringType& default_extension,
[email protected]e7557f172011-08-19 23:42:0120 bool can_save_as_complete,
[email protected]a53209b2012-01-20 16:48:1621 DownloadPrefs* download_prefs,
[email protected]6474b112012-05-04 19:35:2722 const content::SavePackagePathPickedCallback& callback);
[email protected]d089c602011-07-14 23:49:5623 virtual ~SavePackageFilePicker();
[email protected]0ffaa482011-07-14 23:41:2824
25 // Used to disable prompting the user for a directory/filename of the saved
26 // web page. This is available for testing.
27 static void SetShouldPromptUser(bool should_prompt);
28
29 private:
30 // SelectFileDialog::Listener implementation.
[email protected]0d5c08e2011-11-21 16:51:0631 virtual void FileSelected(const FilePath& path,
32 int index,
[email protected]6474b112012-05-04 19:35:2733 void* unused_params) OVERRIDE;
34 virtual void FileSelectionCanceled(void* unused_params) OVERRIDE;
35
36 bool ShouldSaveAsMHTML() const;
[email protected]0ffaa482011-07-14 23:41:2837
[email protected]a53209b2012-01-20 16:48:1638 // Used to look up the renderer process for this request to get the context.
39 int render_process_id_;
40
[email protected]6474b112012-05-04 19:35:2741 // Whether the web page can be saved as a complete HTML file.
42 bool can_save_as_complete_;
43
44 content::SavePackagePathPickedCallback callback_;
[email protected]0ffaa482011-07-14 23:41:2845
46 // For managing select file dialogs.
[email protected]92f54082012-07-31 01:43:1447 scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
[email protected]0ffaa482011-07-14 23:41:2848
49 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker);
50};
51
52#endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_