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 #include "chrome/browser/download/save_package_file_picker.h" | 5 #include "chrome/browser/download/save_package_file_picker.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/prefs/public/pref_member.h" | 10 #include "base/prefs/public/pref_member.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 12 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
13 #include "chrome/browser/download/download_prefs.h" | 13 #include "chrome/browser/download/download_prefs.h" |
14 #include "chrome/browser/platform_util.h" | 14 #include "chrome/browser/platform_util.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/chrome_select_file_policy.h" | 16 #include "chrome/browser/ui/chrome_select_file_policy.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
19 #include "content/public/browser/download_manager.h" | 19 #include "content/public/browser/download_manager.h" |
20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/save_page_type.h" | 21 #include "content/public/browser/save_page_type.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_view.h" |
23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 | 26 |
26 using content::RenderProcessHost; | 27 using content::RenderProcessHost; |
27 using content::SavePageType; | 28 using content::SavePageType; |
28 using content::WebContents; | 29 using content::WebContents; |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 // If false, we don't prompt the user as to where to save the file. This | 33 // If false, we don't prompt the user as to where to save the file. This |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 file_type_info.extensions[0][0].erase(0, 1); | 153 file_type_info.extensions[0][0].erase(0, 1); |
153 } | 154 } |
154 | 155 |
155 file_type_info.include_all_files = true; | 156 file_type_info.include_all_files = true; |
156 file_type_index = 1; | 157 file_type_index = 1; |
157 } | 158 } |
158 | 159 |
159 if (g_should_prompt_for_filename) { | 160 if (g_should_prompt_for_filename) { |
160 select_file_dialog_ = ui::SelectFileDialog::Create( | 161 select_file_dialog_ = ui::SelectFileDialog::Create( |
161 this, new ChromeSelectFilePolicy(web_contents)); | 162 this, new ChromeSelectFilePolicy(web_contents)); |
162 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE, | 163 select_file_dialog_->SelectFile( |
163 string16(), | 164 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
164 suggested_path, | 165 string16(), |
165 &file_type_info, | 166 suggested_path, |
166 file_type_index, | 167 &file_type_info, |
167 default_extension, | 168 file_type_index, |
168 platform_util::GetTopLevel( | 169 default_extension, |
169 web_contents->GetNativeView()), | 170 platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()), |
170 NULL); | 171 NULL); |
171 } else { | 172 } else { |
172 // Just use 'suggested_path' instead of opening the dialog prompt. | 173 // Just use 'suggested_path' instead of opening the dialog prompt. |
173 // Go through FileSelected() for consistency. | 174 // Go through FileSelected() for consistency. |
174 FileSelected(suggested_path, file_type_index, NULL); | 175 FileSelected(suggested_path, file_type_index, NULL); |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 SavePackageFilePicker::~SavePackageFilePicker() { | 179 SavePackageFilePicker::~SavePackageFilePicker() { |
179 } | 180 } |
180 | 181 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 222 |
222 callback_.Run(path, save_type, base::Bind(&OnSavePackageDownloadCreated)); | 223 callback_.Run(path, save_type, base::Bind(&OnSavePackageDownloadCreated)); |
223 } | 224 } |
224 | 225 |
225 delete this; | 226 delete this; |
226 } | 227 } |
227 | 228 |
228 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { | 229 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { |
229 delete this; | 230 delete this; |
230 } | 231 } |
OLD | NEW |