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/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
12 #include "content/public/browser/download_item.h" | 12 #include "content/public/browser/download_item.h" |
13 #include "content/public/browser/download_manager.h" | 13 #include "content/public/browser/download_manager.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "ui/shell_dialogs/selected_file_info.h" |
15 | 16 |
16 using content::DownloadItem; | 17 using content::DownloadItem; |
17 using content::DownloadManager; | 18 using content::DownloadManager; |
18 using content::WebContents; | 19 using content::WebContents; |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 enum FilePickerResult { | 23 enum FilePickerResult { |
23 FILE_PICKER_SAME, | 24 FILE_PICKER_SAME, |
24 FILE_PICKER_DIFFERENT_DIR, | 25 FILE_PICKER_DIFFERENT_DIR, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 &file_type_info, | 86 &file_type_info, |
86 0, | 87 0, |
87 base::FilePath::StringType(), | 88 base::FilePath::StringType(), |
88 owning_window, | 89 owning_window, |
89 NULL); | 90 NULL); |
90 } | 91 } |
91 | 92 |
92 DownloadFilePicker::~DownloadFilePicker() { | 93 DownloadFilePicker::~DownloadFilePicker() { |
93 } | 94 } |
94 | 95 |
95 void DownloadFilePicker::OnFileSelected(const base::FilePath& path) { | 96 void DownloadFilePicker::OnFileSelected(const base::FilePath& path, |
| 97 bool hide_file_extension) { |
96 if (should_record_file_picker_result_) | 98 if (should_record_file_picker_result_) |
97 RecordFilePickerResult(suggested_path_, path); | 99 RecordFilePickerResult(suggested_path_, path); |
98 file_selected_callback_.Run(path); | 100 file_selected_callback_.Run(path, hide_file_extension); |
99 delete this; | 101 delete this; |
100 } | 102 } |
101 | 103 |
102 void DownloadFilePicker::FileSelected(const base::FilePath& path, | 104 void DownloadFilePicker::FileSelected(const base::FilePath& path, |
103 int index, | 105 int index, |
104 void* params) { | 106 void* params) { |
105 OnFileSelected(path); | 107 OnFileSelected(path, false); |
106 // Deletes |this| | 108 // Deletes |this| |
107 } | 109 } |
108 | 110 |
| 111 void DownloadFilePicker::FileSelectedWithExtraInfo( |
| 112 const ui::SelectedFileInfo& file, |
| 113 int index, |
| 114 void* params) { |
| 115 OnFileSelected(file.local_path.empty() ? file.file_path : file.local_path, |
| 116 file.hide_file_extension); |
| 117 } |
| 118 |
109 void DownloadFilePicker::FileSelectionCanceled(void* params) { | 119 void DownloadFilePicker::FileSelectionCanceled(void* params) { |
110 OnFileSelected(base::FilePath()); | 120 OnFileSelected(base::FilePath(), false); |
111 // Deletes |this| | 121 // Deletes |this| |
112 } | 122 } |
113 | 123 |
114 // static | 124 // static |
115 void DownloadFilePicker::ShowFilePicker(DownloadItem* item, | 125 void DownloadFilePicker::ShowFilePicker(DownloadItem* item, |
116 const base::FilePath& suggested_path, | 126 const base::FilePath& suggested_path, |
117 const FileSelectedCallback& callback) { | 127 const FileSelectedCallback& callback) { |
118 new DownloadFilePicker(item, suggested_path, callback); | 128 new DownloadFilePicker(item, suggested_path, callback); |
119 // DownloadFilePicker deletes itself. | 129 // DownloadFilePicker deletes itself. |
120 } | 130 } |
OLD | NEW |