| 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 "base/strings/nullable_string16.h" | 7 #include "base/strings/nullable_string16.h" |
| 8 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 8 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 9 #include "content/public/browser/notification_event_dispatcher.h" | 9 #include "content/public/browser/notification_event_dispatcher.h" |
| 10 | 10 |
| 11 NonPersistentNotificationHandler::NonPersistentNotificationHandler() = default; | 11 NonPersistentNotificationHandler::NonPersistentNotificationHandler() = default; |
| 12 NonPersistentNotificationHandler::~NonPersistentNotificationHandler() = default; | 12 NonPersistentNotificationHandler::~NonPersistentNotificationHandler() = default; |
| 13 | 13 |
| 14 void NonPersistentNotificationHandler::OnShow( |
| 15 Profile* profile, |
| 16 const std::string& notification_id) { |
| 17 content::NotificationEventDispatcher::GetInstance() |
| 18 ->DispatchNonPersistentShowEvent(notification_id); |
| 19 } |
| 20 |
| 14 void NonPersistentNotificationHandler::OnClose( | 21 void NonPersistentNotificationHandler::OnClose( |
| 15 Profile* profile, | 22 Profile* profile, |
| 16 const std::string& origin, | 23 const std::string& origin, |
| 17 const std::string& notification_id, | 24 const std::string& notification_id, |
| 18 bool by_user) { | 25 bool by_user) { |
| 19 content::NotificationEventDispatcher::GetInstance() | 26 content::NotificationEventDispatcher::GetInstance() |
| 20 ->DispatchNonPersistentCloseEvent(notification_id); | 27 ->DispatchNonPersistentCloseEvent(notification_id); |
| 21 } | 28 } |
| 22 | 29 |
| 23 void NonPersistentNotificationHandler::OnClick( | 30 void NonPersistentNotificationHandler::OnClick( |
| 24 Profile* profile, | 31 Profile* profile, |
| 25 const std::string& origin, | 32 const std::string& origin, |
| 26 const std::string& notification_id, | 33 const std::string& notification_id, |
| 27 int action_index, | 34 int action_index, |
| 28 const base::NullableString16& reply) { | 35 const base::NullableString16& reply) { |
| 29 DCHECK(reply.is_null()); | 36 DCHECK(reply.is_null()); |
| 30 | 37 |
| 31 // Non persistent notifications don't allow buttons. | 38 // Non persistent notifications don't allow buttons. |
| 32 // https://notifications.spec.whatwg.org/#create-a-notification | 39 // https://notifications.spec.whatwg.org/#create-a-notification |
| 33 DCHECK_EQ(-1, action_index); | 40 DCHECK_EQ(-1, action_index); |
| 34 | 41 |
| 35 content::NotificationEventDispatcher::GetInstance() | 42 content::NotificationEventDispatcher::GetInstance() |
| 36 ->DispatchNonPersistentClickEvent(notification_id); | 43 ->DispatchNonPersistentClickEvent(notification_id); |
| 37 } | 44 } |
| 38 | 45 |
| 39 void NonPersistentNotificationHandler::OpenSettings(Profile* profile) { | 46 void NonPersistentNotificationHandler::OpenSettings(Profile* profile) { |
| 40 NotificationCommon::OpenNotificationSettings(profile); | 47 NotificationCommon::OpenNotificationSettings(profile); |
| 41 } | 48 } |
| OLD | NEW |