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 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 | 1427 |
1428 void SavePackage::FinalizeDownloadEntry() { | 1428 void SavePackage::FinalizeDownloadEntry() { |
1429 DCHECK(download_); | 1429 DCHECK(download_); |
1430 DCHECK(download_manager_); | 1430 DCHECK(download_manager_); |
1431 | 1431 |
1432 download_manager_->OnSavePackageSuccessfullyFinished(download_); | 1432 download_manager_->OnSavePackageSuccessfullyFinished(download_); |
1433 StopObservation(); | 1433 StopObservation(); |
1434 } | 1434 } |
1435 | 1435 |
1436 } // namespace content | 1436 } // namespace content |
OLD | NEW |