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

Unified Diff: chrome/browser/download/download_target_determiner.cc

Issue 565053002: [Downloads] Gracefully handle SafeBrowsing check failures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_target_determiner.cc
diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc
index 836d4ce92dc8487af37caeff2785d9852934e33e..c0f44b69812d5b0e3b7071e423fd57a8084fcb36 100644
--- a/chrome/browser/download/download_target_determiner.cc
+++ b/chrome/browser/download/download_target_determiner.cc
@@ -89,6 +89,7 @@ DownloadTargetDeterminer::DownloadTargetDeterminer(
create_target_directory_(false),
conflict_action_(DownloadPathReservationTracker::OVERWRITE),
danger_type_(download->GetDangerType()),
+ is_dangerous_file_(false),
virtual_path_(initial_virtual_path),
is_filetype_handled_safely_(false),
download_(download),
@@ -576,10 +577,9 @@ DownloadTargetDeterminer::Result
next_state_ = STATE_DETERMINE_INTERMEDIATE_PATH;
// Checking if there are prior visits to the referrer is only necessary if the
- // danger level of the download depends on the file type. This excludes cases
- // where the download has already been deemed dangerous, or where the user is
- // going to be prompted or where this is a programmatic download.
- if (danger_type_ != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)
+ // danger level of the download depends on the file type.
+ if (danger_type_ != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS &&
+ danger_type_ != content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT)
return CONTINUE;
// Assume that:
@@ -610,7 +610,9 @@ DownloadTargetDeterminer::Result
// If the danger level doesn't depend on having visited the refererrer URL
// or if original profile doesn't have a HistoryService or the referrer url
// is invalid, then assume the referrer has not been visited before.
- danger_type_ = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
+ is_dangerous_file_ = true;
+ if (danger_type_ == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)
+ danger_type_ = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
}
return CONTINUE;
}
@@ -619,9 +621,12 @@ void DownloadTargetDeterminer::CheckVisitedReferrerBeforeDone(
bool visited_referrer_before) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(STATE_DETERMINE_INTERMEDIATE_PATH, next_state_);
- if (IsDangerousFile(
- visited_referrer_before ? VISITED_REFERRER : NO_VISITS_TO_REFERRER))
- danger_type_ = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
+ if (IsDangerousFile(visited_referrer_before ? VISITED_REFERRER
+ : NO_VISITS_TO_REFERRER)) {
+ is_dangerous_file_ = true;
+ if (danger_type_ == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS)
+ danger_type_ = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE;
+ }
DoLoop();
}
@@ -707,7 +712,8 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf() {
<< " Local:" << local_path_.AsUTF8Unsafe()
<< " Intermediate:" << intermediate_path_.AsUTF8Unsafe()
<< " Should prompt:" << should_prompt_
- << " Danger type:" << danger_type_;
+ << " Danger type:" << danger_type_
+ << " Is dangerous file:" << is_dangerous_file_;
scoped_ptr<DownloadTargetInfo> target_info(new DownloadTargetInfo);
target_info->target_path = local_path_;
@@ -716,6 +722,7 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf() {
? DownloadItem::TARGET_DISPOSITION_PROMPT
: DownloadItem::TARGET_DISPOSITION_OVERWRITE);
target_info->danger_type = danger_type_;
+ target_info->is_dangerous_file = is_dangerous_file_;
target_info->intermediate_path = intermediate_path_;
target_info->mime_type = mime_type_;
target_info->is_filetype_handled_safely = is_filetype_handled_safely_;
« no previous file with comments | « chrome/browser/download/download_target_determiner.h ('k') | chrome/browser/download/download_target_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698