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

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

Issue 2093953002: Introduce a new API to handle native notification clicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 5 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
new file mode 100644
index 0000000000000000000000000000000000000000..3e21f926c3f27b7e4ec54d03c34dc953aadd7b9a
--- /dev/null
+++ b/chrome/browser/notifications/non_persistent_notification_handler.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/notifications/non_persistent_notification_handler.h"
+
+#include "chrome/browser/notifications/notification_delegate.h"
+#include "chrome/browser/notifications/platform_notification_service_impl.h"
+
+NonPersistentNotificationHandler::NonPersistentNotificationHandler() {}
+NonPersistentNotificationHandler::~NonPersistentNotificationHandler() {}
+
+void NonPersistentNotificationHandler::OnClose(
+ Profile* profile,
+ 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);
+ }
+}
+
+void NonPersistentNotificationHandler::OnClick(
+ Profile* profile,
+ const std::string& origin,
+ const std::string& notification_id,
+ int action_index) {
+ // Buttons not supported for non persistent notifications.
+ DCHECK_EQ(action_index, -1);
+ if (notifications_.find(notification_id) != notifications_.end()) {
+ notifications_[notification_id]->Click();
+ }
+}
+
+void NonPersistentNotificationHandler::OpenSettings(Profile* profile) {
+ NotificationCommon::OpenNotificationSettings(profile);
+}
+
+void NonPersistentNotificationHandler::RegisterNotification(
+ const std::string& notification_id,
+ NotificationDelegate* delegate) {
+ DCHECK_EQ(notifications_.count(notification_id), 0u);
+ notifications_[notification_id] =
+ scoped_refptr<NotificationDelegate>(delegate);
+}
« no previous file with comments | « chrome/browser/notifications/non_persistent_notification_handler.h ('k') | chrome/browser/notifications/notification_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698