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

Side by Side Diff: chrome/browser/notifications/nonpersistent_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: initial review 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/nonpersistent_notification_handler.h"
6
7 #include "chrome/browser/notifications/notification_delegate.h"
8 #include "chrome/browser/notifications/platform_notification_service_impl.h"
9
10 NonPersistentNotificationHandler::NonPersistentNotificationHandler() {}
11 NonPersistentNotificationHandler::~NonPersistentNotificationHandler() {}
12
13 void NonPersistentNotificationHandler::Close(Profile* profile,
14 const std::string& origin,
15 const std::string& notification_id,
16 bool by_user) {
17 if (notifications_.find(notification_id) != notifications_.end()) {
18 notifications_[notification_id]->Close(by_user);
19 notifications_.erase(notification_id);
20 }
Peter Beverloo 2016/07/05 14:25:34 nit (avoids multiple lookups - elsewhere too): au
Miguel Garcia 2016/07/05 17:12:52 But unordered_map does not allow lookups by iterat
21 }
22
23 void NonPersistentNotificationHandler::Click(Profile* profile,
24 const std::string& origin,
25 const std::string& notification_id,
26 int action_index) {
27 // Buttons not supported for non persistent notifications.
28 DCHECK(action_index = -1);
Peter Beverloo 2016/07/05 14:25:34 This is not doing what you want it to do :) DCHEC
Miguel Garcia 2016/07/05 17:12:52 changed ;)
29 if (notifications_.find(notification_id) != notifications_.end()) {
30 notifications_[notification_id]->Click();
31 }
32 }
33
34 void NonPersistentNotificationHandler::Settings(Profile* profile) {
35 NotificationCommon::OpenNotificationSettings(profile);
36 }
37
38 void NonPersistentNotificationHandler::RegisterNotification(
39 const std::string& notification_id,
40 NotificationDelegate* delegate) {
41 DCHECK_EQ(notifications_.count(notification_id), 0u);
42 notifications_[notification_id] =
43 scoped_refptr<NotificationDelegate>(delegate);
44 }
45
46 NotificationCommon::Type NonPersistentNotificationHandler::NotificationType() {
47 return NotificationCommon::NONPERSISTENT;
48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698