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/message_center_notification_display_servi
ce.h" |
| 6 |
| 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/notifications/notification.h" |
| 9 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
| 11 |
| 12 #if !defined(OS_MACOSX) |
| 13 // static |
| 14 NotificationDisplayService* NotificationDisplayService::Create( |
| 15 Profile* profile) { |
| 16 return new MessageCenterNotificationDisplayService(profile); |
| 17 } |
| 18 #endif |
| 19 |
| 20 MessageCenterNotificationDisplayService:: |
| 21 MessageCenterNotificationDisplayService(Profile* profile) |
| 22 : NotificationDisplayService(profile) {} |
| 23 |
| 24 void MessageCenterNotificationDisplayService::Display( |
| 25 const Notification& notification) { |
| 26 g_browser_process->notification_ui_manager()->Add(notification, profile_); |
| 27 } |
| 28 |
| 29 bool MessageCenterNotificationDisplayService::Close( |
| 30 const std::string& notification_id) { |
| 31 return g_browser_process->notification_ui_manager()->CancelById( |
| 32 notification_id, NotificationUIManager::GetProfileID(profile_)); |
| 33 } |
| 34 |
| 35 std::set<std::string> MessageCenterNotificationDisplayService::GetDisplayed() |
| 36 const { |
| 37 // There may not be a notification ui manager when another feature erroneously |
| 38 // instantiates a storage partition when the browser process is shutting down. |
| 39 // TODO(peter): Remove in favor of a DCHECK when crbug.com/546745 is fixed. |
| 40 NotificationUIManager* ui_manager = |
| 41 g_browser_process->notification_ui_manager(); |
| 42 if (!ui_manager) |
| 43 return std::set<std::string>(); |
| 44 |
| 45 return ui_manager->GetAllIdsByProfile( |
| 46 NotificationUIManager::GetProfileID(profile_)); |
| 47 } |
| 48 |
| 49 bool MessageCenterNotificationDisplayService::SupportsNotificationCenter() |
| 50 const { |
| 51 return false; |
| 52 } |
OLD | NEW |