| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/extensions/extension_info_map.h" | 10 #include "chrome/browser/extensions/extension_info_map.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #endif | 57 #endif |
| 58 } | 58 } |
| 59 | 59 |
| 60 MessageCenterNotificationManager::~MessageCenterNotificationManager() { | 60 MessageCenterNotificationManager::~MessageCenterNotificationManager() { |
| 61 message_center_->RemoveObserver(this); | 61 message_center_->RemoveObserver(this); |
| 62 } | 62 } |
| 63 | 63 |
| 64 //////////////////////////////////////////////////////////////////////////////// | 64 //////////////////////////////////////////////////////////////////////////////// |
| 65 // NotificationUIManager | 65 // NotificationUIManager |
| 66 | 66 |
| 67 bool MessageCenterNotificationManager::DoesIdExist(const std::string& id) { | 67 const Notification* MessageCenterNotificationManager::FindById( |
| 68 if (NotificationUIManagerImpl::DoesIdExist(id)) | 68 const std::string& id) const { |
| 69 return true; | 69 const Notification* notification = NotificationUIManagerImpl::FindById(id); |
| 70 NotificationMap::iterator iter = profile_notifications_.find(id); | 70 if (notification) |
| 71 return notification; |
| 72 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
| 71 if (iter == profile_notifications_.end()) | 73 if (iter == profile_notifications_.end()) |
| 72 return false; | 74 return NULL; |
| 73 return true; | 75 return &(iter->second->notification()); |
| 74 } | 76 } |
| 75 | 77 |
| 76 bool MessageCenterNotificationManager::CancelById(const std::string& id) { | 78 bool MessageCenterNotificationManager::CancelById(const std::string& id) { |
| 77 // See if this ID hasn't been shown yet. | 79 // See if this ID hasn't been shown yet. |
| 78 if (NotificationUIManagerImpl::CancelById(id)) | 80 if (NotificationUIManagerImpl::CancelById(id)) |
| 79 return true; | 81 return true; |
| 80 | 82 |
| 81 // If it has been shown, remove it. | 83 // If it has been shown, remove it. |
| 82 NotificationMap::iterator iter = profile_notifications_.find(id); | 84 NotificationMap::iterator iter = profile_notifications_.find(id); |
| 83 if (iter == profile_notifications_.end()) | 85 if (iter == profile_notifications_.end()) |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 526 |
| 525 MessageCenterNotificationManager::ProfileNotification* | 527 MessageCenterNotificationManager::ProfileNotification* |
| 526 MessageCenterNotificationManager::FindProfileNotification( | 528 MessageCenterNotificationManager::FindProfileNotification( |
| 527 const std::string& id) const { | 529 const std::string& id) const { |
| 528 NotificationMap::const_iterator iter = profile_notifications_.find(id); | 530 NotificationMap::const_iterator iter = profile_notifications_.find(id); |
| 529 if (iter == profile_notifications_.end()) | 531 if (iter == profile_notifications_.end()) |
| 530 return NULL; | 532 return NULL; |
| 531 | 533 |
| 532 return (*iter).second; | 534 return (*iter).second; |
| 533 } | 535 } |
| OLD | NEW |