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/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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 iter = show_queue_.erase(iter); | 117 iter = show_queue_.erase(iter); |
118 removed = true; | 118 removed = true; |
119 } else { | 119 } else { |
120 ++iter; | 120 ++iter; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 return balloon_collection_->RemoveBySourceOrigin(source) || removed; | 124 return balloon_collection_->RemoveBySourceOrigin(source) || removed; |
125 } | 125 } |
126 | 126 |
127 bool NotificationUIManagerImpl::CancelAllByProfile(Profile* profile) { | |
128 // Same pattern as CancelAllBySourceOrigin. | |
129 bool removed = false; | |
oshima
2012/11/29 02:21:50
is it ok to say
bool removed = balloon_collection_
stevenjb
2012/11/29 02:52:25
No, we set it in the for loop also. Should be clea
oshima
2012/11/29 16:57:48
I think you can because the loop changes the value
| |
130 NotificationDeque::iterator iter; | |
131 for (iter = show_queue_.begin(); iter != show_queue_.end();) { | |
oshima
2012/11/29 02:21:50
Move the iter def into for, or if you want to keep
stevenjb
2012/11/29 02:52:25
I didn't write these iterators, I just copy/pasted
| |
132 if ((*iter)->profile() == profile) { | |
133 iter = show_queue_.erase(iter); | |
134 removed = true; | |
135 } else { | |
136 ++iter; | |
137 } | |
138 } | |
139 | |
140 return balloon_collection_->RemoveByProfile(profile) || removed; | |
141 } | |
142 | |
127 void NotificationUIManagerImpl::CancelAll() { | 143 void NotificationUIManagerImpl::CancelAll() { |
128 STLDeleteElements(&show_queue_); | 144 STLDeleteElements(&show_queue_); |
129 balloon_collection_->RemoveAll(); | 145 balloon_collection_->RemoveAll(); |
130 } | 146 } |
131 | 147 |
132 BalloonCollection* NotificationUIManagerImpl::balloon_collection() { | 148 BalloonCollection* NotificationUIManagerImpl::balloon_collection() { |
133 return balloon_collection_.get(); | 149 return balloon_collection_.get(); |
134 } | 150 } |
135 | 151 |
136 NotificationPrefsManager* NotificationUIManagerImpl::prefs_manager() { | 152 NotificationPrefsManager* NotificationUIManagerImpl::prefs_manager() { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 } else { | 259 } else { |
244 NOTREACHED(); | 260 NOTREACHED(); |
245 } | 261 } |
246 } | 262 } |
247 | 263 |
248 void NotificationUIManagerImpl::OnDesktopNotificationPositionChanged() { | 264 void NotificationUIManagerImpl::OnDesktopNotificationPositionChanged() { |
249 balloon_collection_->SetPositionPreference( | 265 balloon_collection_->SetPositionPreference( |
250 static_cast<BalloonCollection::PositionPreference>( | 266 static_cast<BalloonCollection::PositionPreference>( |
251 position_pref_.GetValue())); | 267 position_pref_.GetValue())); |
252 } | 268 } |
OLD | NEW |