| 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/download_file_picker.h" | 5 #include "chrome/browser/download/download_file_picker.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "chrome/browser/download/download_prefs.h" | 8 #include "chrome/browser/download/download_prefs.h" |
| 9 #include "chrome/browser/platform_util.h" | 9 #include "chrome/browser/platform_util.h" |
| 10 #include "chrome/browser/ui/chrome_select_file_policy.h" | 10 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 11 #include "content/public/browser/download_item.h" | 11 #include "content/public/browser/download_item.h" |
| 12 #include "content/public/browser/download_manager.h" | 12 #include "content/public/browser/download_manager.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/browser/web_contents_view.h" |
| 14 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 | 17 |
| 17 using content::DownloadItem; | 18 using content::DownloadItem; |
| 18 using content::DownloadManager; | 19 using content::DownloadManager; |
| 19 using content::WebContents; | 20 using content::WebContents; |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 enum FilePickerResult { | 24 enum FilePickerResult { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ui::SelectFileDialog::FileTypeInfo file_type_info; | 76 ui::SelectFileDialog::FileTypeInfo file_type_info; |
| 76 base::FilePath::StringType extension = suggested_path_.Extension(); | 77 base::FilePath::StringType extension = suggested_path_.Extension(); |
| 77 if (!extension.empty()) { | 78 if (!extension.empty()) { |
| 78 extension.erase(extension.begin()); // drop the . | 79 extension.erase(extension.begin()); // drop the . |
| 79 file_type_info.extensions.resize(1); | 80 file_type_info.extensions.resize(1); |
| 80 file_type_info.extensions[0].push_back(extension); | 81 file_type_info.extensions[0].push_back(extension); |
| 81 } | 82 } |
| 82 file_type_info.include_all_files = true; | 83 file_type_info.include_all_files = true; |
| 83 file_type_info.support_drive = true; | 84 file_type_info.support_drive = true; |
| 84 gfx::NativeWindow owning_window = web_contents ? | 85 gfx::NativeWindow owning_window = web_contents ? |
| 85 platform_util::GetTopLevel(web_contents->GetNativeView()) : NULL; | 86 platform_util::GetTopLevel(web_contents->GetView()->GetNativeView()) : |
| 87 NULL; |
| 86 | 88 |
| 87 select_file_dialog_->SelectFile( | 89 select_file_dialog_->SelectFile( |
| 88 ui::SelectFileDialog::SELECT_SAVEAS_FILE, | 90 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
| 89 string16(), | 91 string16(), |
| 90 suggested_path_, | 92 suggested_path_, |
| 91 &file_type_info, | 93 &file_type_info, |
| 92 0, | 94 0, |
| 93 FILE_PATH_LITERAL(""), | 95 FILE_PATH_LITERAL(""), |
| 94 owning_window, | 96 owning_window, |
| 95 NULL); | 97 NULL); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 120 RecordFileSelected(path); | 122 RecordFileSelected(path); |
| 121 OnFileSelected(path); | 123 OnFileSelected(path); |
| 122 // Deletes |this| | 124 // Deletes |this| |
| 123 } | 125 } |
| 124 | 126 |
| 125 void DownloadFilePicker::FileSelectionCanceled(void* params) { | 127 void DownloadFilePicker::FileSelectionCanceled(void* params) { |
| 126 RecordFilePickerResult(download_manager_, FILE_PICKER_CANCEL); | 128 RecordFilePickerResult(download_manager_, FILE_PICKER_CANCEL); |
| 127 OnFileSelected(base::FilePath()); | 129 OnFileSelected(base::FilePath()); |
| 128 // Deletes |this| | 130 // Deletes |this| |
| 129 } | 131 } |
| OLD | NEW |