Chromium Code Reviews| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/browser_process.h" | |
| 13 #include "chrome/browser/notifications/extension_welcome_notification.h" | 14 #include "chrome/browser/notifications/extension_welcome_notification.h" |
| 14 #include "chrome/browser/notifications/extension_welcome_notification_factory.h" | 15 #include "chrome/browser/notifications/extension_welcome_notification_factory.h" |
| 15 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" | 16 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" |
| 16 #include "chrome/browser/notifications/message_center_settings_controller.h" | 17 #include "chrome/browser/notifications/message_center_settings_controller.h" |
| 17 #include "chrome/browser/notifications/notification.h" | 18 #include "chrome/browser/notifications/notification.h" |
| 18 #include "chrome/browser/notifications/profile_notification.h" | 19 #include "chrome/browser/notifications/profile_notification.h" |
| 19 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" | 20 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 MessageCenterNotificationManager::~MessageCenterNotificationManager() { | 72 MessageCenterNotificationManager::~MessageCenterNotificationManager() { |
| 72 message_center_->SetNotifierSettingsProvider(nullptr); | 73 message_center_->SetNotifierSettingsProvider(nullptr); |
| 73 message_center_->RemoveObserver(this); | 74 message_center_->RemoveObserver(this); |
| 74 | 75 |
| 75 profile_notifications_.clear(); | 76 profile_notifications_.clear(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 //////////////////////////////////////////////////////////////////////////////// | 79 //////////////////////////////////////////////////////////////////////////////// |
| 79 // NotificationUIManager | 80 // NotificationUIManager |
| 80 | 81 |
| 81 void MessageCenterNotificationManager::Add(const Notification& notification, | 82 void MessageCenterNotificationManager::Add(const Notification& notification, |
|
sky
2017/03/28 22:00:34
Would it make more sense for this class to be dest
sammiequon
2017/03/28 23:12:08
It would, but would this cause a bunch of other bu
stevenjb
2017/03/29 00:21:33
I would also be worried about dereferencing errors
| |
| 82 Profile* profile) { | 83 Profile* profile) { |
| 84 // We won't have time to process and act on this notification. | |
| 85 if (g_browser_process->IsShuttingDown()) | |
| 86 return; | |
| 87 | |
| 83 if (Update(notification, profile)) | 88 if (Update(notification, profile)) |
| 84 return; | 89 return; |
| 85 | 90 |
| 86 std::unique_ptr<ProfileNotification> profile_notification_ptr = | 91 std::unique_ptr<ProfileNotification> profile_notification_ptr = |
| 87 base::MakeUnique<ProfileNotification>(profile, notification); | 92 base::MakeUnique<ProfileNotification>(profile, notification); |
| 88 ProfileNotification* profile_notification = profile_notification_ptr.get(); | 93 ProfileNotification* profile_notification = profile_notification_ptr.get(); |
| 89 | 94 |
| 90 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> | 95 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> |
| 91 ShowWelcomeNotificationIfNecessary(profile_notification->notification()); | 96 ShowWelcomeNotificationIfNecessary(profile_notification->notification()); |
| 92 | 97 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 } | 340 } |
| 336 | 341 |
| 337 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification( | 342 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification( |
| 338 const std::string& id) const { | 343 const std::string& id) const { |
| 339 auto iter = profile_notifications_.find(id); | 344 auto iter = profile_notifications_.find(id); |
| 340 if (iter == profile_notifications_.end()) | 345 if (iter == profile_notifications_.end()) |
| 341 return nullptr; | 346 return nullptr; |
| 342 | 347 |
| 343 return (*iter).second.get(); | 348 return (*iter).second.get(); |
| 344 } | 349 } |
| OLD | NEW |