| 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 "content/browser/download/save_package.h" | 5 #include "content/browser/download/save_package.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 // Ask user for getting final saving name. | 1237 // Ask user for getting final saving name. |
| 1238 name_with_proper_ext = EnsureMimeExtension(name_with_proper_ext, | 1238 name_with_proper_ext = EnsureMimeExtension(name_with_proper_ext, |
| 1239 contents_mime_type); | 1239 contents_mime_type); |
| 1240 // Adjust extension for complete types. | 1240 // Adjust extension for complete types. |
| 1241 if (can_save_as_complete) | 1241 if (can_save_as_complete) |
| 1242 name_with_proper_ext = EnsureHtmlExtension(name_with_proper_ext); | 1242 name_with_proper_ext = EnsureHtmlExtension(name_with_proper_ext); |
| 1243 | 1243 |
| 1244 base::FilePath::StringType file_name = name_with_proper_ext.value(); | 1244 base::FilePath::StringType file_name = name_with_proper_ext.value(); |
| 1245 base::i18n::ReplaceIllegalCharactersInPath(&file_name, ' '); | 1245 base::i18n::ReplaceIllegalCharactersInPath(&file_name, '_'); |
| 1246 return base::FilePath(file_name); | 1246 return base::FilePath(file_name); |
| 1247 } | 1247 } |
| 1248 | 1248 |
| 1249 base::FilePath SavePackage::EnsureHtmlExtension(const base::FilePath& name) { | 1249 base::FilePath SavePackage::EnsureHtmlExtension(const base::FilePath& name) { |
| 1250 // If the file name doesn't have an extension suitable for HTML files, | 1250 // If the file name doesn't have an extension suitable for HTML files, |
| 1251 // append one. | 1251 // append one. |
| 1252 base::FilePath::StringType ext = name.Extension(); | 1252 base::FilePath::StringType ext = name.Extension(); |
| 1253 if (!ext.empty()) | 1253 if (!ext.empty()) |
| 1254 ext.erase(ext.begin()); // Erase preceding '.'. | 1254 ext.erase(ext.begin()); // Erase preceding '.'. |
| 1255 std::string mime_type; | 1255 std::string mime_type; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 | 1434 |
| 1435 void SavePackage::FinalizeDownloadEntry() { | 1435 void SavePackage::FinalizeDownloadEntry() { |
| 1436 DCHECK(download_); | 1436 DCHECK(download_); |
| 1437 DCHECK(download_manager_); | 1437 DCHECK(download_manager_); |
| 1438 | 1438 |
| 1439 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1439 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
| 1440 StopObservation(); | 1440 StopObservation(); |
| 1441 } | 1441 } |
| 1442 | 1442 |
| 1443 } // namespace content | 1443 } // namespace content |
| OLD | NEW |