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::OnClose(Profile* profile, |
| 16 const std::string& origin, |
| 17 const std::string& notification_id, |
| 18 bool by_user) { |
| 19 // No need to propage back Close events from JS. |
| 20 if (!by_user) |
| 21 return; |
| 22 |
| 23 int64_t persistent_notification_id; |
| 24 GURL notification_origin(origin); |
| 25 DCHECK(notification_origin.is_valid()); |
| 26 if (!base::StringToInt64(notification_id, &persistent_notification_id)) { |
| 27 LOG(ERROR) << "Unable to convert notification ID: " << notification_id |
| 28 << " to integer."; |
| 29 return; |
| 30 } |
| 31 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClose( |
| 32 profile, persistent_notification_id, notification_origin, by_user); |
| 33 } |
| 34 |
| 35 void PersistentNotificationHandler::OnClick(Profile* profile, |
| 36 const std::string& origin, |
| 37 const std::string& notification_id, |
| 38 int action_index) { |
| 39 int64_t persistent_notification_id; |
| 40 if (!base::StringToInt64(notification_id, &persistent_notification_id)) { |
| 41 LOG(ERROR) << "Unable to convert notification ID: " << notification_id |
| 42 << " to integer."; |
| 43 return; |
| 44 } |
| 45 GURL notification_origin(origin); |
| 46 DCHECK(notification_origin.is_valid()); |
| 47 PlatformNotificationServiceImpl::GetInstance()->OnPersistentNotificationClick( |
| 48 profile, persistent_notification_id, notification_origin, action_index); |
| 49 } |
| 50 |
| 51 void PersistentNotificationHandler::OpenSettings(Profile* profile) { |
| 52 NotificationCommon::OpenNotificationSettings(profile); |
| 53 } |
| 54 |
| 55 void PersistentNotificationHandler::RegisterNotification( |
| 56 const std::string& notification_id, |
| 57 NotificationDelegate* delegate) { |
| 58 // Nothing to do here since there is no state kept. |
| 59 } |
OLD | NEW |