Modify ExtensionApps to set the has_badge flag.
Modify ExtensionApps to observe the notification service. If there are
app notifications to be displayed, set the has_badge flag for the app as
true.
BUG=1068884
Change-Id: I71a86857b94a1be82507461e8a07dd39ed62da61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2160646
Commit-Queue: Nancy Wang <[email protected]>
Reviewed-by: Travis Skare <[email protected]>
Reviewed-by: Dominick Ng <[email protected]>
Reviewed-by: Peter Beverloo <[email protected]>
Cr-Commit-Position: refs/heads/master@{#762222}
diff --git a/chrome/browser/notifications/notification_display_service.h b/chrome/browser/notifications/notification_display_service.h
index a9ee846..1d6be64 100644
--- a/chrome/browser/notifications/notification_display_service.h
+++ b/chrome/browser/notifications/notification_display_service.h
@@ -12,6 +12,7 @@
#include "base/callback_forward.h"
#include "base/macros.h"
+#include "base/observer_list_types.h"
#include "chrome/browser/notifications/notification_common.h"
#include "chrome/browser/notifications/notification_handler.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -27,6 +28,25 @@
// center provided by the platform, or by Chrome's Message Center.
class NotificationDisplayService : public KeyedService {
public:
+ class Observer : public base::CheckedObserver {
+ public:
+ // Invoked when the |notification| is displayed.
+ virtual void OnDisplay(
+ const message_center::Notification& notification) = 0;
+
+ // Invoked when the notification having |notification_id| is closed.
+ virtual void OnClose(const std::string& notification_id) = 0;
+
+ // Invoked when the NotificationDisplayService object (the thing that this
+ // observer observes) will be destroyed. In response, the observer, |this|,
+ // should call "RemoveObserver(this)", whether directly or indirectly (e.g.
+ // via ScopedObserver::Remove).
+ virtual void OnWillBeDestroyed(NotificationDisplayService* service) = 0;
+
+ protected:
+ ~Observer() override;
+ };
+
~NotificationDisplayService() override;
// Callback to be used with the GetDisplayed() method. Includes the set of
@@ -58,6 +78,10 @@
// once available. Not all backends support retrieving this information.
virtual void GetDisplayed(DisplayedNotificationsCallback callback) = 0;
+ // Adds and removes an observer.
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+
protected:
NotificationDisplayService() = default;