| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/i18n/file_util_icu.h" | 11 #include "base/i18n/file_util_icu.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 15 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 16 #include "chrome/browser/download/download_prefs.h" | 16 #include "chrome/browser/download/download_prefs.h" |
| 17 #include "chrome/browser/platform_util.h" | |
| 18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/chrome_select_file_policy.h" | 18 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 20 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 22 #include "components/prefs/pref_member.h" | 21 #include "components/prefs/pref_member.h" |
| 23 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
| 24 #include "content/public/browser/download_manager.h" | 23 #include "content/public/browser/download_manager.h" |
| 25 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/browser/save_page_type.h" | 25 #include "content/public/browser/save_page_type.h" |
| 27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/gfx/view_util.h" |
| 29 | 29 |
| 30 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
| 31 #include "chrome/browser/chromeos/drive/download_handler.h" | 31 #include "chrome/browser/chromeos/drive/download_handler.h" |
| 32 #include "chrome/browser/chromeos/drive/file_system_util.h" | 32 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 using content::RenderProcessHost; | 35 using content::RenderProcessHost; |
| 36 using content::SavePageType; | 36 using content::SavePageType; |
| 37 using content::WebContents; | 37 using content::WebContents; |
| 38 | 38 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 | 206 |
| 207 file_type_info.include_all_files = true; | 207 file_type_info.include_all_files = true; |
| 208 file_type_index = 1; | 208 file_type_index = 1; |
| 209 } | 209 } |
| 210 | 210 |
| 211 if (g_should_prompt_for_filename) { | 211 if (g_should_prompt_for_filename) { |
| 212 select_file_dialog_ = ui::SelectFileDialog::Create( | 212 select_file_dialog_ = ui::SelectFileDialog::Create( |
| 213 this, new ChromeSelectFilePolicy(web_contents)); | 213 this, new ChromeSelectFilePolicy(web_contents)); |
| 214 select_file_dialog_->SelectFile( | 214 select_file_dialog_->SelectFile( |
| 215 ui::SelectFileDialog::SELECT_SAVEAS_FILE, | 215 ui::SelectFileDialog::SELECT_SAVEAS_FILE, base::string16(), |
| 216 base::string16(), | 216 suggested_path_copy, &file_type_info, file_type_index, |
| 217 suggested_path_copy, | 217 default_extension_copy, gfx::GetTopLevel(web_contents->GetNativeView()), |
| 218 &file_type_info, | |
| 219 file_type_index, | |
| 220 default_extension_copy, | |
| 221 platform_util::GetTopLevel(web_contents->GetNativeView()), | |
| 222 NULL); | 218 NULL); |
| 223 } else { | 219 } else { |
| 224 // Just use 'suggested_path_copy' instead of opening the dialog prompt. | 220 // Just use 'suggested_path_copy' instead of opening the dialog prompt. |
| 225 // Go through FileSelected() for consistency. | 221 // Go through FileSelected() for consistency. |
| 226 FileSelected(suggested_path_copy, file_type_index, NULL); | 222 FileSelected(suggested_path_copy, file_type_index, NULL); |
| 227 } | 223 } |
| 228 } | 224 } |
| 229 | 225 |
| 230 SavePackageFilePicker::~SavePackageFilePicker() { | 226 SavePackageFilePicker::~SavePackageFilePicker() { |
| 231 } | 227 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 279 } |
| 284 #endif | 280 #endif |
| 285 | 281 |
| 286 callback_.Run(path_copy, save_type, | 282 callback_.Run(path_copy, save_type, |
| 287 base::Bind(&OnSavePackageDownloadCreated)); | 283 base::Bind(&OnSavePackageDownloadCreated)); |
| 288 } | 284 } |
| 289 | 285 |
| 290 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { | 286 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { |
| 291 delete this; | 287 delete this; |
| 292 } | 288 } |
| OLD | NEW |