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

Unified Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 16018005: Use DownloadItem::GetState() in chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stopping complete_animation_ when download is cancelled Created 7 years, 6 months 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/chromeos/drive/download_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/download_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698