| 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/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 BalloonCollection* BalloonNotificationUIManager::balloon_collection() { | 73 BalloonCollection* BalloonNotificationUIManager::balloon_collection() { |
| 74 return balloon_collection_.get(); | 74 return balloon_collection_.get(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 NotificationPrefsManager* BalloonNotificationUIManager::prefs_manager() { | 77 NotificationPrefsManager* BalloonNotificationUIManager::prefs_manager() { |
| 78 return this; | 78 return this; |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool BalloonNotificationUIManager::ShowNotification( | 81 bool BalloonNotificationUIManager::ShowNotification( |
| 82 const Notification& notification, Profile* profile) { | 82 const Notification& notification, |
| 83 Profile* profile) { |
| 83 if (!balloon_collection_->HasSpace()) | 84 if (!balloon_collection_->HasSpace()) |
| 84 return false; | 85 return false; |
| 85 balloon_collection_->Add(notification, profile); | 86 balloon_collection_->Add(notification, profile); |
| 86 return true; | 87 return true; |
| 87 } | 88 } |
| 88 | 89 |
| 89 void BalloonNotificationUIManager::OnBalloonSpaceChanged() { | 90 void BalloonNotificationUIManager::OnBalloonSpaceChanged() { |
| 90 CheckAndShowNotifications(); | 91 CheckAndShowNotifications(); |
| 91 } | 92 } |
| 92 | 93 |
| 93 bool BalloonNotificationUIManager::UpdateNotification( | 94 bool BalloonNotificationUIManager::UpdateNotification( |
| 94 const Notification& notification) { | 95 const Notification& notification, |
| 96 Profile* profile) { |
| 95 const GURL& origin = notification.origin_url(); | 97 const GURL& origin = notification.origin_url(); |
| 96 const string16& replace_id = notification.replace_id(); | 98 const string16& replace_id = notification.replace_id(); |
| 97 | 99 |
| 98 DCHECK(!replace_id.empty()); | 100 DCHECK(!replace_id.empty()); |
| 99 | 101 |
| 100 const BalloonCollection::Balloons& balloons = | 102 const BalloonCollection::Balloons& balloons = |
| 101 balloon_collection_->GetActiveBalloons(); | 103 balloon_collection_->GetActiveBalloons(); |
| 102 for (BalloonCollection::Balloons::const_iterator iter = balloons.begin(); | 104 for (BalloonCollection::Balloons::const_iterator iter = balloons.begin(); |
| 103 iter != balloons.end(); ++iter) { | 105 iter != balloons.end(); ++iter) { |
| 104 if (origin == (*iter)->notification().origin_url() && | 106 if (profile == (*iter)->profile() && |
| 107 origin == (*iter)->notification().origin_url() && |
| 105 replace_id == (*iter)->notification().replace_id()) { | 108 replace_id == (*iter)->notification().replace_id()) { |
| 106 (*iter)->Update(notification); | 109 (*iter)->Update(notification); |
| 107 return true; | 110 return true; |
| 108 } | 111 } |
| 109 } | 112 } |
| 110 | 113 |
| 111 return false; | 114 return false; |
| 112 } | 115 } |
| 113 | 116 |
| 114 BalloonCollection::PositionPreference | 117 BalloonCollection::PositionPreference |
| (...skipping 23 matching lines...) Expand all Loading... |
| 138 if (NotificationUIManager::DelegatesToMessageCenter()) { | 141 if (NotificationUIManager::DelegatesToMessageCenter()) { |
| 139 LOG(ERROR) << "Attempt to run a test that requires " | 142 LOG(ERROR) << "Attempt to run a test that requires " |
| 140 << "BalloonNotificationUIManager while delegating to a " | 143 << "BalloonNotificationUIManager while delegating to a " |
| 141 << "native MessageCenter. Test will fail. Ask dimich@"; | 144 << "native MessageCenter. Test will fail. Ask dimich@"; |
| 142 return NULL; | 145 return NULL; |
| 143 } | 146 } |
| 144 return static_cast<BalloonNotificationUIManager*>( | 147 return static_cast<BalloonNotificationUIManager*>( |
| 145 g_browser_process->notification_ui_manager()); | 148 g_browser_process->notification_ui_manager()); |
| 146 } | 149 } |
| 147 | 150 |
| OLD | NEW |