| 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 const Notification* NotificationUIManagerImpl::FindById( |
| 78 for (NotificationDeque::iterator iter = show_queue_.begin(); | 78 const std::string& id) const { |
| 79 for (NotificationDeque::const_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) { |
| 81 return true; | 82 return &((*iter)->notification()); |
| 83 } |
| 82 } | 84 } |
| 83 return false; | 85 return NULL; |
| 84 } | 86 } |
| 85 | 87 |
| 86 bool NotificationUIManagerImpl::CancelById(const std::string& id) { | 88 bool NotificationUIManagerImpl::CancelById(const std::string& id) { |
| 87 // See if this ID hasn't been shown yet. | 89 // See if this ID hasn't been shown yet. |
| 88 for (NotificationDeque::iterator iter = show_queue_.begin(); | 90 for (NotificationDeque::iterator iter = show_queue_.begin(); |
| 89 iter != show_queue_.end(); ++iter) { | 91 iter != show_queue_.end(); ++iter) { |
| 90 if ((*iter)->notification().notification_id() == id) { | 92 if ((*iter)->notification().notification_id() == id) { |
| 91 show_queue_.erase(iter); | 93 show_queue_.erase(iter); |
| 92 return true; | 94 return true; |
| 93 } | 95 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 CancelAllBySourceOrigin(extension->url()); | 235 CancelAllBySourceOrigin(extension->url()); |
| 234 } | 236 } |
| 235 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { | 237 } else if (type == chrome::NOTIFICATION_PROFILE_DESTROYED) { |
| 236 // We only want to remove the incognito notifications. | 238 // We only want to remove the incognito notifications. |
| 237 if (content::Source<Profile>(source)->IsOffTheRecord()) | 239 if (content::Source<Profile>(source)->IsOffTheRecord()) |
| 238 CancelAllByProfile(content::Source<Profile>(source).ptr()); | 240 CancelAllByProfile(content::Source<Profile>(source).ptr()); |
| 239 } else { | 241 } else { |
| 240 NOTREACHED(); | 242 NOTREACHED(); |
| 241 } | 243 } |
| 242 } | 244 } |
| OLD | NEW |