Index: chrome/browser/notifications/persistent_notification_handler.cc |
diff --git a/chrome/browser/notifications/persistent_notification_handler.cc b/chrome/browser/notifications/persistent_notification_handler.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..92c5dadad5142a74d8b94d324170a6097b867066 |
--- /dev/null |
+++ b/chrome/browser/notifications/persistent_notification_handler.cc |
@@ -0,0 +1,61 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/notifications/persistent_notification_handler.h" |
+ |
+#include "base/logging.h" |
+#include "base/strings/string_number_conversions.h" |
+#include "chrome/browser/notifications/platform_notification_service_impl.h" |
+#include "chrome/browser/profiles/profile.h" |
+ |
+PersistentNotificationHandler::PersistentNotificationHandler() {} |
+PersistentNotificationHandler::~PersistentNotificationHandler() {} |
+ |
+void PersistentNotificationHandler::HandleNotificationOperation( |
+ notification_operation_common::NotificationOperation operation, |
+ Profile* profile, |
+ const std::string& origin, |
+ const std::string& notification_id, |
+ int action_index) { |
+ GURL notification_origin(origin); |
+ int64_t persistent_notification_id; |
+ if (!base::StringToInt64(notification_id, &persistent_notification_id)) { |
+ LOG(ERROR) << "Unable to convert notification ID: " << notification_id |
+ << " to integer."; |
+ return; |
+ } |
+ |
+ switch (operation) { |
+ case notification_operation_common::NOTIFICATION_CLICK: |
+ PlatformNotificationServiceImpl::GetInstance() |
+ ->OnPersistentNotificationClick(profile, persistent_notification_id, |
+ notification_origin, action_index); |
+ break; |
+ case notification_operation_common::NOTIFICATION_CLOSE: |
+ PlatformNotificationServiceImpl::GetInstance() |
+ ->OnPersistentNotificationClose(profile, persistent_notification_id, |
+ notification_origin, true); |
+ break; |
+ case notification_operation_common::NOTIFICATION_SETTINGS: |
+ notification_operation_common::OpenNotificationSettings(profile); |
+ break; |
+ } |
+} |
+ |
+void PersistentNotificationHandler::CloseNotification( |
+ Profile* profile, |
+ const std::string& notification_id) { |
+ // Nothing to do here since there is no state kept. |
+} |
+ |
+void PersistentNotificationHandler::RegisterNotification( |
+ const std::string& notification_id, |
+ std::unique_ptr<Notification> notification) { |
+ // Nothing to do here since there is no state kept. |
+} |
+ |
+notification_operation_common::NotificationHandlerType |
+PersistentNotificationHandler::NotificationType() { |
+ return notification_operation_common::PERSISTENT_NOTIFICATION; |
+} |