Chromium Code Reviews| Index: content/browser/download/download_item.cc |
| diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc |
| index e71366b411ce07b214b039a66cae298302f1658a..37ae2383139b9be4d4564fa39cca33def620cf11 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 |
|
benjhayden
2011/11/16 15:57:22
Thank you for fixing the incorrect use of the verb
|
| +// |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; |
| } |
| @@ -187,7 +193,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), |
| @@ -464,7 +470,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(); |
| @@ -673,7 +680,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 { |
| @@ -696,6 +704,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(), |