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

Unified Diff: chrome/browser/download/download_shelf.cc

Issue 3127008: Preliminary work on resuming downloads whose connections have expired.
Patch Set: Waiting to send download automation error message until after other downloads are canceled. Created 10 years, 3 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/download/download_shelf.cc
diff --git a/chrome/browser/download/download_shelf.cc b/chrome/browser/download/download_shelf.cc
index dc69d02c4f029000180e3a49fea680e723f76f25..5adc587faeb2e07225e9bf21d443d0aeb57d543f 100644
--- a/chrome/browser/download/download_shelf.cc
+++ b/chrome/browser/download/download_shelf.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/download/download_shelf.h"
#include "app/l10n_util.h"
+#include "base/command_line.h"
#include "base/file_util.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/dom_ui/downloads_ui.h"
@@ -14,6 +15,7 @@
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/common/url_constants.h"
+#include "chrome/common/chrome_switches.h"
#include "grit/generated_resources.h"
// DownloadShelfContextMenu ----------------------------------------------------
@@ -50,7 +52,7 @@ string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const {
case CANCEL:
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL);
case TOGGLE_PAUSE: {
- if (download_->is_paused())
+ if (download_->is_paused() || download_->IsInterruptedDownload())
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM);
else
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM);
@@ -62,6 +64,8 @@ string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const {
}
bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
+ static bool can_restart = CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableDownloadRestarts);
switch (command_id) {
case SHOW_IN_FOLDER:
case OPEN_WHEN_COMPLETE:
@@ -69,9 +73,11 @@ bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
case ALWAYS_OPEN_TYPE:
return download_->CanOpenDownload();
case CANCEL:
- return download_->state() == DownloadItem::IN_PROGRESS;
+ return download_->IsPartialDownload();
case TOGGLE_PAUSE:
- return download_->state() == DownloadItem::IN_PROGRESS;
+ return ((download_->state() == DownloadItem::IN_PROGRESS) ||
+ (can_restart &&
+ (download_->IsInterruptedDownload())));
default:
return command_id > 0 && command_id < MENU_LAST;
}
@@ -97,7 +103,7 @@ void DownloadShelfContextMenu::ExecuteCommand(int command_id) {
// It is possible for the download to complete before the user clicks the
// menu item, recheck if the download is in progress state before toggling
// pause.
- if (download_->state() == DownloadItem::IN_PROGRESS)
+ if (download_->IsPartialDownload())
download_->TogglePause();
break;
default:

Powered by Google App Engine
This is Rietveld 408576698