| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/download_target_determiner.h" | 5 #include "chrome/browser/download/download_target_determiner.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 return COMPLETE; | 594 return COMPLETE; |
| 595 } | 595 } |
| 596 | 596 |
| 597 // Dangerous downloads receive a random intermediate name that looks like: | 597 // Dangerous downloads receive a random intermediate name that looks like: |
| 598 // 'Unconfirmed <random>.crdownload'. | 598 // 'Unconfirmed <random>.crdownload'. |
| 599 const base::FilePath::CharType kUnconfirmedFormatSuffix[] = | 599 const base::FilePath::CharType kUnconfirmedFormatSuffix[] = |
| 600 FILE_PATH_LITERAL(" %d.crdownload"); | 600 FILE_PATH_LITERAL(" %d.crdownload"); |
| 601 // Range of the <random> uniquifier. | 601 // Range of the <random> uniquifier. |
| 602 const int kUnconfirmedUniquifierRange = 1000000; | 602 const int kUnconfirmedUniquifierRange = 1000000; |
| 603 #if defined(OS_WIN) | 603 #if defined(OS_WIN) |
| 604 string16 unconfirmed_format = | 604 base::string16 unconfirmed_format = |
| 605 l10n_util::GetStringUTF16(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); | 605 l10n_util::GetStringUTF16(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); |
| 606 #else | 606 #else |
| 607 std::string unconfirmed_format = | 607 std::string unconfirmed_format = |
| 608 l10n_util::GetStringUTF8(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); | 608 l10n_util::GetStringUTF8(IDS_DOWNLOAD_UNCONFIRMED_PREFIX); |
| 609 #endif | 609 #endif |
| 610 unconfirmed_format.append(kUnconfirmedFormatSuffix); | 610 unconfirmed_format.append(kUnconfirmedFormatSuffix); |
| 611 | 611 |
| 612 base::FilePath::StringType file_name = base::StringPrintf( | 612 base::FilePath::StringType file_name = base::StringPrintf( |
| 613 unconfirmed_format.c_str(), | 613 unconfirmed_format.c_str(), |
| 614 base::RandInt(0, kUnconfirmedUniquifierRange)); | 614 base::RandInt(0, kUnconfirmedUniquifierRange)); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 // asynchronously. | 785 // asynchronously. |
| 786 new DownloadTargetDeterminer(download, initial_virtual_path, download_prefs, | 786 new DownloadTargetDeterminer(download, initial_virtual_path, download_prefs, |
| 787 delegate, callback); | 787 delegate, callback); |
| 788 } | 788 } |
| 789 | 789 |
| 790 // static | 790 // static |
| 791 base::FilePath DownloadTargetDeterminer::GetCrDownloadPath( | 791 base::FilePath DownloadTargetDeterminer::GetCrDownloadPath( |
| 792 const base::FilePath& suggested_path) { | 792 const base::FilePath& suggested_path) { |
| 793 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); | 793 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); |
| 794 } | 794 } |
| OLD | NEW |