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

Unified Diff: content/browser/download/download_item.cc

Issue 8468020: Propagate the SafeBrowsing download protection verdict to the DownloadItem. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address Ben's comment. Created 9 years, 1 month 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: content/browser/download/download_item.cc
diff --git a/content/browser/download/download_item.cc b/content/browser/download/download_item.cc
index e71366b411ce07b214b039a66cae298302f1658a..d793b1ec72765467abed07a2913fb4b1feb742f8 100644
--- a/content/browser/download/download_item.cc
+++ b/content/browser/download/download_item.cc
@@ -92,20 +92,23 @@ 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.
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 +190,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 +467,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 +677,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 +701,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(),

Powered by Google App Engine
This is Rietveld 408576698