| 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/notification_ui_manager_impl.h" | 5 #include "chrome/browser/notifications/notification_ui_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 | 69 |
| 70 VLOG(1) << "Added notification. URL: " | 70 VLOG(1) << "Added notification. URL: " |
| 71 << notification.content_url().spec(); | 71 << notification.content_url().spec(); |
| 72 show_queue_.push_back(linked_ptr<QueuedNotification>( | 72 show_queue_.push_back(linked_ptr<QueuedNotification>( |
| 73 new QueuedNotification(notification, profile))); | 73 new QueuedNotification(notification, profile))); |
| 74 CheckAndShowNotifications(); | 74 CheckAndShowNotifications(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool NotificationUIManagerImpl::DoesIdExist(const std::string& id) { | 77 bool NotificationUIManagerImpl::DoesIdExist( |
| 78 const std::string& id, Notification* matched_notification) { |
| 78 for (NotificationDeque::iterator iter = show_queue_.begin(); | 79 for (NotificationDeque::iterator iter = show_queue_.begin(); |
| 79 iter != show_queue_.end(); ++iter) { | 80 iter != show_queue_.end(); ++iter) { |
| 80 if ((*iter)->notification().notification_id() == id) | 81 if ((*iter)->notification().notification_id() == id) { |
| 82 if (matched_notification) |
| 83 *matched_notification = (*iter)->notification(); |
| 81 return true; | 84 return true; |
| 85 } |
| 82 } | 86 } |
| 83 return false; | 87 return false; |
| 84 } | 88 } |
| 85 | 89 |
| 86 bool NotificationUIManagerImpl::CancelById(const std::string& id) { | 90 bool NotificationUIManagerImpl::CancelById(const std::string& id) { |
| 87 // See if this ID hasn't been shown yet. | 91 // See if this ID hasn't been shown yet. |
| 88 for (NotificationDeque::iterator iter = show_queue_.begin(); | 92 for (NotificationDeque::iterator iter = show_queue_.begin(); |
| 89 iter != show_queue_.end(); ++iter) { | 93 iter != show_queue_.end(); ++iter) { |
| 90 if ((*iter)->notification().notification_id() == id) { | 94 if ((*iter)->notification().notification_id() == id) { |
| 91 show_queue_.erase(iter); | 95 show_queue_.erase(iter); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 CancelAllBySourceOrigin(extension->url()); | 237 CancelAllBySourceOrigin(extension->url()); |
| 234 } | 238 } |
| 235 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { | 239 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { |
| 236 // We only want to remove the incognito notifications. | 240 // We only want to remove the incognito notifications. |
| 237 if (content::Source<Profile>(source)->IsOffTheRecord()) | 241 if (content::Source<Profile>(source)->IsOffTheRecord()) |
| 238 CancelAllByProfile(content::Source<Profile>(source).ptr()); | 242 CancelAllByProfile(content::Source<Profile>(source).ptr()); |
| 239 } else { | 243 } else { |
| 240 NOTREACHED(); | 244 NOTREACHED(); |
| 241 } | 245 } |
| 242 } | 246 } |
| OLD | NEW |