Index: chrome/browser/notifications/message_center_notification_display_service.cc |
diff --git a/chrome/browser/notifications/message_center_notification_display_service.cc b/chrome/browser/notifications/message_center_notification_display_service.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..eddfa420e0d9965c2173d485771f40d61bba5217 |
--- /dev/null |
+++ b/chrome/browser/notifications/message_center_notification_display_service.cc |
@@ -0,0 +1,52 @@ |
+// 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/message_center_notification_display_service.h" |
+ |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/notifications/notification.h" |
+#include "chrome/browser/notifications/notification_ui_manager.h" |
+#include "chrome/browser/profiles/profile.h" |
+ |
+#if !defined(OS_MACOSX) |
+// static |
+NotificationDisplayService* NotificationDisplayService::Create( |
+ Profile* profile) { |
+ return new MessageCenterNotificationDisplayService(profile); |
+} |
+#endif |
+ |
+MessageCenterNotificationDisplayService:: |
+ MessageCenterNotificationDisplayService(Profile* profile) |
+ : NotificationDisplayService(profile) {} |
+ |
+void MessageCenterNotificationDisplayService::Display( |
+ const Notification& notification) { |
+ g_browser_process->notification_ui_manager()->Add(notification, profile_); |
+} |
+ |
+bool MessageCenterNotificationDisplayService::Close( |
+ const std::string& notification_id) { |
+ return g_browser_process->notification_ui_manager()->CancelById( |
+ notification_id, NotificationUIManager::GetProfileID(profile_)); |
+} |
+ |
+std::set<std::string> MessageCenterNotificationDisplayService::GetDisplayed() |
+ const { |
+ // There may not be a notification ui manager when another feature erroneously |
+ // instantiates a storage partition when the browser process is shutting down. |
+ // TODO(peter): Remove in favor of a DCHECK when crbug.com/546745 is fixed. |
+ NotificationUIManager* ui_manager = |
+ g_browser_process->notification_ui_manager(); |
+ if (!ui_manager) |
+ return std::set<std::string>(); |
+ |
+ return ui_manager->GetAllIdsByProfile( |
+ NotificationUIManager::GetProfileID(profile_)); |
+} |
+ |
+bool MessageCenterNotificationDisplayService::SupportsNotificationCenter() |
+ const { |
+ return false; |
+} |