| 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/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 bool SavePackage::GetSafePureFileName( | 417 bool SavePackage::GetSafePureFileName( |
| 418 const base::FilePath& dir_path, | 418 const base::FilePath& dir_path, |
| 419 const base::FilePath::StringType& file_name_ext, | 419 const base::FilePath::StringType& file_name_ext, |
| 420 uint32 max_file_path_len, | 420 uint32 max_file_path_len, |
| 421 base::FilePath::StringType* pure_file_name) { | 421 base::FilePath::StringType* pure_file_name) { |
| 422 DCHECK(!pure_file_name->empty()); | 422 DCHECK(!pure_file_name->empty()); |
| 423 int available_length = static_cast<int>(max_file_path_len - | 423 int available_length = static_cast<int>(max_file_path_len - |
| 424 dir_path.value().length() - | 424 dir_path.value().length() - |
| 425 file_name_ext.length()); | 425 file_name_ext.length()); |
| 426 // Need an extra space for the separator. | 426 // Need an extra space for the separator. |
| 427 if (!file_util::EndsWithSeparator(dir_path)) | 427 if (!dir_path.EndsWithSeparator()) |
| 428 --available_length; | 428 --available_length; |
| 429 | 429 |
| 430 // Plenty of room. | 430 // Plenty of room. |
| 431 if (static_cast<int>(pure_file_name->length()) <= available_length) | 431 if (static_cast<int>(pure_file_name->length()) <= available_length) |
| 432 return true; | 432 return true; |
| 433 | 433 |
| 434 // Limited room. Truncate |pure_file_name| to fit. | 434 // Limited room. Truncate |pure_file_name| to fit. |
| 435 if (available_length > 0) { | 435 if (available_length > 0) { |
| 436 *pure_file_name = pure_file_name->substr(0, available_length); | 436 *pure_file_name = pure_file_name->substr(0, available_length); |
| 437 return true; | 437 return true; |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1432 | 1432 |
| 1433 void SavePackage::FinalizeDownloadEntry() { | 1433 void SavePackage::FinalizeDownloadEntry() { |
| 1434 DCHECK(download_); | 1434 DCHECK(download_); |
| 1435 DCHECK(download_manager_); | 1435 DCHECK(download_manager_); |
| 1436 | 1436 |
| 1437 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1437 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
| 1438 StopObservation(); | 1438 StopObservation(); |
| 1439 } | 1439 } |
| 1440 | 1440 |
| 1441 } // namespace content | 1441 } // namespace content |
| OLD | NEW |