summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 00:20:42 +0000
committerasanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 00:20:42 +0000
commitb5c973515f8c451a6f1799cdeccb9e8e7df488b8 (patch)
treefc76f219bb572cd2f4d3f0b5bf940f269b299aab
parentbdfc03ebd9af014a7f633a9dcb1575b599b907f0 (diff)
downloadchromium_src-b5c973515f8c451a6f1799cdeccb9e8e7df488b8.zip
chromium_src-b5c973515f8c451a6f1799cdeccb9e8e7df488b8.tar.gz
chromium_src-b5c973515f8c451a6f1799cdeccb9e8e7df488b8.tar.bz2
Update download page to deal with new DANGEROUS_CONTENT state.
Downloads that are flagged as malicious based on content will have a danger type of DANGEROUS_CONTENT. BUG=102540 TEST=Downloading something flagged as malicious by the SafeBrowsing service shows a warning dialog in the downloads page. Review URL: http://codereview.chromium.org/8558029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111051 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/download/download_util.cc32
-rw-r--r--chrome/browser/resources/active_downloads.js2
-rw-r--r--chrome/browser/resources/downloads.js3
3 files changed, 33 insertions, 4 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 7f587b1..4680585 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -83,6 +83,30 @@
// the same value on all platforms.
static const double PI = 3.141592653589793;
+namespace {
+
+// Returns a string constant to be used as the |danger_type| value in
+// CreateDownloadItemValue(). We only return strings for DANGEROUS_FILE,
+// DANGEROUS_URL and DANGEROUS_CONTENT because the |danger_type| value is only
+// defined if the value of |state| is |DANGEROUS|.
+const char* GetDangerTypeString(DownloadStateInfo::DangerType danger_type) {
+ switch (danger_type) {
+ case DownloadStateInfo::DANGEROUS_FILE:
+ return "DANGEROUS_FILE";
+ case DownloadStateInfo::DANGEROUS_URL:
+ return "DANGEROUS_URL";
+ case DownloadStateInfo::DANGEROUS_CONTENT:
+ return "DANGEROUS_CONTENT";
+ default:
+ // We shouldn't be returning a danger type string if it is
+ // NOT_DANGEROUS or MAYBE_DANGEROUS_CONTENT.
+ NOTREACHED();
+ return "";
+ }
+}
+
+} // namespace
+
namespace download_util {
// How many times to cycle the complete animation. This should be an odd number
@@ -428,11 +452,13 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) {
if (download->IsInProgress()) {
if (download->GetSafetyState() == DownloadItem::DANGEROUS) {
file_value->SetString("state", "DANGEROUS");
+ // These are the only danger states we expect to see (and the UI is
+ // equipped to handle):
DCHECK(download->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE ||
- download->GetDangerType() == DownloadStateInfo::DANGEROUS_URL);
+ download->GetDangerType() == DownloadStateInfo::DANGEROUS_URL ||
+ download->GetDangerType() == DownloadStateInfo::DANGEROUS_CONTENT);
const char* danger_type_value =
- download->GetDangerType() == DownloadStateInfo::DANGEROUS_FILE ?
- "DANGEROUS_FILE" : "DANGEROUS_URL";
+ GetDangerTypeString(download->GetDangerType());
file_value->SetString("danger_type", danger_type_value);
} else if (download->IsPaused()) {
file_value->SetString("state", "PAUSED");
diff --git a/chrome/browser/resources/active_downloads.js b/chrome/browser/resources/active_downloads.js
index 5908c3c..590d639 100644
--- a/chrome/browser/resources/active_downloads.js
+++ b/chrome/browser/resources/active_downloads.js
@@ -382,7 +382,7 @@ DownloadRow.prototype = {
// Handle dangerous files, extensions and dangerous urls.
var dangerText;
- if (dangerType == 'DANGEROUS_URL') {
+ if (dangerType == 'DANGEROUS_URL' || dangerType == 'DANGEROUS_CONTENT') {
dangerText = localStrings.getString('dangerousurl');
} else if (dangerType == 'DANGEROUS_FILE' && this.path.match(/\.crx$/)) {
dangerText = localStrings.getString('dangerousextension');
diff --git a/chrome/browser/resources/downloads.js b/chrome/browser/resources/downloads.js
index ec8148d..9e78342 100644
--- a/chrome/browser/resources/downloads.js
+++ b/chrome/browser/resources/downloads.js
@@ -305,6 +305,7 @@ Download.DangerType = {
NOT_DANGEROUS: "NOT_DANGEROUS",
DANGEROUS_FILE: "DANGEROUS_FILE",
DANGEROUS_URL: "DANGEROUS_URL",
+ DANGEROUS_CONTENT: "DANGEROUS_CONTENT"
}
/**
@@ -347,6 +348,7 @@ Download.prototype.update = function(download) {
this.dangerDesc_.textContent = localStrings.getStringF('danger_file_desc',
this.fileName_);
} else {
+ // This is used by both DANGEROUS_URL and DANGEROUS_CONTENT.
this.dangerDesc_.textContent = localStrings.getString('danger_url_desc');
}
this.danger_.style.display = 'block';
@@ -462,6 +464,7 @@ Download.prototype.getStatusText_ = function() {
case Download.States.PAUSED:
return localStrings.getString('status_paused');
case Download.States.DANGEROUS:
+ // danger_url_desc is also used by DANGEROUS_CONTENT.
var desc = this.dangerType_ == Download.DangerType.DANGEROUS_FILE ?
'danger_file_desc' : 'danger_url_desc';
return localStrings.getString(desc);