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

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: Created 7 years, 7 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
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()));

Powered by Google App Engine
This is Rietveld 408576698