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_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_CHROMEOS_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_CHROMEOS_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_CHROMEOS_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "content/public/browser/download_manager_delegate.h" | 9 #include "content/public/browser/download_manager_delegate.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
11 #include "ui/shell_dialogs/select_file_dialog.h" | 11 #include "ui/shell_dialogs/select_file_dialog.h" |
12 | 12 |
13 namespace ui { | 13 namespace ui { |
14 struct SelectedFileInfo; | 14 struct SelectedFileInfo; |
15 } | 15 } |
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 // on ChromeOS. | 18 // on ChromeOS. |
19 class SavePackageFilePickerChromeOS : public ui::SelectFileDialog::Listener, | 19 class SavePackageFilePickerChromeOS : public ui::SelectFileDialog::Listener, |
20 public content::WebContentsObserver { | 20 public content::WebContentsObserver { |
21 public: | 21 public: |
22 SavePackageFilePickerChromeOS( | 22 SavePackageFilePickerChromeOS( |
23 content::WebContents* web_contents, | 23 content::WebContents* web_contents, |
24 const base::FilePath& suggested_path, | 24 const base::FilePath& suggested_path, |
25 bool is_html, | 25 bool is_html, |
| 26 const base::Callback<void(const base::FilePath&)>& on_chosen, |
26 const content::SavePackagePathPickedCallback& callback); | 27 const content::SavePackagePathPickedCallback& callback); |
27 | 28 |
28 // 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 |
29 // web page. This is available for testing. | 30 // web page. This is available for testing. |
30 static void SetShouldPromptUser(bool should_prompt); | 31 static void SetShouldPromptUser(bool should_prompt); |
31 | 32 |
32 private: | 33 private: |
33 virtual ~SavePackageFilePickerChromeOS(); | 34 virtual ~SavePackageFilePickerChromeOS(); |
34 | 35 |
35 // SelectFileDialog::Listener implementation. | 36 // SelectFileDialog::Listener implementation. |
36 virtual void FileSelected(const base::FilePath& selected_path, | 37 virtual void FileSelected(const base::FilePath& selected_path, |
37 int unused_index, | 38 int unused_index, |
38 void* unused_params) OVERRIDE; | 39 void* unused_params) OVERRIDE; |
39 virtual void FileSelectedWithExtraInfo( | 40 virtual void FileSelectedWithExtraInfo( |
40 const ui::SelectedFileInfo& selected_file_info, | 41 const ui::SelectedFileInfo& selected_file_info, |
41 int unused_index, | 42 int unused_index, |
42 void* unused_params) OVERRIDE; | 43 void* unused_params) OVERRIDE; |
43 virtual void FileSelectionCanceled(void* params) OVERRIDE; | 44 virtual void FileSelectionCanceled(void* params) OVERRIDE; |
44 | 45 |
| 46 base::Callback<void(const base::FilePath&)> on_chosen_; |
45 content::SavePackagePathPickedCallback callback_; | 47 content::SavePackagePathPickedCallback callback_; |
46 bool is_html_; | 48 content::SavePageType save_type_; |
47 | 49 |
48 // For managing select file dialogs. | 50 // For managing select file dialogs. |
49 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | 51 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
50 base::FilePath selected_path_; | 52 base::FilePath selected_path_; |
51 | 53 |
52 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePickerChromeOS); | 54 DISALLOW_COPY_AND_ASSIGN(SavePackageFilePickerChromeOS); |
53 }; | 55 }; |
54 | 56 |
55 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_CHROMEOS_H_ | 57 #endif // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_CHROMEOS_H_ |
OLD | NEW |