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

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

Issue 2850042: Deprecate more old filepath functions. (Closed)
Patch Set: rebase Created 10 years, 5 months 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 name_with_proper_ext = EnsureHtmlExtension(name_with_proper_ext); 1077 name_with_proper_ext = EnsureHtmlExtension(name_with_proper_ext);
1078 1078
1079 FilePath::StringType file_name = name_with_proper_ext.value(); 1079 FilePath::StringType file_name = name_with_proper_ext.value();
1080 file_util::ReplaceIllegalCharactersInPath(&file_name, ' '); 1080 file_util::ReplaceIllegalCharactersInPath(&file_name, ' ');
1081 return FilePath(file_name); 1081 return FilePath(file_name);
1082 } 1082 }
1083 1083
1084 FilePath SavePackage::EnsureHtmlExtension(const FilePath& name) { 1084 FilePath SavePackage::EnsureHtmlExtension(const FilePath& name) {
1085 // If the file name doesn't have an extension suitable for HTML files, 1085 // If the file name doesn't have an extension suitable for HTML files,
1086 // append one. 1086 // append one.
1087 FilePath::StringType ext = file_util::GetFileExtensionFromPath(name); 1087 FilePath::StringType ext = name.Extension();
1088 if (!ext.empty())
1089 ext.erase(ext.begin()); // Erase preceding '.'.
1088 std::string mime_type; 1090 std::string mime_type;
1089 if (!net::GetMimeTypeFromExtension(ext, &mime_type) || 1091 if (!net::GetMimeTypeFromExtension(ext, &mime_type) ||
1090 !CanSaveAsComplete(mime_type)) { 1092 !CanSaveAsComplete(mime_type)) {
1091 return FilePath(name.value() + FILE_PATH_LITERAL(".") + 1093 return FilePath(name.value() + FILE_PATH_LITERAL(".") +
1092 kDefaultHtmlExtension); 1094 kDefaultHtmlExtension);
1093 } 1095 }
1094 return name; 1096 return name;
1095 } 1097 }
1096 1098
1097 FilePath SavePackage::EnsureMimeExtension(const FilePath& name, 1099 FilePath SavePackage::EnsureMimeExtension(const FilePath& name,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 int index, void* params) { 1358 int index, void* params) {
1357 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1359 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1358 ContinueSave(save_params, path, index); 1360 ContinueSave(save_params, path, index);
1359 delete save_params; 1361 delete save_params;
1360 } 1362 }
1361 1363
1362 void SavePackage::FileSelectionCanceled(void* params) { 1364 void SavePackage::FileSelectionCanceled(void* params) {
1363 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params); 1365 SavePackageParam* save_params = reinterpret_cast<SavePackageParam*>(params);
1364 delete save_params; 1366 delete save_params;
1365 } 1367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698