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..3d2128a3f418d4ed08ca76a74f8eaf8c825ed488 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,7 @@ 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; |
} |
return CONTINUE; |
} |
@@ -621,7 +621,7 @@ void DownloadTargetDeterminer::CheckVisitedReferrerBeforeDone( |
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; |
+ is_dangerous_file_ = true; |
DoLoop(); |
} |
@@ -715,7 +715,12 @@ void DownloadTargetDeterminer::ScheduleCallbackAndDeleteSelf() { |
(HasPromptedForPath() || should_prompt_ |
? DownloadItem::TARGET_DISPOSITION_PROMPT |
: DownloadItem::TARGET_DISPOSITION_OVERWRITE); |
- target_info->danger_type = danger_type_; |
+ target_info->danger_type = |
+ (is_dangerous_file_ && |
+ danger_type_ == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) |
+ ? content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE |
+ : 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_; |