Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/notifications/non_persistent_notification_handler.h" | 5 #include "chrome/browser/notifications/non_persistent_notification_handler.h" |
| 6 | 6 |
| 7 #include "chrome/browser/notifications/notification_delegate.h" | 7 #include "chrome/browser/notifications/notification_delegate.h" |
| 8 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 8 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 9 | 9 |
| 10 NonPersistentNotificationHandler::NonPersistentNotificationHandler() {} | 10 NonPersistentNotificationHandler::NonPersistentNotificationHandler() {} |
| 11 NonPersistentNotificationHandler::~NonPersistentNotificationHandler() {} | 11 NonPersistentNotificationHandler::~NonPersistentNotificationHandler() {} |
| 12 | 12 |
| 13 void NonPersistentNotificationHandler::OnClose( | 13 void NonPersistentNotificationHandler::OnClose( |
| 14 Profile* profile, | 14 Profile* profile, |
| 15 const std::string& origin, | 15 const std::string& origin, |
| 16 const std::string& notification_id, | 16 const std::string& notification_id, |
| 17 bool by_user) { | 17 bool by_user) { |
| 18 if (notifications_.find(notification_id) != notifications_.end()) { | 18 if (notifications_.find(notification_id) != notifications_.end()) { |
| 19 notifications_[notification_id]->Close(by_user); | 19 notifications_[notification_id]->Close(by_user); |
| 20 notifications_.erase(notification_id); | 20 notifications_.erase(notification_id); |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 void NonPersistentNotificationHandler::OnClick( | 24 void NonPersistentNotificationHandler::OnClick( |
| 25 Profile* profile, | 25 Profile* profile, |
| 26 const std::string& origin, | 26 const std::string& origin, |
| 27 const std::string& notification_id, | 27 const std::string& notification_id, |
| 28 int action_index) { | 28 int action_index, |
| 29 const base::NullableString16& reply) { | |
|
Peter Beverloo
2016/10/12 13:58:31
Could we DCHECK(reply.is_null()) since we don't su
awdf
2016/10/12 17:04:01
Done.
| |
| 29 // Buttons not supported for non persistent notifications. | 30 // Buttons not supported for non persistent notifications. |
| 30 DCHECK_EQ(action_index, -1); | 31 DCHECK_EQ(action_index, -1); |
| 31 if (notifications_.find(notification_id) != notifications_.end()) { | 32 if (notifications_.find(notification_id) != notifications_.end()) { |
| 32 notifications_[notification_id]->Click(); | 33 notifications_[notification_id]->Click(); |
| 33 } | 34 } |
| 34 } | 35 } |
| 35 | 36 |
| 36 void NonPersistentNotificationHandler::OpenSettings(Profile* profile) { | 37 void NonPersistentNotificationHandler::OpenSettings(Profile* profile) { |
| 37 NotificationCommon::OpenNotificationSettings(profile); | 38 NotificationCommon::OpenNotificationSettings(profile); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void NonPersistentNotificationHandler::RegisterNotification( | 41 void NonPersistentNotificationHandler::RegisterNotification( |
| 41 const std::string& notification_id, | 42 const std::string& notification_id, |
| 42 NotificationDelegate* delegate) { | 43 NotificationDelegate* delegate) { |
| 43 DCHECK_EQ(notifications_.count(notification_id), 0u); | 44 DCHECK_EQ(notifications_.count(notification_id), 0u); |
| 44 notifications_[notification_id] = | 45 notifications_[notification_id] = |
| 45 scoped_refptr<NotificationDelegate>(delegate); | 46 scoped_refptr<NotificationDelegate>(delegate); |
| 46 } | 47 } |
| OLD | NEW |