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_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 return false; | 224 return false; |
225 | 225 |
226 RemoveProfileNotification(iter->second); | 226 RemoveProfileNotification(iter->second); |
227 message_center_->RemoveNotification(profile_notification_id, | 227 message_center_->RemoveNotification(profile_notification_id, |
228 /* by_user */ false); | 228 /* by_user */ false); |
229 return true; | 229 return true; |
230 } | 230 } |
231 | 231 |
232 std::set<std::string> | 232 std::set<std::string> |
233 MessageCenterNotificationManager::GetAllIdsByProfileAndSourceOrigin( | 233 MessageCenterNotificationManager::GetAllIdsByProfileAndSourceOrigin( |
234 Profile* profile, | 234 ProfileID profile_id, |
235 const GURL& source) { | 235 const GURL& source) { |
236 // The profile pointer can be weak, the instance may have been destroyed, so | 236 // The profile pointer can be weak, the instance may have been destroyed, so |
Peter Beverloo
2015/05/21 11:28:48
nit: You can now remove this comment.
Deepak
2015/05/21 14:01:07
Done.
| |
237 // no profile method should be called inside this function. | 237 // no profile method should be called inside this function. |
238 | 238 |
239 std::set<std::string> delegate_ids; | 239 std::set<std::string> delegate_ids; |
240 for (const auto& pair : profile_notifications_) { | 240 for (const auto& pair : profile_notifications_) { |
241 const Notification& notification = pair.second->notification(); | 241 const Notification& notification = pair.second->notification(); |
242 if (pair.second->profile() == profile && | 242 if (pair.second->profile() == profile_id && |
243 notification.origin_url() == source) { | 243 notification.origin_url() == source) { |
244 delegate_ids.insert(notification.delegate_id()); | 244 delegate_ids.insert(notification.delegate_id()); |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 return delegate_ids; | 248 return delegate_ids; |
249 } | 249 } |
250 | 250 |
251 std::set<std::string> MessageCenterNotificationManager::GetAllIdsByProfile( | 251 std::set<std::string> MessageCenterNotificationManager::GetAllIdsByProfile( |
252 Profile* profile) { | 252 ProfileID profile_id) { |
253 // The profile pointer can be weak, the instance may have been destroyed, so | 253 // The profile pointer can be weak, the instance may have been destroyed, so |
Peter Beverloo
2015/05/21 11:28:48
nit: You can now remove this comment.
Deepak
2015/05/21 14:01:07
Done.
| |
254 // no profile method should be called inside this function. | 254 // no profile method should be called inside this function. |
255 | 255 |
256 std::set<std::string> delegate_ids; | 256 std::set<std::string> delegate_ids; |
257 for (const auto& pair : profile_notifications_) { | 257 for (const auto& pair : profile_notifications_) { |
258 if (pair.second->profile() == profile) | 258 if (pair.second->profile() == profile_id) |
Peter Beverloo
2015/05/21 11:28:48
This is now a [Profile* == void*] comparison. Even
Deepak
2015/05/21 14:01:07
Done.
| |
259 delegate_ids.insert(pair.second->notification().delegate_id()); | 259 delegate_ids.insert(pair.second->notification().delegate_id()); |
260 } | 260 } |
261 | 261 |
262 return delegate_ids; | 262 return delegate_ids; |
263 } | 263 } |
264 | 264 |
265 bool MessageCenterNotificationManager::CancelAllBySourceOrigin( | 265 bool MessageCenterNotificationManager::CancelAllBySourceOrigin( |
266 const GURL& source) { | 266 const GURL& source) { |
267 // Same pattern as CancelById, but more complicated than the above | 267 // Same pattern as CancelById, but more complicated than the above |
268 // because there may be multiple notifications from the same source. | 268 // because there may be multiple notifications from the same source. |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 it != registry->enabled_extensions().end(); | 421 it != registry->enabled_extensions().end(); |
422 ++it) { | 422 ++it) { |
423 if ((*it->get()).permissions_data()->HasAPIPermission( | 423 if ((*it->get()).permissions_data()->HasAPIPermission( |
424 extensions::APIPermission::ID::kNotificationProvider)) { | 424 extensions::APIPermission::ID::kNotificationProvider)) { |
425 extension_id = (*it->get()).id(); | 425 extension_id = (*it->get()).id(); |
426 return extension_id; | 426 return extension_id; |
427 } | 427 } |
428 } | 428 } |
429 return extension_id; | 429 return extension_id; |
430 } | 430 } |
OLD | NEW |