| 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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 10 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 11 #include "chrome/browser/download/download_prefs.h" | 11 #include "chrome/browser/download/download_prefs.h" |
| 12 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
| 13 #include "chrome/browser/prefs/pref_member.h" | 13 #include "chrome/browser/prefs/pref_member.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.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" | |
| 17 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 19 #include "content/public/browser/download_manager.h" | 18 #include "content/public/browser/download_manager.h" |
| 20 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 21 #include "content/public/browser/save_page_type.h" | 20 #include "content/public/browser/save_page_type.h" |
| 22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 23 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 25 | 24 |
| 26 using content::RenderProcessHost; | 25 using content::RenderProcessHost; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 if (!file_type_info.extensions[0][0].empty()) { | 149 if (!file_type_info.extensions[0][0].empty()) { |
| 151 // Drop the . | 150 // Drop the . |
| 152 file_type_info.extensions[0][0].erase(0, 1); | 151 file_type_info.extensions[0][0].erase(0, 1); |
| 153 } | 152 } |
| 154 | 153 |
| 155 file_type_info.include_all_files = true; | 154 file_type_info.include_all_files = true; |
| 156 file_type_index = 1; | 155 file_type_index = 1; |
| 157 } | 156 } |
| 158 | 157 |
| 159 if (g_should_prompt_for_filename) { | 158 if (g_should_prompt_for_filename) { |
| 160 select_file_dialog_ = SelectFileDialog::Create( | 159 select_file_dialog_ = SelectFileDialog::Create(this); |
| 161 this, new ChromeSelectFilePolicy(web_contents)); | |
| 162 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, | 160 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, |
| 163 string16(), | 161 string16(), |
| 164 suggested_path, | 162 suggested_path, |
| 165 &file_type_info, | 163 &file_type_info, |
| 166 file_type_index, | 164 file_type_index, |
| 167 default_extension, | 165 default_extension, |
| 166 web_contents, |
| 168 platform_util::GetTopLevel( | 167 platform_util::GetTopLevel( |
| 169 web_contents->GetNativeView()), | 168 web_contents->GetNativeView()), |
| 170 NULL); | 169 NULL); |
| 171 } else { | 170 } else { |
| 172 // Just use 'suggested_path' instead of opening the dialog prompt. | 171 // Just use 'suggested_path' instead of opening the dialog prompt. |
| 173 // Go through FileSelected() for consistency. | 172 // Go through FileSelected() for consistency. |
| 174 FileSelected(suggested_path, file_type_index, NULL); | 173 FileSelected(suggested_path, file_type_index, NULL); |
| 175 } | 174 } |
| 176 } | 175 } |
| 177 | 176 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 220 |
| 222 callback_.Run(path, save_type, base::Bind(&OnSavePackageDownloadCreated)); | 221 callback_.Run(path, save_type, base::Bind(&OnSavePackageDownloadCreated)); |
| 223 } | 222 } |
| 224 | 223 |
| 225 delete this; | 224 delete this; |
| 226 } | 225 } |
| 227 | 226 |
| 228 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { | 227 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { |
| 229 delete this; | 228 delete this; |
| 230 } | 229 } |
| OLD | NEW |