Index: chrome/browser/automation/testing_automation_provider.cc |
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc |
index e44edb89d1a47a73097e7f6f7d05f855c427c759..a4f54144ce7318643d9d701aa0c3caea69a1b83a 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -2612,11 +2612,16 @@ void TestingAutomationProvider::PerformActionOnDownload( |
return; |
} |
+ DownloadItem::DownloadState download_state = selected_item->GetState(); |
+ |
// We need to be IN_PROGRESS for these actions. |
if ((action == "pause" || action == "resume" || action == "cancel") && |
- !selected_item->IsInProgress()) { |
+ download_state != DownloadItem::IN_PROGRESS) { |
AutomationJSONReply(this, reply_message) |
- .SendError("Selected DownloadItem is not in progress."); |
+ .SendError(base::StringPrintf( |
+ "Action '%s' called on download that is not in progress.", |
+ action.c_str())); |
+ return; |
} |
if (action == "open") { |
@@ -2646,32 +2651,22 @@ void TestingAutomationProvider::PerformActionOnDownload( |
this, reply_message, false, browser->profile()->IsOffTheRecord())); |
selected_item->ValidateDangerousDownload(); |
} else if (action == "pause") { |
- if (!selected_item->IsInProgress() || selected_item->IsPaused()) { |
+ if (selected_item->IsPaused()) { |
// Action would be a no-op; respond right from here. No-op implies |
// the test is poorly written or failing, so make it an error return. |
- if (!selected_item->IsInProgress()) { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Action 'pause' called on download in termal state."); |
- } else { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Action 'pause' called on already paused download."); |
- } |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("Action 'pause' called on already paused download."); |
} else { |
selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( |
this, reply_message, false, browser->profile()->IsOffTheRecord())); |
selected_item->Pause(); |
} |
} else if (action == "resume") { |
- if (!selected_item->IsInProgress() || !selected_item->IsPaused()) { |
+ if (!selected_item->IsPaused()) { |
// Action would be a no-op; respond right from here. No-op implies |
// the test is poorly written or failing, so make it an error return. |
- if (!selected_item->IsInProgress()) { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Action 'resume' called on download in termal state."); |
- } else { |
- AutomationJSONReply(this, reply_message) |
- .SendError("Action 'resume' called on unpaused download."); |
- } |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("Action 'resume' called on unpaused download."); |
} else { |
selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( |
this, reply_message, false, browser->profile()->IsOffTheRecord())); |