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

Unified Diff: chrome/browser/download/notification/download_notification_item.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: Remove RETRY and use RESUME instead Created 5 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
« no previous file with comments | « chrome/browser/download/notification/download_notification_item.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/notification/download_notification_item.cc
diff --git a/chrome/browser/download/notification/download_notification_item.cc b/chrome/browser/download/notification/download_notification_item.cc
index 8345ff2a915801186c502248225b3f6ad0fa7dd6..db99ac508c3226f470b5dc160c5024340bf0dd97 100644
--- a/chrome/browser/download/notification/download_notification_item.cc
+++ b/chrome/browser/download/notification/download_notification_item.cc
@@ -11,12 +11,15 @@
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/notifications/profile_notification.h"
+#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
+#include "chrome/common/url_constants.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_interrupt_reasons.h"
#include "content/public/browser/download_item.h"
+#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -113,14 +116,22 @@ DownloadNotificationItem::~DownloadNotificationItem() {
void DownloadNotificationItem::OnNotificationClick() {
if (openable_) {
- if (item_->IsDone())
+ if (item_->IsDone()) {
item_->OpenDownload();
- else
+ CloseNotificationByUser();
+ } else {
item_->SetOpenWhenComplete(!item_->GetOpenWhenComplete()); // Toggle
- }
-
- if (item_->IsDone())
+ }
+ } else if (item_->GetState() == content::DownloadItem::INTERRUPTED ||
+ item_->GetState() == content::DownloadItem::CANCELLED) {
+ GetBrowser()->OpenURL(content::OpenURLParams(
+ GURL(chrome::kChromeUIDownloadsURL), content::Referrer(),
+ NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK,
+ false /* is_renderer_initiated */));
+ CloseNotificationByUser();
+ } else if (item_->IsDone()) {
CloseNotificationByUser();
+ }
}
void DownloadNotificationItem::OnNotificationButtonClick(int button_index) {
@@ -330,7 +341,8 @@ DownloadNotificationItem::GetPossibleActions() const {
break;
case content::DownloadItem::CANCELLED:
case content::DownloadItem::INTERRUPTED:
- actions->push_back(DownloadCommands::RETRY);
+ if (item_->CanResume())
+ actions->push_back(DownloadCommands::RESUME);
break;
case content::DownloadItem::COMPLETE:
actions->push_back(DownloadCommands::OPEN_WHEN_COMPLETE);
@@ -389,10 +401,6 @@ base::string16 DownloadNotificationItem::GetCommandLabel(
case DownloadCommands::SHOW_IN_FOLDER:
id = IDS_DOWNLOAD_LINK_SHOW;
break;
- case DownloadCommands::RETRY:
- // Only for non menu.
- id = IDS_DOWNLOAD_LINK_RETRY;
- break;
case DownloadCommands::DISCARD:
id = IDS_DISCARD_DOWNLOAD;
break;
@@ -455,3 +463,10 @@ base::string16 DownloadNotificationItem::GetWarningText() const {
NOTREACHED();
return base::string16();
}
+
+Browser* DownloadNotificationItem::GetBrowser() {
+ chrome::ScopedTabbedBrowserDisplayer browser_displayer(
+ profile_, chrome::GetActiveDesktop());
+ DCHECK(browser_displayer.browser());
+ return browser_displayer.browser();
+}
« no previous file with comments | « chrome/browser/download/notification/download_notification_item.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698