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

Unified Diff: chrome/browser/download/notification/download_notification_item.h

Issue 1005393003: [Download Notification] Use NotificationUIManager instead of MessageCenter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed the comments 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
Index: chrome/browser/download/notification/download_notification_item.h
diff --git a/chrome/browser/download/notification/download_notification_item.h b/chrome/browser/download/notification/download_notification_item.h
index 6470e7a69ea8ed8def17030c7c866539d5f89f86..e39a8e5201161a4bf63fdf332efb2a9373b8e32f 100644
--- a/chrome/browser/download/notification/download_notification_item.h
+++ b/chrome/browser/download/notification/download_notification_item.h
@@ -9,14 +9,13 @@
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/download/download_commands.h"
+#include "chrome/browser/notifications/notification.h"
+#include "chrome/browser/notifications/notification_delegate.h"
+#include "chrome/browser/notifications/notification_test_util.h"
#include "content/public/browser/download_item.h"
#include "grit/theme_resources.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/message_center_observer.h"
-#include "ui/message_center/notification.h"
-#include "ui/message_center/notification_delegate.h"
-
-using message_center::Notification;
namespace test {
class DownloadNotificationItemTest;
@@ -31,35 +30,46 @@ class DownloadNotificationItem : public content::DownloadItem::Observer {
virtual void OnDownloadRemoved(DownloadNotificationItem* item) = 0;
};
- DownloadNotificationItem(content::DownloadItem* item, Delegate* delegate);
+ static const char kDownloadNotificationOrigin[];
+
+ DownloadNotificationItem(content::DownloadItem* item,
+ Profile* profile,
+ Delegate* delegate);
~DownloadNotificationItem() override;
private:
- class NotificationWatcher : public message_center::NotificationDelegate,
- public message_center::MessageCenterObserver {
+ friend class test::DownloadNotificationItemTest;
+
+ class NotificationWatcher : public NotificationDelegate {
public:
explicit NotificationWatcher(DownloadNotificationItem* item);
- private:
- ~NotificationWatcher() override;
-
- // message_center::NotificationDelegate overrides:
+ // NotificationDelegate overrides:
void Close(bool by_user) override;
void Click() override;
bool HasClickedListener() override;
void ButtonClick(int button_index) override;
+ std::string id() const override;
- // message_center::MessageCenterObserver overrides:
- void OnNotificationRemoved(const std::string& id, bool by_user) override;
+ private:
+ ~NotificationWatcher() override;
DownloadNotificationItem* item_;
};
+ // For testing. This is set by SetStubNotificationUIManagerForTesting method.
+ static StubNotificationUIManager* stub_notification_ui_manager_for_testing_;
Randy Smith (Not in Mondays) 2015/04/15 19:16:31 nit, suggestion: There's no real reason that this
+
+ // Replaces the NotificationUIManager for tests.
+ static void SetStubNotificationUIManagerForTesting(
+ StubNotificationUIManager* stub_notification_ui_manager) {
+ stub_notification_ui_manager_for_testing_ = stub_notification_ui_manager;
+ }
+
+ // Methods called from NotificationWatcher.
void OnNotificationClick();
void OnNotificationButtonClick(int button_index);
- void OnNotificationClose(bool by_user);
- void OnNotificationRemoved(bool by_user);
// DownloadItem::Observer overrides:
void OnDownloadUpdated(content::DownloadItem* item) override;
@@ -70,6 +80,8 @@ class DownloadNotificationItem : public content::DownloadItem::Observer {
void UpdateNotificationData();
void SetNotificationImage(int resource_id);
+ NotificationUIManager* notification_ui_manager() const;
+
// Returns a short one-line status string for the download.
base::string16 GetTitle() const;
@@ -84,11 +96,10 @@ class DownloadNotificationItem : public content::DownloadItem::Observer {
bool openable_;
bool downloading_;
- bool reshow_after_remove_;
int image_resource_id_;
+ Profile* profile_;
scoped_refptr<NotificationWatcher> watcher_;
- message_center::MessageCenter* message_center_;
scoped_ptr<Notification> notification_;
content::DownloadItem* item_;
@@ -96,8 +107,6 @@ class DownloadNotificationItem : public content::DownloadItem::Observer {
Delegate* const delegate_;
- friend class test::DownloadNotificationItemTest;
-
DISALLOW_COPY_AND_ASSIGN(DownloadNotificationItem);
};

Powered by Google App Engine
This is Rietveld 408576698