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_macros.h" | 7 #include "base/metrics/histogram_macros.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" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 owning_window, | 89 owning_window, |
90 NULL); | 90 NULL); |
91 } | 91 } |
92 | 92 |
93 DownloadFilePicker::~DownloadFilePicker() { | 93 DownloadFilePicker::~DownloadFilePicker() { |
94 } | 94 } |
95 | 95 |
96 void DownloadFilePicker::OnFileSelected(const base::FilePath& path) { | 96 void DownloadFilePicker::OnFileSelected(const base::FilePath& path) { |
97 if (should_record_file_picker_result_) | 97 if (should_record_file_picker_result_) |
98 RecordFilePickerResult(suggested_path_, path); | 98 RecordFilePickerResult(suggested_path_, path); |
99 file_selected_callback_.Run(path); | 99 file_selected_callback_.Run(path.empty() |
| 100 ? DownloadConfirmationResult::CANCELED |
| 101 : DownloadConfirmationResult::CONFIRMED, |
| 102 path); |
100 delete this; | 103 delete this; |
101 } | 104 } |
102 | 105 |
103 void DownloadFilePicker::FileSelected(const base::FilePath& path, | 106 void DownloadFilePicker::FileSelected(const base::FilePath& path, |
104 int index, | 107 int index, |
105 void* params) { | 108 void* params) { |
106 OnFileSelected(path); | 109 OnFileSelected(path); |
107 // Deletes |this| | 110 // Deletes |this| |
108 } | 111 } |
109 | 112 |
110 void DownloadFilePicker::FileSelectionCanceled(void* params) { | 113 void DownloadFilePicker::FileSelectionCanceled(void* params) { |
111 OnFileSelected(base::FilePath()); | 114 OnFileSelected(base::FilePath()); |
112 // Deletes |this| | 115 // Deletes |this| |
113 } | 116 } |
114 | 117 |
115 // static | 118 // static |
116 void DownloadFilePicker::ShowFilePicker(DownloadItem* item, | 119 void DownloadFilePicker::ShowFilePicker(DownloadItem* item, |
117 const base::FilePath& suggested_path, | 120 const base::FilePath& suggested_path, |
118 const FileSelectedCallback& callback) { | 121 const FileSelectedCallback& callback) { |
119 new DownloadFilePicker(item, suggested_path, callback); | 122 new DownloadFilePicker(item, suggested_path, callback); |
120 // DownloadFilePicker deletes itself. | 123 // DownloadFilePicker deletes itself. |
121 } | 124 } |
OLD | NEW |