OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/notifications/notification_event_dispatcher_impl.h" | 5 #include "content/browser/notifications/notification_event_dispatcher_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/optional.h" | 8 #include "base/optional.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "content/browser/notifications/notification_message_filter.h" | 10 #include "content/browser/notifications/notification_message_filter.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 browser_context, notification_id, origin, | 387 browser_context, notification_id, origin, |
388 base::Bind(&DoDispatchNotificationCloseEvent, notification_id, by_user, | 388 base::Bind(&DoDispatchNotificationCloseEvent, notification_id, by_user, |
389 dispatch_complete_callback), | 389 dispatch_complete_callback), |
390 dispatch_complete_callback); | 390 dispatch_complete_callback); |
391 } | 391 } |
392 | 392 |
393 void NotificationEventDispatcherImpl::RegisterNonPersistentNotification( | 393 void NotificationEventDispatcherImpl::RegisterNonPersistentNotification( |
394 const std::string& notification_id, | 394 const std::string& notification_id, |
395 int renderer_id, | 395 int renderer_id, |
396 int non_persistent_id) { | 396 int non_persistent_id) { |
| 397 if (non_persistent_ids_.count(notification_id) && |
| 398 non_persistent_ids_[notification_id] != non_persistent_id) { |
| 399 // Notify close for a previously displayed notification with the same id, |
| 400 // this can happen when replacing a non-persistent notification with the |
| 401 // same tag since from the JS point of view there will be two notification |
| 402 // objects and the old one needs to receive the close event. |
| 403 // TODO(miguelg) this is probably not the right layer to do this. |
| 404 DispatchNonPersistentCloseEvent(notification_id); |
| 405 } |
397 renderer_ids_[notification_id] = renderer_id; | 406 renderer_ids_[notification_id] = renderer_id; |
398 non_persistent_ids_[notification_id] = non_persistent_id; | 407 non_persistent_ids_[notification_id] = non_persistent_id; |
399 } | 408 } |
400 | 409 |
401 void NotificationEventDispatcherImpl::DispatchNonPersistentShowEvent( | 410 void NotificationEventDispatcherImpl::DispatchNonPersistentShowEvent( |
402 const std::string& notification_id) { | 411 const std::string& notification_id) { |
403 if (!renderer_ids_.count(notification_id)) | 412 if (!renderer_ids_.count(notification_id)) |
404 return; | 413 return; |
405 DCHECK(non_persistent_ids_.count(notification_id)); | 414 DCHECK(non_persistent_ids_.count(notification_id)); |
406 | 415 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 if (iter->second == renderer_id) { | 467 if (iter->second == renderer_id) { |
459 non_persistent_ids_.erase(iter->first); | 468 non_persistent_ids_.erase(iter->first); |
460 iter = renderer_ids_.erase(iter); | 469 iter = renderer_ids_.erase(iter); |
461 } else { | 470 } else { |
462 iter++; | 471 iter++; |
463 } | 472 } |
464 } | 473 } |
465 } | 474 } |
466 | 475 |
467 } // namespace content | 476 } // namespace content |
OLD | NEW |