| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/notifications/message_center_display_service.h" | 5 #include "chrome/browser/notifications/message_center_display_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/notifications/notification.h" | 7 #include "chrome/browser/notifications/notification.h" |
| 8 #include "chrome/browser/notifications/notification_ui_manager.h" | 8 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 | 10 |
| 11 MessageCenterDisplayService::MessageCenterDisplayService( | 11 MessageCenterDisplayService::MessageCenterDisplayService( |
| 12 Profile* profile, | 12 Profile* profile, |
| 13 NotificationUIManager* ui_manager) | 13 NotificationUIManager* ui_manager) |
| 14 : profile_(profile), ui_manager_(ui_manager) {} | 14 : profile_(profile), ui_manager_(ui_manager) {} |
| 15 | 15 |
| 16 MessageCenterDisplayService::~MessageCenterDisplayService() {} | 16 MessageCenterDisplayService::~MessageCenterDisplayService() {} |
| 17 | 17 |
| 18 void MessageCenterDisplayService::Display(const std::string& notification_id, | 18 void MessageCenterDisplayService::Display( |
| 19 const Notification& notification) { | 19 notification_operation_common::NotificationHandlerType notification_type, |
| 20 const std::string& notification_id, |
| 21 const Notification& notification) { |
| 20 ui_manager_->Add(notification, profile_); | 22 ui_manager_->Add(notification, profile_); |
| 21 } | 23 } |
| 22 | 24 |
| 23 void MessageCenterDisplayService::Close(const std::string& notification_id) { | 25 void MessageCenterDisplayService::Close( |
| 26 notification_operation_common::NotificationHandlerType notification_type, |
| 27 const std::string& notification_id) { |
| 24 ui_manager_->CancelById(notification_id, | 28 ui_manager_->CancelById(notification_id, |
| 25 NotificationUIManager::GetProfileID(profile_)); | 29 NotificationUIManager::GetProfileID(profile_)); |
| 26 } | 30 } |
| 27 | 31 |
| 28 bool MessageCenterDisplayService::GetDisplayed( | 32 bool MessageCenterDisplayService::GetDisplayed( |
| 29 std::set<std::string>* notifications) const { | 33 std::set<std::string>* notifications) const { |
| 30 DCHECK(notifications); | 34 DCHECK(notifications); |
| 31 for (auto notification_id : ui_manager_->GetAllIdsByProfile( | 35 for (auto notification_id : ui_manager_->GetAllIdsByProfile( |
| 32 NotificationUIManager::GetProfileID(profile_))) { | 36 NotificationUIManager::GetProfileID(profile_))) { |
| 33 notifications->insert(notification_id); | 37 notifications->insert(notification_id); |
| 34 } | 38 } |
| 35 return true; | 39 return true; |
| 36 } | 40 } |
| 37 | 41 |
| 42 void MessageCenterDisplayService::ProcessNotificationOperation( |
| 43 notification_operation_common::NotificationOperation operation, |
| 44 notification_operation_common::NotificationHandlerType notification_type, |
| 45 const std::string& origin, |
| 46 const std::string& notification_id, |
| 47 int action_index) { |
| 48 // Message center based notifications don't receive operations from the |
| 49 // outside world, everything is managed within chrome's notification center. |
| 50 } |
| 51 |
| 38 bool MessageCenterDisplayService::SupportsNotificationCenter() const { | 52 bool MessageCenterDisplayService::SupportsNotificationCenter() const { |
| 39 return false; | 53 return false; |
| 40 } | 54 } |
| OLD | NEW |