Index: chrome/browser/ui/webui/downloads_dom_handler.cc |
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc |
index d0b83a59d9daf8d3c687345d74d53469eda5e84f..3600c5f5cdd41c4816669f6475e97ecfb57e4d19 100644 |
--- a/chrome/browser/ui/webui/downloads_dom_handler.cc |
+++ b/chrome/browser/ui/webui/downloads_dom_handler.cc |
@@ -147,59 +147,68 @@ DictionaryValue* CreateDownloadItemValue( |
file_value->SetBoolean("retry", false); // Overridden below if needed. |
file_value->SetBoolean("resume", download_item->CanResume()); |
- if (download_item->IsInProgress()) { |
- if (download_item->IsDangerous()) { |
- file_value->SetString("state", "DANGEROUS"); |
- // These are the only danger states that the UI is equipped to handle. |
- DCHECK(download_item->GetDangerType() == |
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || |
- download_item->GetDangerType() == |
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
- download_item->GetDangerType() == |
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
- download_item->GetDangerType() == |
- content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || |
- download_item->GetDangerType() == |
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST); |
- const char* danger_type_value = |
- GetDangerTypeString(download_item->GetDangerType()); |
- file_value->SetString("danger_type", danger_type_value); |
- } else if (download_item->IsPaused()) { |
- file_value->SetString("state", "PAUSED"); |
- } else { |
- file_value->SetString("state", "IN_PROGRESS"); |
- } |
- |
- file_value->SetString("progress_status_text", |
- download_util::GetProgressStatusText(download_item)); |
- |
- file_value->SetInteger("percent", |
- static_cast<int>(download_item->PercentComplete())); |
- file_value->SetInteger("received", |
- static_cast<int>(download_item->GetReceivedBytes())); |
- } else if (download_item->IsInterrupted()) { |
- file_value->SetString("state", "INTERRUPTED"); |
- |
- file_value->SetString("progress_status_text", |
- download_util::GetProgressStatusText(download_item)); |
- |
- file_value->SetInteger("percent", |
- static_cast<int>(download_item->PercentComplete())); |
- file_value->SetInteger("received", |
- static_cast<int>(download_item->GetReceivedBytes())); |
- file_value->SetString("last_reason_text", |
- download_model.GetInterruptReasonText()); |
- if (content::DOWNLOAD_INTERRUPT_REASON_CRASH == |
- download_item->GetLastReason() && !download_item->CanResume()) |
+ switch (download_item->GetState()) { |
+ case content::DownloadItem::IN_PROGRESS: |
+ if (download_item->IsDangerous()) { |
+ file_value->SetString("state", "DANGEROUS"); |
+ // These are the only danger states that the UI is equipped to handle. |
+ DCHECK(download_item->GetDangerType() == |
+ content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE || |
+ download_item->GetDangerType() == |
+ content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || |
+ download_item->GetDangerType() == |
+ content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT || |
+ download_item->GetDangerType() == |
+ content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || |
+ download_item->GetDangerType() == |
+ content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST); |
+ const char* danger_type_value = |
+ GetDangerTypeString(download_item->GetDangerType()); |
+ file_value->SetString("danger_type", danger_type_value); |
+ } else if (download_item->IsPaused()) { |
+ file_value->SetString("state", "PAUSED"); |
+ } else { |
+ file_value->SetString("state", "IN_PROGRESS"); |
+ } |
+ |
+ file_value->SetString("progress_status_text", |
+ download_util::GetProgressStatusText(download_item)); |
+ |
+ file_value->SetInteger("percent", |
+ static_cast<int>(download_item->PercentComplete())); |
+ file_value->SetInteger("received", |
+ static_cast<int>(download_item->GetReceivedBytes())); |
+ break; |
+ |
+ case content::DownloadItem::INTERRUPTED: |
+ file_value->SetString("state", "INTERRUPTED"); |
+ |
+ file_value->SetString("progress_status_text", |
+ download_util::GetProgressStatusText(download_item)); |
+ |
+ file_value->SetInteger("percent", |
+ static_cast<int>(download_item->PercentComplete())); |
+ file_value->SetInteger("received", |
+ static_cast<int>(download_item->GetReceivedBytes())); |
+ file_value->SetString("last_reason_text", |
+ download_model.GetInterruptReasonText()); |
+ if (content::DOWNLOAD_INTERRUPT_REASON_CRASH == |
+ download_item->GetLastReason() && !download_item->CanResume()) |
+ file_value->SetBoolean("retry", true); |
+ break; |
+ |
+ case content::DownloadItem::CANCELLED: |
+ file_value->SetString("state", "CANCELLED"); |
file_value->SetBoolean("retry", true); |
- } else if (download_item->IsCancelled()) { |
- file_value->SetString("state", "CANCELLED"); |
- file_value->SetBoolean("retry", true); |
- } else if (download_item->IsComplete()) { |
- DCHECK(!download_item->IsDangerous()); |
- file_value->SetString("state", "COMPLETE"); |
- } else { |
- NOTREACHED() << "state undefined"; |
+ break; |
+ |
+ case content::DownloadItem::COMPLETE: |
+ DCHECK(!download_item->IsDangerous()); |
+ file_value->SetString("state", "COMPLETE"); |
+ break; |
+ |
+ case content::DownloadItem::MAX_DOWNLOAD_STATE: |
+ NOTREACHED() << "state undefined"; |
} |
return file_value; |