summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications/message_center_notification_manager.cc
diff options
context:
space:
mode:
authordewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-25 20:26:49 +0000
committerdewittj@chromium.org <dewittj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-25 20:26:49 +0000
commit749e8d645403bdef7846318d60cb713baf76a369 (patch)
treee4d2e009cc629715bdd8e048c4036c269f46dc58 /chrome/browser/notifications/message_center_notification_manager.cc
parent6c253ae8d7a55829e600ee968a1ee4bffe950a51 (diff)
downloadchromium_src-749e8d645403bdef7846318d60cb713baf76a369.zip
chromium_src-749e8d645403bdef7846318d60cb713baf76a369.tar.gz
chromium_src-749e8d645403bdef7846318d60cb713baf76a369.tar.bz2
Reland r279550 "Allow notification updates on ChromeOS."
This fixes a regression with multi-profile mode where updated notifications don't properly have the profile_id set. Original patch was reverted due to a memory leak in the tests. BUG=386814 Review URL: https://codereview.chromium.org/356783002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279797 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications/message_center_notification_manager.cc')
-rw-r--r--chrome/browser/notifications/message_center_notification_manager.cc21
1 files changed, 15 insertions, 6 deletions
diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
index f400bfd..a0ae9d19 100644
--- a/chrome/browser/notifications/message_center_notification_manager.cc
+++ b/chrome/browser/notifications/message_center_notification_manager.cc
@@ -8,6 +8,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
+#include "base/stl_util.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
@@ -91,6 +92,10 @@ MessageCenterNotificationManager::MessageCenterNotificationManager(
MessageCenterNotificationManager::~MessageCenterNotificationManager() {
message_center_->SetNotifierSettingsProvider(NULL);
message_center_->RemoveObserver(this);
+
+ STLDeleteContainerPairSecondPointers(profile_notifications_.begin(),
+ profile_notifications_.end());
+ profile_notifications_.clear();
}
void MessageCenterNotificationManager::RegisterPrefs(
@@ -112,6 +117,9 @@ void MessageCenterNotificationManager::Add(const Notification& notification,
DesktopNotificationServiceFactory::GetForProfile(profile)->
ShowWelcomeNotificationIfNecessary(notification);
+ // WARNING: You MUST use AddProfileNotification or update the message center
+ // via the notification within a ProfileNotification object or the profile ID
+ // will not be correctly set for ChromeOS.
AddProfileNotification(
new ProfileNotification(profile, notification, message_center_));
}
@@ -138,7 +146,6 @@ bool MessageCenterNotificationManager::Update(const Notification& notification,
// the immediate update allowed in the message center.
std::string old_id =
old_notification->notification().delegate_id();
- DCHECK(message_center_->FindVisibleNotificationById(old_id));
// Add/remove notification in the local list but just update the same
// one in MessageCenter.
@@ -148,11 +155,13 @@ bool MessageCenterNotificationManager::Update(const Notification& notification,
new ProfileNotification(profile, notification, message_center_);
profile_notifications_[notification.delegate_id()] = new_notification;
- // Now pass a copy to message center.
- scoped_ptr<message_center::Notification> message_center_notification(
- make_scoped_ptr(new message_center::Notification(notification)));
- message_center_->UpdateNotification(old_id,
- message_center_notification.Pass());
+ // WARNING: You MUST use AddProfileNotification or update the message
+ // center via the notification within a ProfileNotification object or the
+ // profile ID will not be correctly set for ChromeOS.
+ message_center_->UpdateNotification(
+ old_id,
+ make_scoped_ptr(new message_center::Notification(
+ new_notification->notification())));
new_notification->StartDownloads();
return true;