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" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 const content::SavePackagePathPickedCallback& callback) | 81 const content::SavePackagePathPickedCallback& callback) |
82 : render_process_id_(web_contents->GetRenderProcessHost()->GetID()), | 82 : render_process_id_(web_contents->GetRenderProcessHost()->GetID()), |
83 can_save_as_complete_(can_save_as_complete), | 83 can_save_as_complete_(can_save_as_complete), |
84 callback_(callback) { | 84 callback_(callback) { |
85 FilePath suggested_path = suggested_path_const; | 85 FilePath suggested_path = suggested_path_const; |
86 FilePath::StringType default_extension = default_extension_const; | 86 FilePath::StringType default_extension = default_extension_const; |
87 int file_type_index = SavePackageTypeToIndex( | 87 int file_type_index = SavePackageTypeToIndex( |
88 static_cast<SavePageType>(download_prefs->save_file_type())); | 88 static_cast<SavePageType>(download_prefs->save_file_type())); |
89 DCHECK_NE(-1, file_type_index); | 89 DCHECK_NE(-1, file_type_index); |
90 | 90 |
91 SelectFileDialog::FileTypeInfo file_type_info; | 91 ui::SelectFileDialog::FileTypeInfo file_type_info; |
92 | 92 |
93 // TODO(benjhayden): Merge the first branch with the second when all of the | 93 // TODO(benjhayden): Merge the first branch with the second when all of the |
94 // platform-specific file selection dialog implementations fully support | 94 // platform-specific file selection dialog implementations fully support |
95 // switching save-as file formats, and remove the flag/switch. | 95 // switching save-as file formats, and remove the flag/switch. |
96 if (ShouldSaveAsMHTML()) { | 96 if (ShouldSaveAsMHTML()) { |
97 default_extension = FILE_PATH_LITERAL("mhtml"); | 97 default_extension = FILE_PATH_LITERAL("mhtml"); |
98 suggested_path = suggested_path.ReplaceExtension(default_extension); | 98 suggested_path = suggested_path.ReplaceExtension(default_extension); |
99 } else if (can_save_as_complete) { | 99 } else if (can_save_as_complete) { |
100 bool add_extra_extension = false; | 100 bool add_extra_extension = false; |
101 FilePath::StringType extra_extension; | 101 FilePath::StringType extra_extension; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 if (!file_type_info.extensions[0][0].empty()) { | 150 if (!file_type_info.extensions[0][0].empty()) { |
151 // Drop the . | 151 // Drop the . |
152 file_type_info.extensions[0][0].erase(0, 1); | 152 file_type_info.extensions[0][0].erase(0, 1); |
153 } | 153 } |
154 | 154 |
155 file_type_info.include_all_files = true; | 155 file_type_info.include_all_files = true; |
156 file_type_index = 1; | 156 file_type_index = 1; |
157 } | 157 } |
158 | 158 |
159 if (g_should_prompt_for_filename) { | 159 if (g_should_prompt_for_filename) { |
160 select_file_dialog_ = SelectFileDialog::Create( | 160 select_file_dialog_ = ui::SelectFileDialog::Create( |
161 this, new ChromeSelectFilePolicy(web_contents)); | 161 this, new ChromeSelectFilePolicy(web_contents)); |
162 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, | 162 select_file_dialog_->SelectFile(ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
163 string16(), | 163 string16(), |
164 suggested_path, | 164 suggested_path, |
165 &file_type_info, | 165 &file_type_info, |
166 file_type_index, | 166 file_type_index, |
167 default_extension, | 167 default_extension, |
168 platform_util::GetTopLevel( | 168 platform_util::GetTopLevel( |
169 web_contents->GetNativeView()), | 169 web_contents->GetNativeView()), |
170 NULL); | 170 NULL); |
171 } else { | 171 } else { |
172 // Just use 'suggested_path' instead of opening the dialog prompt. | 172 // Just use 'suggested_path' instead of opening the dialog prompt. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 callback_.Run(path, save_type, base::Bind(&OnSavePackageDownloadCreated)); | 222 callback_.Run(path, save_type, base::Bind(&OnSavePackageDownloadCreated)); |
223 } | 223 } |
224 | 224 |
225 delete this; | 225 delete this; |
226 } | 226 } |
227 | 227 |
228 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { | 228 void SavePackageFilePicker::FileSelectionCanceled(void* unused_params) { |
229 delete this; | 229 delete this; |
230 } | 230 } |
OLD | NEW |