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

Unified Diff: chrome/browser/notifications/non_persistent_notification_handler.cc

Issue 2888303004: Minimize the delegate dependencies for non persistent notifications. (Closed)
Patch Set: review Created 3 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
Index: chrome/browser/notifications/non_persistent_notification_handler.cc
diff --git a/chrome/browser/notifications/non_persistent_notification_handler.cc b/chrome/browser/notifications/non_persistent_notification_handler.cc
index 9a33f5360089a844572c0c027f1722defb9f2b20..091aff5635eac17a0e703028f128b7420dc00998 100644
--- a/chrome/browser/notifications/non_persistent_notification_handler.cc
+++ b/chrome/browser/notifications/non_persistent_notification_handler.cc
@@ -5,8 +5,8 @@
#include "chrome/browser/notifications/non_persistent_notification_handler.h"
#include "base/strings/nullable_string16.h"
-#include "chrome/browser/notifications/notification_delegate.h"
#include "chrome/browser/notifications/platform_notification_service_impl.h"
+#include "content/public/browser/notification_event_dispatcher.h"
NonPersistentNotificationHandler::NonPersistentNotificationHandler() = default;
NonPersistentNotificationHandler::~NonPersistentNotificationHandler() = default;
@@ -16,10 +16,8 @@ void NonPersistentNotificationHandler::OnClose(
const std::string& origin,
const std::string& notification_id,
bool by_user) {
- if (notifications_.find(notification_id) != notifications_.end()) {
- notifications_[notification_id]->Close(by_user);
- notifications_.erase(notification_id);
- }
+ content::NotificationEventDispatcher::GetInstance()
+ ->DispatchNonPersistentCloseEvent(notification_id);
}
void NonPersistentNotificationHandler::OnClick(
@@ -30,21 +28,14 @@ void NonPersistentNotificationHandler::OnClick(
const base::NullableString16& reply) {
DCHECK(reply.is_null());
- if (notifications_.find(notification_id) != notifications_.end()) {
- if (action_index >= 0)
- notifications_[notification_id]->ButtonClick(action_index);
- else
- notifications_[notification_id]->Click();
- }
+ // Non persistent notifications don't allow buttons.
+ // https://notifications.spec.whatwg.org/#create-a-notification
+ DCHECK_EQ(-1, action_index);
+
+ content::NotificationEventDispatcher::GetInstance()
+ ->DispatchNonPersistentClickEvent(notification_id);
}
void NonPersistentNotificationHandler::OpenSettings(Profile* profile) {
NotificationCommon::OpenNotificationSettings(profile);
}
-
-void NonPersistentNotificationHandler::RegisterNotification(
- const std::string& notification_id,
- NotificationDelegate* delegate) {
- notifications_[notification_id] =
- scoped_refptr<NotificationDelegate>(delegate);
-}

Powered by Google App Engine
This is Rietveld 408576698