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

Unified Diff: ash/system/web_notification/web_notification_tray.h

Issue 11189099: Re-factor Ash Message Center code part 4/4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 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: ash/system/web_notification/web_notification_tray.h
diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h
index abf4200197d53e2a855292d19a04401434e15636..eeef01b18ada3f6eb5e622e2334f6cfe4915ff96 100644
--- a/ash/system/web_notification/web_notification_tray.h
+++ b/ash/system/web_notification/web_notification_tray.h
@@ -9,9 +9,17 @@
#include "ash/system/tray/tray_background_view.h"
#include "ash/system/tray/tray_views.h"
#include "ash/system/user/login_status.h"
-#include "ash/system/web_notification/web_notification_list.h"
+#include "ash/system/web_notification/message_center.h"
#include "base/gtest_prod_util.h"
+// Status area tray for showing browser and app notifications. This hosts
+// a MessageCenter class which manages the notification list. This class
+// contains the Ash specific tray implementation.
+//
+// Note: These are not related to system notifications (i.e NotificationView
+// generated by SystemTrayItem). Visibility of one notification type or other
+// is controlled by StatusAreaWidget.
+
namespace aura {
class LocatedEvent;
}
@@ -36,78 +44,15 @@ class StatusAreaWidget;
class WebNotificationBubbleWrapper;
}
-// Status area tray for showing browser and app notifications. The client
-// (e.g. Chrome) calls [Add|Remove|Update]Notification to create and update
-// notifications in the tray. It can also implement Delegate to receive
-// callbacks when a notification is removed (closed), clicked on, or a menu
-// item is triggered.
-//
-// Note: These are not related to system notifications (i.e NotificationView
-// generated by SystemTrayItem). Visibility of one notification type or other
-// is controlled by StatusAreaWidget.
-
class ASH_EXPORT WebNotificationTray
: public internal::TrayBackgroundView,
public message_center::TrayBubbleView::Delegate,
- public message_center::WebNotificationList::Delegate,
+ public message_center::MessageCenter::Host,
public views::ButtonListener {
public:
- class ASH_EXPORT Delegate {
- public:
- virtual ~Delegate() {}
-
- // Called when the notification associated with |notification_id| is
- // removed (i.e. closed by the user).
- virtual void NotificationRemoved(const std::string& notifcation_id) = 0;
-
- // Request to disable the extension associated with |notification_id|.
- virtual void DisableExtension(const std::string& notifcation_id) = 0;
-
- // Request to disable notifications from the source of |notification_id|.
- virtual void DisableNotificationsFromSource(
- const std::string& notifcation_id) = 0;
-
- // Request to show the notification settings (|notification_id| is used
- // to identify the requesting browser context).
- virtual void ShowSettings(const std::string& notifcation_id) = 0;
-
- // Called when the notification body is clicked on.
- virtual void OnClicked(const std::string& notifcation_id) = 0;
- };
-
explicit WebNotificationTray(internal::StatusAreaWidget* status_area_widget);
virtual ~WebNotificationTray();
- // Called once to set the delegate.
- void SetDelegate(Delegate* delegate);
-
- // Add a new notification. |id| is a unique identifier, used to update or
- // remove notifications. |title| and |meesage| describe the notification text.
- // Use SetNotificationImage to set the icon image. If |extension_id| is
- // provided then 'Disable extension' will appear in a dropdown menu and the
- // id will be used to disable notifications from the extension. Otherwise if
- // |display_source| is provided, a menu item showing the source and allowing
- // notifications from that source to be disabled will be shown. All actual
- // disabling is handled by the Delegate.
- void AddNotification(const std::string& id,
- const string16& title,
- const string16& message,
- const string16& display_source,
- const std::string& extension_id);
-
- // Update an existing notification with id = old_id and set its id to new_id.
- void UpdateNotification(const std::string& old_id,
- const std::string& new_id,
- const string16& title,
- const string16& message);
-
- // Remove an existing notification.
- void RemoveNotification(const std::string& id);
-
- // Set the notification image.
- void SetNotificationImage(const std::string& id,
- const gfx::ImageSkia& image);
-
// Set whether or not the popup notifications should be hidden.
void SetHidePopupBubble(bool hide);
@@ -120,6 +65,10 @@ class ASH_EXPORT WebNotificationTray
// Returns true if the mouse is inside the notification bubble.
bool IsMouseInNotificationBubble() const;
+ message_center::MessageCenter* message_center() {
+ return message_center_.get();
+ }
+
// Overridden from TrayBackgroundView.
virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
virtual void AnchorUpdated() OVERRIDE;
@@ -142,14 +91,8 @@ class ASH_EXPORT WebNotificationTray
virtual void HideBubble(
const message_center::TrayBubbleView* bubble_view) OVERRIDE;
- // Overridden from message_center::WebNotificationList::Delegate.
- virtual void SendRemoveNotification(const std::string& id) OVERRIDE;
- virtual void SendRemoveAllNotifications() OVERRIDE;
- virtual void DisableNotificationByExtension(const std::string& id) OVERRIDE;
- virtual void DisableNotificationByUrl(const std::string& id) OVERRIDE;
- virtual void ShowNotificationSettings(const std::string& id) OVERRIDE;
- virtual void OnNotificationClicked(const std::string& id) OVERRIDE;
- virtual message_center::WebNotificationList* GetNotificationList() OVERRIDE;
+ // Overridden from message_center::MessageCenter::Host.
+ virtual void MessageCenterChanged(bool new_notification);
// Overridden from ButtonListener.
virtual void ButtonPressed(views::Button* sender,
@@ -180,13 +123,6 @@ class ASH_EXPORT WebNotificationTray
// Updates the tray icon and visibility.
void UpdateTray();
- // As above but also updates any visible bubble.
- void UpdateTrayAndBubble();
-
- message_center::WebNotificationList* notification_list() {
- return notification_list_.get();
- }
-
internal::WebNotificationBubbleWrapper* message_center_bubble() const {
return message_center_bubble_.get();
}
@@ -199,11 +135,10 @@ class ASH_EXPORT WebNotificationTray
message_center::MessageCenterBubble* GetMessageCenterBubbleForTest();
message_center::PopupBubble* GetPopupBubbleForTest();
- scoped_ptr<message_center::WebNotificationList> notification_list_;
+ scoped_ptr<message_center::MessageCenter> message_center_;
scoped_ptr<internal::WebNotificationBubbleWrapper> message_center_bubble_;
scoped_ptr<internal::WebNotificationBubbleWrapper> popup_bubble_;
views::ImageButton* button_;
- Delegate* delegate_;
bool show_message_center_on_unlock_;
DISALLOW_COPY_AND_ASSIGN(WebNotificationTray);

Powered by Google App Engine
This is Rietveld 408576698