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

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

Issue 14625016: downloads: Make GetCrDownloadPath a static method on DownloadTargetDeterminer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // download_->GetForcedFilePath(). 420 // download_->GetForcedFilePath().
421 if (danger_type_ == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS && 421 if (danger_type_ == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS &&
422 !download_->GetForcedFilePath().empty()) { 422 !download_->GetForcedFilePath().empty()) {
423 DCHECK_EQ(download_->GetForcedFilePath().value(), local_path_.value()); 423 DCHECK_EQ(download_->GetForcedFilePath().value(), local_path_.value());
424 intermediate_path_ = local_path_; 424 intermediate_path_ = local_path_;
425 return COMPLETE; 425 return COMPLETE;
426 } 426 }
427 427
428 // Other safe downloads get a .crdownload suffix for their intermediate name. 428 // Other safe downloads get a .crdownload suffix for their intermediate name.
429 if (danger_type_ == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) { 429 if (danger_type_ == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
430 intermediate_path_ = download_util::GetCrDownloadPath(local_path_); 430 intermediate_path_ = GetCrDownloadPath(local_path_);
431 return COMPLETE; 431 return COMPLETE;
432 } 432 }
433 433
434 // Dangerous downloads receive a random intermediate name that looks like: 434 // Dangerous downloads receive a random intermediate name that looks like:
435 // 'Unconfirmed <random>.crdownload'. 435 // 'Unconfirmed <random>.crdownload'.
436 const base::FilePath::CharType kUnconfirmedFormatSuffix[] = 436 const base::FilePath::CharType kUnconfirmedFormatSuffix[] =
437 FILE_PATH_LITERAL(" %d.crdownload"); 437 FILE_PATH_LITERAL(" %d.crdownload");
438 // Range of the <random> uniquifier. 438 // Range of the <random> uniquifier.
439 const int kUnconfirmedUniquifierRange = 1000000; 439 const int kUnconfirmedUniquifierRange = 1000000;
440 #if defined(OS_WIN) 440 #if defined(OS_WIN)
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 DownloadPrefs* download_prefs, 587 DownloadPrefs* download_prefs,
588 const base::FilePath& last_selected_directory, 588 const base::FilePath& last_selected_directory,
589 DownloadTargetDeterminerDelegate* delegate, 589 DownloadTargetDeterminerDelegate* delegate,
590 const content::DownloadTargetCallback& callback) { 590 const content::DownloadTargetCallback& callback) {
591 // DownloadTargetDeterminer owns itself and will self destruct when the job is 591 // DownloadTargetDeterminer owns itself and will self destruct when the job is
592 // complete or the download item is destroyed. The callback is always invoked 592 // complete or the download item is destroyed. The callback is always invoked
593 // asynchronously. 593 // asynchronously.
594 new DownloadTargetDeterminer(download, download_prefs, 594 new DownloadTargetDeterminer(download, download_prefs,
595 last_selected_directory, delegate, callback); 595 last_selected_directory, delegate, callback);
596 } 596 }
597
598 // static
599 base::FilePath DownloadTargetDeterminer::GetCrDownloadPath(
600 const base::FilePath& suggested_path) {
601 return base::FilePath(suggested_path.value() +
602 FILE_PATH_LITERAL(".crdownload"));
603 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_target_determiner.h ('k') | chrome/browser/download/download_target_determiner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698