| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 message_center_->RemoveObserver(this); | 73 message_center_->RemoveObserver(this); |
| 74 | 74 |
| 75 profile_notifications_.clear(); | 75 profile_notifications_.clear(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
| 79 // NotificationUIManager | 79 // NotificationUIManager |
| 80 | 80 |
| 81 void MessageCenterNotificationManager::Add(const Notification& notification, | 81 void MessageCenterNotificationManager::Add(const Notification& notification, |
| 82 Profile* profile) { | 82 Profile* profile) { |
| 83 // We won't have time to process and act on this notification. |
| 84 if (is_shutdown_started_) |
| 85 return; |
| 86 |
| 83 if (Update(notification, profile)) | 87 if (Update(notification, profile)) |
| 84 return; | 88 return; |
| 85 | 89 |
| 86 std::unique_ptr<ProfileNotification> profile_notification_ptr = | 90 std::unique_ptr<ProfileNotification> profile_notification_ptr = |
| 87 base::MakeUnique<ProfileNotification>(profile, notification); | 91 base::MakeUnique<ProfileNotification>(profile, notification); |
| 88 ProfileNotification* profile_notification = profile_notification_ptr.get(); | 92 ProfileNotification* profile_notification = profile_notification_ptr.get(); |
| 89 | 93 |
| 90 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> | 94 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> |
| 91 ShowWelcomeNotificationIfNecessary(profile_notification->notification()); | 95 ShowWelcomeNotificationIfNecessary(profile_notification->notification()); |
| 92 | 96 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 254 } |
| 251 } | 255 } |
| 252 return removed; | 256 return removed; |
| 253 } | 257 } |
| 254 | 258 |
| 255 void MessageCenterNotificationManager::CancelAll() { | 259 void MessageCenterNotificationManager::CancelAll() { |
| 256 message_center_->RemoveAllNotifications( | 260 message_center_->RemoveAllNotifications( |
| 257 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); | 261 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); |
| 258 } | 262 } |
| 259 | 263 |
| 264 void MessageCenterNotificationManager::StartShutdown() { |
| 265 is_shutdown_started_ = true; |
| 266 CancelAll(); |
| 267 } |
| 268 |
| 260 //////////////////////////////////////////////////////////////////////////////// | 269 //////////////////////////////////////////////////////////////////////////////// |
| 261 // MessageCenter::Observer | 270 // MessageCenter::Observer |
| 262 void MessageCenterNotificationManager::OnNotificationRemoved( | 271 void MessageCenterNotificationManager::OnNotificationRemoved( |
| 263 const std::string& id, | 272 const std::string& id, |
| 264 bool by_user) { | 273 bool by_user) { |
| 265 auto iter = profile_notifications_.find(id); | 274 auto iter = profile_notifications_.find(id); |
| 266 if (iter != profile_notifications_.end()) | 275 if (iter != profile_notifications_.end()) |
| 267 RemoveProfileNotification(iter->first); | 276 RemoveProfileNotification(iter->first); |
| 268 } | 277 } |
| 269 | 278 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 344 } |
| 336 | 345 |
| 337 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification( | 346 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification( |
| 338 const std::string& id) const { | 347 const std::string& id) const { |
| 339 auto iter = profile_notifications_.find(id); | 348 auto iter = profile_notifications_.find(id); |
| 340 if (iter == profile_notifications_.end()) | 349 if (iter == profile_notifications_.end()) |
| 341 return nullptr; | 350 return nullptr; |
| 342 | 351 |
| 343 return (*iter).second.get(); | 352 return (*iter).second.get(); |
| 344 } | 353 } |
| OLD | NEW |