Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: chrome/browser/download/save_package.cc

Issue 459008: Mac: the return of the tab-modal-sheets patch. (Closed)
Patch Set: Merged ToT. Must ... commit ... soon. Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/gtk/dialogs_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "chrome/browser/download/save_package.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/i18n/file_util_icu.h" 10 #include "base/i18n/file_util_icu.h"
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 new SavePackageParam(tab_contents_->contents_mime_type()); 1115 new SavePackageParam(tab_contents_->contents_mime_type());
1116 1116
1117 bool can_save_as_complete = 1117 bool can_save_as_complete =
1118 CanSaveAsComplete(save_params->current_tab_mime_type); 1118 CanSaveAsComplete(save_params->current_tab_mime_type);
1119 1119
1120 FilePath title = 1120 FilePath title =
1121 FilePath::FromWStringHack(UTF16ToWideHack(tab_contents_->GetTitle())); 1121 FilePath::FromWStringHack(UTF16ToWideHack(tab_contents_->GetTitle()));
1122 FilePath suggested_path = 1122 FilePath suggested_path =
1123 save_dir.Append(GetSuggestedNameForSaveAs(title, can_save_as_complete)); 1123 save_dir.Append(GetSuggestedNameForSaveAs(title, can_save_as_complete));
1124 1124
1125 // If the contents can not be saved as complete-HTML, do not show the 1125 // If the contents cannot be saved as complete-HTML, do not show the
1126 // file filters. 1126 // file filters.
1127 if (can_save_as_complete) { 1127 if (can_save_as_complete) {
1128 file_type_info.extensions.resize(2); 1128 file_type_info.extensions.resize(2);
1129 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("htm")); 1129 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("htm"));
1130 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); 1130 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html"));
1131 file_type_info.extension_description_overrides.push_back( 1131 file_type_info.extension_description_overrides.push_back(
1132 WideToUTF16(l10n_util::GetString(IDS_SAVE_PAGE_DESC_HTML_ONLY))); 1132 WideToUTF16(l10n_util::GetString(IDS_SAVE_PAGE_DESC_HTML_ONLY)));
1133 file_type_info.extensions[1].push_back(FILE_PATH_LITERAL("htm")); 1133 file_type_info.extensions[1].push_back(FILE_PATH_LITERAL("htm"));
1134 file_type_info.extensions[1].push_back(FILE_PATH_LITERAL("html")); 1134 file_type_info.extensions[1].push_back(FILE_PATH_LITERAL("html"));
1135 file_type_info.extension_description_overrides.push_back( 1135 file_type_info.extension_description_overrides.push_back(
1136 WideToUTF16(l10n_util::GetString(IDS_SAVE_PAGE_DESC_COMPLETE))); 1136 WideToUTF16(l10n_util::GetString(IDS_SAVE_PAGE_DESC_COMPLETE)));
1137 file_type_info.include_all_files = false; 1137 file_type_info.include_all_files = false;
1138 default_extension = kDefaultHtmlExtension; 1138 default_extension = kDefaultHtmlExtension;
1139 } else { 1139 } else {
1140 file_type_info.extensions.resize(1); 1140 file_type_info.extensions.resize(1);
1141 file_type_info.extensions[0].push_back(suggested_path.Extension()); 1141 file_type_info.extensions[0].push_back(suggested_path.Extension());
1142 if (!file_type_info.extensions[0][0].empty()) 1142 if (!file_type_info.extensions[0][0].empty())
1143 file_type_info.extensions[0][0].erase(0, 1); // drop the . 1143 file_type_info.extensions[0][0].erase(0, 1); // drop the .
1144 file_type_info.include_all_files = true; 1144 file_type_info.include_all_files = true;
1145 file_type_index = 1; 1145 file_type_index = 1;
1146 } 1146 }
1147 1147
1148 if (g_should_prompt_for_filename) { 1148 if (g_should_prompt_for_filename) {
1149 if (!select_file_dialog_.get()) 1149 if (!select_file_dialog_.get())
1150 select_file_dialog_ = SelectFileDialog::Create(this); 1150 select_file_dialog_ = SelectFileDialog::Create(this);
1151 #if defined(OS_MACOSX)
1152 select_file_dialog_->SelectFileInTab(SelectFileDialog::SELECT_SAVEAS_FILE,
1153 string16(),
1154 suggested_path,
1155 &file_type_info,
1156 file_type_index,
1157 default_extension,
1158 tab_contents_,
1159 save_params);
1160 #else
1151 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE, 1161 select_file_dialog_->SelectFile(SelectFileDialog::SELECT_SAVEAS_FILE,
1152 string16(), 1162 string16(),
1153 suggested_path, 1163 suggested_path,
1154 &file_type_info, 1164 &file_type_info,
1155 file_type_index, 1165 file_type_index,
1156 default_extension, 1166 default_extension,
1157 platform_util::GetTopLevel( 1167 platform_util::GetTopLevel(
1158 tab_contents_->GetNativeView()), 1168 tab_contents_->GetNativeView()),
1159 save_params); 1169 save_params);
1170 #endif
1160 } else { 1171 } else {
1161 // Just use 'suggested_path' instead of opening the dialog prompt. 1172 // Just use 'suggested_path' instead of opening the dialog prompt.
1162 ContinueSave(save_params, suggested_path, file_type_index); 1173 ContinueSave(save_params, suggested_path, file_type_index);
1163 delete save_params; 1174 delete save_params;
1164 } 1175 }
1165 } 1176 }
1166 1177
1167 // Called after the save file dialog box returns. 1178 // Called after the save file dialog box returns.
1168 void SavePackage::ContinueSave(SavePackageParam* param, 1179 void SavePackage::ContinueSave(SavePackageParam* param,
1169 const FilePath& final_name, 1180 const FilePath& final_name,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 int index, void* params) { 1275 int index, void* params) {
1265 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1276 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1266 ContinueSave(save_params, path, index); 1277 ContinueSave(save_params, path, index);
1267 delete save_params; 1278 delete save_params;
1268 } 1279 }
1269 1280
1270 void SavePackage::FileSelectionCanceled(void* params) { 1281 void SavePackage::FileSelectionCanceled(void* params) {
1271 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1282 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1272 delete save_params; 1283 delete save_params;
1273 } 1284 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/gtk/dialogs_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698