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

Unified Diff: chrome/browser/download/download_util.cc

Issue 8558029: Update download page to deal with new DANGEROUS_CONTENT state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " 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
« no previous file with comments | « no previous file | chrome/browser/resources/active_downloads.js » ('j') | chrome/browser/resources/downloads.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_util.cc
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 737b829de006e9d6acad8d5d5f9aa1d79ddb6c2c..ddd87e21c6b642a27e7cb34e27b2479c2c99fe3e 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -83,6 +83,29 @@
// 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.
achuithb 2011/11/21 21:34:36 Does a NOTREACHED() make sense here? If we ever ge
asanka 2011/11/21 22:46:58 It did have a NOTREACHED(), but I removed it becau
+ return "";
+ }
+}
+
+} // namespace
+
namespace download_util {
// How many times to cycle the complete animation. This should be an odd number
@@ -428,11 +451,13 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) {
if (download->IsInProgress()) {
if (download->safety_state() == 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->is_paused()) {
file_value->SetString("state", "PAUSED");
« no previous file with comments | « no previous file | chrome/browser/resources/active_downloads.js » ('j') | chrome/browser/resources/downloads.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698