Index: chrome/browser/notifications/message_center_notification_manager.cc |
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc |
index e4c54e7430d9f8d01001fee859ab5e2d69c42799..3d6f5abf226940a28184aed3109244f1bf1bcd7c 100644 |
--- a/chrome/browser/notifications/message_center_notification_manager.cc |
+++ b/chrome/browser/notifications/message_center_notification_manager.cc |
@@ -117,8 +117,8 @@ void MessageCenterNotificationManager::Add(const Notification& notification, |
if (Update(notification, profile)) |
return; |
- ProfileNotification* profile_notification = |
- new ProfileNotification(profile, notification); |
+ ProfileNotification* profile_notification = new ProfileNotification( |
+ NotificationUIManager::GetProfileID(profile), notification); |
ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> |
ShowWelcomeNotificationIfNecessary(profile_notification->notification()); |
@@ -162,7 +162,8 @@ bool MessageCenterNotificationManager::Update(const Notification& notification, |
ProfileNotification* old_notification = (*iter).second; |
if (old_notification->notification().tag() == tag && |
old_notification->notification().origin_url() == origin_url && |
- old_notification->profile() == profile) { |
+ old_notification->profile() == |
+ NotificationUIManager::GetProfileID(profile)) { |
// Changing the type from non-progress to progress does not count towards |
// the immediate update allowed in the message center. |
std::string old_id = old_notification->notification().id(); |
@@ -171,8 +172,8 @@ bool MessageCenterNotificationManager::Update(const Notification& notification, |
// one in MessageCenter. |
delete old_notification; |
profile_notifications_.erase(old_id); |
- ProfileNotification* new_notification = |
- new ProfileNotification(profile, notification); |
+ ProfileNotification* new_notification = new ProfileNotification( |
+ NotificationUIManager::GetProfileID(profile), notification); |
profile_notifications_[new_notification->notification().id()] = |
new_notification; |
@@ -231,15 +232,12 @@ bool MessageCenterNotificationManager::CancelById( |
std::set<std::string> |
MessageCenterNotificationManager::GetAllIdsByProfileAndSourceOrigin( |
- Profile* profile, |
+ ProfileID profile_id, |
const GURL& source) { |
- // The profile pointer can be weak, the instance may have been destroyed, so |
- // no profile method should be called inside this function. |
- |
std::set<std::string> delegate_ids; |
for (const auto& pair : profile_notifications_) { |
const Notification& notification = pair.second->notification(); |
- if (pair.second->profile() == profile && |
+ if (pair.second->profile() == profile_id && |
notification.origin_url() == source) { |
delegate_ids.insert(notification.delegate_id()); |
} |
@@ -249,13 +247,10 @@ MessageCenterNotificationManager::GetAllIdsByProfileAndSourceOrigin( |
} |
std::set<std::string> MessageCenterNotificationManager::GetAllIdsByProfile( |
- Profile* profile) { |
- // The profile pointer can be weak, the instance may have been destroyed, so |
- // no profile method should be called inside this function. |
- |
+ ProfileID profile_id) { |
std::set<std::string> delegate_ids; |
for (const auto& pair : profile_notifications_) { |
- if (pair.second->profile() == profile) |
+ if (pair.second->profile() == profile_id) |
delegate_ids.insert(pair.second->notification().delegate_id()); |
} |
@@ -289,8 +284,7 @@ bool MessageCenterNotificationManager::CancelAllByProfile( |
for (NotificationMap::iterator loopiter = profile_notifications_.begin(); |
loopiter != profile_notifications_.end(); ) { |
NotificationMap::iterator curiter = loopiter++; |
- if (profile_id == NotificationUIManager::GetProfileID( |
- (*curiter).second->profile())) { |
+ if (profile_id == (*curiter).second->profile()) { |
const std::string id = curiter->first; |
RemoveProfileNotification(curiter->second); |
message_center_->RemoveNotification(id, /* by_user */ false); |
@@ -375,7 +369,7 @@ void MessageCenterNotificationManager::AddNotificationToAlternateProvider( |
// Send the notification to the alternate provider extension/app. |
extensions::NotificationProviderEventRouter event_router( |
- profile_notification->profile()); |
+ static_cast<Profile*>(profile_notification->profile())); |
dewittj
2015/05/22 16:54:37
We shouldn't cast ProfileId to Profile. Instead,
Deepak
2015/05/23 06:19:11
Done.
|
event_router.CreateNotification(extension_id, |
notification.notifier_id().id, |
notification.delegate_id(), |