| Index: content/browser/download/download_item.cc
|
| diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc
|
| index e3eff9943cf34b37c35f0b76a1f26125076bdb2f..bd68e6a92854ca59a6553c5052b55c1544d50fa3 100644
|
| --- a/content/browser/download/download_item.cc
|
| +++ b/content/browser/download/download_item.cc
|
| @@ -92,20 +92,26 @@ const char* DebugDownloadStateString(DownloadItem::DownloadState state) {
|
| }
|
|
|
| DownloadItem::SafetyState GetSafetyState(bool dangerous_file,
|
| - bool dangerous_url) {
|
| + bool dangerous_url,
|
| + bool dangerous_content) {
|
| + // TODO(noelutz): At this point we can't mark the download as dangerous
|
| + // if it's content is dangerous because the UI doesn't yet support it.
|
| + // Once the UI has been changed we should return DANGEROUS when
|
| + // |dangerous_content| is true.
|
| return (dangerous_url || dangerous_file) ?
|
| DownloadItem::DANGEROUS : DownloadItem::SAFE;
|
| }
|
|
|
| -// Note: When a download has both |dangerous_file| and |dangerous_url| set,
|
| -// danger type is set to DANGEROUS_URL since the risk of dangerous URL
|
| -// overweights that of dangerous file type.
|
| +// Note: |dangerous_url| takes precedence over both |dangerous_content| and
|
| +// |dangerous_content| and |dangerous_url| takes precedence over
|
| +// |dangerous_content|.
|
| DownloadItem::DangerType GetDangerType(bool dangerous_file,
|
| - bool dangerous_url) {
|
| - if (dangerous_url) {
|
| - // dangerous URL overweights dangerous file. We check dangerous URL first.
|
| + bool dangerous_url,
|
| + bool dangerous_content) {
|
| + if (dangerous_url)
|
| return DownloadItem::DANGEROUS_URL;
|
| - }
|
| + if (dangerous_content)
|
| + return DownloadItem::DANGEROUS_CONTENT;
|
| return dangerous_file ?
|
| DownloadItem::DANGEROUS_FILE : DownloadItem::NOT_DANGEROUS;
|
| }
|
| @@ -162,7 +168,7 @@ DownloadItem::DownloadItem(DownloadManager* download_manager,
|
| : state_info_(info.original_name, info.save_info.file_path,
|
| info.has_user_gesture, info.transition_type,
|
| info.prompt_user_for_save_location, info.path_uniquifier,
|
| - false, false),
|
| + false, false, false, false),
|
| request_handle_(request_handle),
|
| download_id_(info.download_id),
|
| full_path_(info.path),
|
| @@ -438,7 +444,8 @@ void DownloadItem::TransitionTo(DownloadState new_state) {
|
| void DownloadItem::UpdateSafetyState() {
|
| SafetyState updated_value(
|
| GetSafetyState(state_info_.is_dangerous_file,
|
| - state_info_.is_dangerous_url));
|
| + state_info_.is_dangerous_url,
|
| + state_info_.is_dangerous_content));
|
| if (updated_value != safety_state_) {
|
| safety_state_ = updated_value;
|
| UpdateObservers();
|
| @@ -647,7 +654,8 @@ void DownloadItem::SetFileCheckResults(const DownloadStateInfo& state) {
|
|
|
| DownloadItem::DangerType DownloadItem::GetDangerType() const {
|
| return ::GetDangerType(state_info_.is_dangerous_file,
|
| - state_info_.is_dangerous_url);
|
| + state_info_.is_dangerous_url,
|
| + state_info_.is_dangerous_content);
|
| }
|
|
|
| bool DownloadItem::IsDangerous() const {
|
| @@ -670,6 +678,14 @@ void DownloadItem::MarkUrlDangerous() {
|
| UpdateSafetyState();
|
| }
|
|
|
| +void DownloadItem::MarkContentDangerous() {
|
| + // TODO(rdsmith): Change to DCHECK after http://crbug.com/85408 resolved.
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + state_info_.is_dangerous_content = true;
|
| + UpdateSafetyState();
|
| +}
|
| +
|
| DownloadPersistentStoreInfo DownloadItem::GetPersistentStoreInfo() const {
|
| return DownloadPersistentStoreInfo(full_path(),
|
| GetURL(),
|
|
|