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 9ae23bd0ad2ccbcc10ea21fb4b79e553d91abe1f..fc4592a5ba4e90b36263267198c1f7ed71a61b18 100644 |
--- a/chrome/browser/automation/testing_automation_provider.cc |
+++ b/chrome/browser/automation/testing_automation_provider.cc |
@@ -2617,9 +2617,11 @@ 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) { |
asanka
2013/05/28 18:43:15
This check is necessary for 'pause' and 'resume' g
|
AutomationJSONReply(this, reply_message) |
.SendError("Selected DownloadItem is not in progress."); |
} |
@@ -2651,32 +2653,28 @@ void TestingAutomationProvider::PerformActionOnDownload( |
this, reply_message, false, browser->profile()->IsOffTheRecord())); |
selected_item->DangerousDownloadValidated(); |
} else if (action == "pause") { |
- if (!selected_item->IsInProgress() || 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."); |
- } |
+ // If action will 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 (download_state != DownloadItem::IN_PROGRESS) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("Action 'pause' called on download in termal state."); |
+ } else if (selected_item->IsPaused()) { |
+ 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()) { |
- // 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."); |
- } |
+ // If action will 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 (download_state != DownloadItem::IN_PROGRESS) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("Action 'resume' called on download in termal state."); |
+ } else if (!selected_item->IsPaused()) { |
+ AutomationJSONReply(this, reply_message) |
+ .SendError("Action 'resume' called on unpaused download."); |
} else { |
selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver( |
this, reply_message, false, browser->profile()->IsOffTheRecord())); |