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

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

Issue 1087843004: [Download Notification] Refine retry logic when interrupted or cancelled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_commands.cc
diff --git a/chrome/browser/download/download_commands.cc b/chrome/browser/download/download_commands.cc
index 97784977e39b20f3f88b82ed0210bc26bebca988..32151569955c3e83004af7d0fd8ac5735e75ad26 100644
--- a/chrome/browser/download/download_commands.cc
+++ b/chrome/browser/download/download_commands.cc
@@ -15,6 +15,8 @@
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
+#include "content/public/browser/download_manager.h"
+#include "content/public/browser/download_url_parameters.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -136,6 +138,8 @@ bool DownloadCommands::IsCommandVisible(Command command) const {
}
void DownloadCommands::ExecuteCommand(Command command) {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
switch (command) {
case SHOW_IN_FOLDER:
download_item_->ShowDownloadInShell();
@@ -203,13 +207,23 @@ void DownloadCommands::ExecuteCommand(Command command) {
case RESUME:
download_item_->Resume();
break;
- case RETRY:
- if (download_item_->CanResume()) {
- download_item_->Resume();
- } else {
- // TODO(yoshiki): Implement retry logic.
- }
+ case RETRY: {
+ content::DownloadManager* download_manager =
+ content::BrowserContext::GetDownloadManager(
+ download_item_->GetBrowserContext());
+ scoped_ptr<content::DownloadUrlParameters> params(
+ content::DownloadUrlParameters::FromWebContents(
+ download_item_->GetWebContents(), download_item_->GetURL()));
asanka 2015/04/22 21:17:35 DownloadItem::GetWebContents() isn't guaranteed to
+ params->set_referrer(content::Referrer(download_item_->GetReferrerUrl(),
+ blink::WebReferrerPolicyDefault));
+
+ // Removes the previous donwload item.
+ download_item_->Remove();
+
+ // Starts new download.
+ download_manager->DownloadUrl(params.Pass());
break;
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698