| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 message_center_->RemoveObserver(this); | 75 message_center_->RemoveObserver(this); |
| 76 | 76 |
| 77 profile_notifications_.clear(); | 77 profile_notifications_.clear(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 //////////////////////////////////////////////////////////////////////////////// | 80 //////////////////////////////////////////////////////////////////////////////// |
| 81 // NotificationUIManager | 81 // NotificationUIManager |
| 82 | 82 |
| 83 void MessageCenterNotificationManager::Add(const Notification& notification, | 83 void MessageCenterNotificationManager::Add(const Notification& notification, |
| 84 Profile* profile) { | 84 Profile* profile) { |
| 85 // We won't have time to process and act on this notification. |
| 86 if (is_shutdown_started_) |
| 87 return; |
| 88 |
| 85 if (Update(notification, profile)) | 89 if (Update(notification, profile)) |
| 86 return; | 90 return; |
| 87 | 91 |
| 88 std::unique_ptr<ProfileNotification> profile_notification_ptr = | 92 std::unique_ptr<ProfileNotification> profile_notification_ptr = |
| 89 base::MakeUnique<ProfileNotification>(profile, notification); | 93 base::MakeUnique<ProfileNotification>(profile, notification); |
| 90 ProfileNotification* profile_notification = profile_notification_ptr.get(); | 94 ProfileNotification* profile_notification = profile_notification_ptr.get(); |
| 91 | 95 |
| 92 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> | 96 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> |
| 93 ShowWelcomeNotificationIfNecessary(profile_notification->notification()); | 97 ShowWelcomeNotificationIfNecessary(profile_notification->notification()); |
| 94 | 98 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 } | 256 } |
| 253 } | 257 } |
| 254 return removed; | 258 return removed; |
| 255 } | 259 } |
| 256 | 260 |
| 257 void MessageCenterNotificationManager::CancelAll() { | 261 void MessageCenterNotificationManager::CancelAll() { |
| 258 message_center_->RemoveAllNotifications( | 262 message_center_->RemoveAllNotifications( |
| 259 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); | 263 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); |
| 260 } | 264 } |
| 261 | 265 |
| 266 void MessageCenterNotificationManager::StartShutdown() { |
| 267 is_shutdown_started_ = true; |
| 268 CancelAll(); |
| 269 } |
| 270 |
| 262 //////////////////////////////////////////////////////////////////////////////// | 271 //////////////////////////////////////////////////////////////////////////////// |
| 263 // MessageCenter::Observer | 272 // MessageCenter::Observer |
| 264 void MessageCenterNotificationManager::OnNotificationRemoved( | 273 void MessageCenterNotificationManager::OnNotificationRemoved( |
| 265 const std::string& id, | 274 const std::string& id, |
| 266 bool by_user) { | 275 bool by_user) { |
| 267 auto iter = profile_notifications_.find(id); | 276 auto iter = profile_notifications_.find(id); |
| 268 if (iter != profile_notifications_.end()) | 277 if (iter != profile_notifications_.end()) |
| 269 RemoveProfileNotification(iter->first); | 278 RemoveProfileNotification(iter->first); |
| 270 } | 279 } |
| 271 | 280 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 } | 347 } |
| 339 | 348 |
| 340 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification( | 349 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification( |
| 341 const std::string& id) const { | 350 const std::string& id) const { |
| 342 auto iter = profile_notifications_.find(id); | 351 auto iter = profile_notifications_.find(id); |
| 343 if (iter == profile_notifications_.end()) | 352 if (iter == profile_notifications_.end()) |
| 344 return nullptr; | 353 return nullptr; |
| 345 | 354 |
| 346 return (*iter).second.get(); | 355 return (*iter).second.get(); |
| 347 } | 356 } |
| OLD | NEW |