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

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

Issue 2916383004: Revert of Minimize the delegate dependencies for non persistent notifications. (Closed)
Patch Set: 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 091aff5635eac17a0e703028f128b7420dc00998..9a33f5360089a844572c0c027f1722defb9f2b20 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,8 +16,10 @@
const std::string& origin,
const std::string& notification_id,
bool by_user) {
- content::NotificationEventDispatcher::GetInstance()
- ->DispatchNonPersistentCloseEvent(notification_id);
+ if (notifications_.find(notification_id) != notifications_.end()) {
+ notifications_[notification_id]->Close(by_user);
+ notifications_.erase(notification_id);
+ }
}
void NonPersistentNotificationHandler::OnClick(
@@ -28,14 +30,21 @@
const base::NullableString16& reply) {
DCHECK(reply.is_null());
- // 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);
+ if (notifications_.find(notification_id) != notifications_.end()) {
+ if (action_index >= 0)
+ notifications_[notification_id]->ButtonClick(action_index);
+ else
+ notifications_[notification_id]->Click();
+ }
}
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