OLD | NEW |
(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/persistent_notification_handler.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 |
| 12 PersistentNotificationHandler::PersistentNotificationHandler() {} |
| 13 PersistentNotificationHandler::~PersistentNotificationHandler() {} |
| 14 |
| 15 void PersistentNotificationHandler::HandleNotificationOperation( |
| 16 notification_operation_common::NotificationOperation operation, |
| 17 Profile* profile, |
| 18 const std::string& origin, |
| 19 const std::string& notification_id, |
| 20 int action_index) { |
| 21 GURL notification_origin(origin); |
| 22 int64_t persistent_notification_id; |
| 23 if (!base::StringToInt64(notification_id, &persistent_notification_id)) { |
| 24 LOG(ERROR) << "Unable to convert notification ID: " << notification_id |
| 25 << " to integer."; |
| 26 return; |
| 27 } |
| 28 |
| 29 switch (operation) { |
| 30 case notification_operation_common::NOTIFICATION_CLICK: |
| 31 PlatformNotificationServiceImpl::GetInstance() |
| 32 ->OnPersistentNotificationClick(profile, persistent_notification_id, |
| 33 notification_origin, action_index); |
| 34 break; |
| 35 case notification_operation_common::NOTIFICATION_CLOSE: |
| 36 PlatformNotificationServiceImpl::GetInstance() |
| 37 ->OnPersistentNotificationClose(profile, persistent_notification_id, |
| 38 notification_origin, true); |
| 39 break; |
| 40 case notification_operation_common::NOTIFICATION_SETTINGS: |
| 41 notification_operation_common::OpenNotificationSettings(profile); |
| 42 break; |
| 43 } |
| 44 } |
| 45 |
| 46 void PersistentNotificationHandler::CloseNotification( |
| 47 Profile* profile, |
| 48 const std::string& notification_id) { |
| 49 // Nothing to do here since there is no state kept. |
| 50 } |
| 51 |
| 52 void PersistentNotificationHandler::RegisterNotification( |
| 53 const std::string& notification_id, |
| 54 std::unique_ptr<Notification> notification) { |
| 55 // Nothing to do here since there is no state kept. |
| 56 } |
| 57 |
| 58 notification_operation_common::NotificationHandlerType |
| 59 PersistentNotificationHandler::NotificationType() { |
| 60 return notification_operation_common::PERSISTENT_NOTIFICATION; |
| 61 } |
OLD | NEW |