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

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

Issue 11711003: Remove the DownloadItem::TogglePause() interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to r175145. Created 7 years, 12 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/download/download_shelf_context_menu.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 012fb4922c3121bcfa754f7a63a1ea36ffb120fb..823130a8695a0c1ae3fa3fab0834d75ab03dcefe 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -2657,7 +2657,7 @@ void TestingAutomationProvider::PerformActionOnDownload(
}
// We need to be IN_PROGRESS for these actions.
- if ((action == "toggle_pause" || action == "cancel") &&
+ if ((action == "pause" || action == "resume" || action == "cancel") &&
!selected_item->IsInProgress()) {
AutomationJSONReply(this, reply_message)
.SendError("Selected DownloadItem is not in progress.");
@@ -2689,11 +2689,38 @@ void TestingAutomationProvider::PerformActionOnDownload(
selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
this, reply_message, false, browser->profile()->IsOffTheRecord()));
selected_item->DangerousDownloadValidated();
- } else if (action == "toggle_pause") {
- selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
- this, reply_message, false, browser->profile()->IsOffTheRecord()));
- // This will still return if download has already completed.
- selected_item->TogglePause();
+ } 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.");
+ }
+ } 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.");
+ }
+ } else {
+ selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
+ this, reply_message, false, browser->profile()->IsOffTheRecord()));
+ selected_item->Resume();
+ }
} else if (action == "cancel") {
selected_item->AddObserver(new AutomationProviderDownloadUpdatedObserver(
this, reply_message, false, browser->profile()->IsOffTheRecord()));
« no previous file with comments | « no previous file | chrome/browser/download/download_shelf_context_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698