OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "content/public/browser/download_manager_delegate.h" | 11 #include "content/public/browser/download_manager_delegate.h" |
12 #include "content/public/browser/save_page_type.h" | 12 #include "content/public/browser/save_page_type.h" |
13 #include "ui/shell_dialogs/select_file_dialog.h" | 13 #include "ui/shell_dialogs/select_file_dialog.h" |
14 | 14 |
15 class DownloadPrefs; | 15 class DownloadPrefs; |
16 | 16 |
17 // Handles showing a dialog to the user to ask for the filename to save a page. | 17 // Handles showing a dialog to the user to ask for the filename to save a page. |
18 class SavePackageFilePicker : public ui::SelectFileDialog::Listener { | 18 class SavePackageFilePicker : public ui::SelectFileDialog::Listener { |
19 public: | 19 public: |
20 SavePackageFilePicker( | 20 SavePackageFilePicker( |
21 content::WebContents* web_contents, | 21 content::WebContents* web_contents, |
22 const base::FilePath& suggested_path, | 22 const base::FilePath& suggested_path, |
23 const base::FilePath::StringType& default_extension, | 23 const base::FilePath::StringType& default_extension, |
24 bool can_save_as_complete, | 24 bool can_save_as_complete, |
25 DownloadPrefs* download_prefs, | 25 DownloadPrefs* download_prefs, |
26 const content::SavePackagePathPickedCallback& callback); | 26 const content::SavePackagePathPickedCallback& callback); |
27 virtual ~SavePackageFilePicker(); | 27 ~SavePackageFilePicker() override; |
28 | 28 |
29 // Used to disable prompting the user for a directory/filename of the saved | 29 // Used to disable prompting the user for a directory/filename of the saved |
30 // web page. This is available for testing. | 30 // web page. This is available for testing. |
31 static void SetShouldPromptUser(bool should_prompt); | 31 static void SetShouldPromptUser(bool should_prompt); |
32 | 32 |
33 private: | 33 private: |
34 // SelectFileDialog::Listener implementation. | 34 // SelectFileDialog::Listener implementation. |
35 virtual void FileSelected(const base::FilePath& path, | 35 void FileSelected(const base::FilePath& path, |
36 int index, | 36 int index, |
37 void* unused_params) override; | 37 void* unused_params) override; |
38 virtual void FileSelectionCanceled(void* unused_params) override; | 38 void FileSelectionCanceled(void* unused_params) override; |
39 | 39 |
40 bool ShouldSaveAsMHTML() const; | 40 bool ShouldSaveAsMHTML() const; |
41 | 41 |
42 // Used to look up the renderer process for this request to get the context. | 42 // Used to look up the renderer process for this request to get the context. |
43 int render_process_id_; | 43 int render_process_id_; |
44 | 44 |
45 // Whether the web page can be saved as a complete HTML file. | 45 // Whether the web page can be saved as a complete HTML file. |
46 bool can_save_as_complete_; | 46 bool can_save_as_complete_; |
47 | 47 |
48 DownloadPrefs* download_prefs_; | 48 DownloadPrefs* download_prefs_; |
49 | 49 |
50 content::SavePackagePathPickedCallback callback_; | 50 content::SavePackagePathPickedCallback callback_; |
51 | 51 |
52 std::vector<content::SavePageType> save_types_; | 52 std::vector<content::SavePageType> save_types_; |
53 | 53 |
54 // For managing select file dialogs. | 54 // For managing select file dialogs. |
55 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 55 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker); | 57 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker); |
58 }; | 58 }; |
59 | 59 |
60 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ | 60 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_ |
OLD | NEW |