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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (old_notification->notification().tag() == tag && | 138 if (old_notification->notification().tag() == tag && |
139 old_notification->notification().origin_url() == origin_url && | 139 old_notification->notification().origin_url() == origin_url && |
140 old_notification->profile_id() == | 140 old_notification->profile_id() == |
141 NotificationUIManager::GetProfileID(profile)) { | 141 NotificationUIManager::GetProfileID(profile)) { |
142 // Changing the type from non-progress to progress does not count towards | 142 // Changing the type from non-progress to progress does not count towards |
143 // the immediate update allowed in the message center. | 143 // the immediate update allowed in the message center. |
144 std::string old_id = old_notification->notification().id(); | 144 std::string old_id = old_notification->notification().id(); |
145 | 145 |
146 // Add/remove notification in the local list but just update the same | 146 // Add/remove notification in the local list but just update the same |
147 // one in MessageCenter. | 147 // one in MessageCenter. |
| 148 ProfileNotification* new_notification = |
| 149 new ProfileNotification(profile, notification); |
| 150 // Delete the old one after the new one is created to ensure we don't run |
| 151 // out of KeepAlives. |
148 delete old_notification; | 152 delete old_notification; |
149 profile_notifications_.erase(old_id); | 153 profile_notifications_.erase(old_id); |
150 ProfileNotification* new_notification = | |
151 new ProfileNotification(profile, notification); | |
152 profile_notifications_[new_notification->notification().id()] = | 154 profile_notifications_[new_notification->notification().id()] = |
153 new_notification; | 155 new_notification; |
154 | 156 |
155 // TODO(liyanhou): Add routing updated notifications to alternative | 157 // TODO(liyanhou): Add routing updated notifications to alternative |
156 // providers. | 158 // providers. |
157 | 159 |
158 // WARNING: You MUST use AddProfileNotification or update the message | 160 // WARNING: You MUST use AddProfileNotification or update the message |
159 // center via the notification within a ProfileNotification object or the | 161 // center via the notification within a ProfileNotification object or the |
160 // profile ID will not be correctly set for ChromeOS. | 162 // profile ID will not be correctly set for ChromeOS. |
161 message_center_->UpdateNotification( | 163 message_center_->UpdateNotification( |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 it != registry->enabled_extensions().end(); | 379 it != registry->enabled_extensions().end(); |
378 ++it) { | 380 ++it) { |
379 if ((*it->get()).permissions_data()->HasAPIPermission( | 381 if ((*it->get()).permissions_data()->HasAPIPermission( |
380 extensions::APIPermission::ID::kNotificationProvider)) { | 382 extensions::APIPermission::ID::kNotificationProvider)) { |
381 extension_id = (*it->get()).id(); | 383 extension_id = (*it->get()).id(); |
382 return extension_id; | 384 return extension_id; |
383 } | 385 } |
384 } | 386 } |
385 return extension_id; | 387 return extension_id; |
386 } | 388 } |
OLD | NEW |