diff options
-rw-r--r-- | chrome/browser/download/download_util.cc | 32 | ||||
-rw-r--r-- | chrome/browser/resources/active_downloads.js | 2 | ||||
-rw-r--r-- | chrome/browser/resources/downloads.js | 3 |
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); |