| 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/balloon_notification_ui_manager.h" | 5 #include "chrome/browser/notifications/balloon_notification_ui_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 "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 DCHECK(!balloon_collection_.get() || | 37 DCHECK(!balloon_collection_.get() || |
| 38 balloon_collection_->GetActiveBalloons().size() == 0); | 38 balloon_collection_->GetActiveBalloons().size() == 0); |
| 39 DCHECK(balloon_collection); | 39 DCHECK(balloon_collection); |
| 40 balloon_collection_.reset(balloon_collection); | 40 balloon_collection_.reset(balloon_collection); |
| 41 balloon_collection_->SetPositionPreference( | 41 balloon_collection_->SetPositionPreference( |
| 42 static_cast<BalloonCollection::PositionPreference>( | 42 static_cast<BalloonCollection::PositionPreference>( |
| 43 position_pref_.GetValue())); | 43 position_pref_.GetValue())); |
| 44 balloon_collection_->set_space_change_listener(this); | 44 balloon_collection_->set_space_change_listener(this); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool BalloonNotificationUIManager::DoesIdExist(const std::string& id) { | 47 const Notification* BalloonNotificationUIManager::FindById( |
| 48 if (NotificationUIManagerImpl::DoesIdExist(id)) | 48 const std::string& id) const { |
| 49 return true; | 49 const Notification* notification = NotificationUIManagerImpl::FindById(id); |
| 50 return balloon_collection_->DoesIdExist(id); | 50 if (notification) |
| 51 return notification; |
| 52 return balloon_collection_->FindById(id); |
| 51 } | 53 } |
| 52 | 54 |
| 53 bool BalloonNotificationUIManager::CancelById(const std::string& id) { | 55 bool BalloonNotificationUIManager::CancelById(const std::string& id) { |
| 54 // See if this ID hasn't been shown yet. | 56 // See if this ID hasn't been shown yet. |
| 55 if (NotificationUIManagerImpl::CancelById(id)) | 57 if (NotificationUIManagerImpl::CancelById(id)) |
| 56 return true; | 58 return true; |
| 57 // If it has been shown, remove it from the balloon collections. | 59 // If it has been shown, remove it from the balloon collections. |
| 58 return balloon_collection_->RemoveById(id); | 60 return balloon_collection_->RemoveById(id); |
| 59 } | 61 } |
| 60 | 62 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 BalloonNotificationUIManager::GetInstanceForTesting() { | 168 BalloonNotificationUIManager::GetInstanceForTesting() { |
| 167 if (NotificationUIManager::DelegatesToMessageCenter()) { | 169 if (NotificationUIManager::DelegatesToMessageCenter()) { |
| 168 LOG(ERROR) << "Attempt to run a test that requires " | 170 LOG(ERROR) << "Attempt to run a test that requires " |
| 169 << "BalloonNotificationUIManager while delegating to a " | 171 << "BalloonNotificationUIManager while delegating to a " |
| 170 << "native MessageCenter. Test will fail. Ask dimich@"; | 172 << "native MessageCenter. Test will fail. Ask dimich@"; |
| 171 return NULL; | 173 return NULL; |
| 172 } | 174 } |
| 173 return static_cast<BalloonNotificationUIManager*>( | 175 return static_cast<BalloonNotificationUIManager*>( |
| 174 g_browser_process->notification_ui_manager()); | 176 g_browser_process->notification_ui_manager()); |
| 175 } | 177 } |
| OLD | NEW |