OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/extensions/api/notifications/extension_notification_dis
play_helper.h" | 5 #include "chrome/browser/extensions/api/notifications/extension_notification_dis
play_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 bool ExtensionNotificationDisplayHelper::Close( | 73 bool ExtensionNotificationDisplayHelper::Close( |
74 const std::string& notification_id) { | 74 const std::string& notification_id) { |
75 if (!EraseDataForNotificationId(notification_id)) | 75 if (!EraseDataForNotificationId(notification_id)) |
76 return false; | 76 return false; |
77 | 77 |
78 GetDisplayService()->Close(NotificationCommon::EXTENSION, notification_id); | 78 GetDisplayService()->Close(NotificationCommon::EXTENSION, notification_id); |
79 return true; | 79 return true; |
80 } | 80 } |
81 | 81 |
82 void ExtensionNotificationDisplayHelper::Shutdown() { | 82 void ExtensionNotificationDisplayHelper::Shutdown() { |
83 for (const std::unique_ptr<Notification>& notification : notifications_) { | 83 // Do not call GetDisplayService()->Close() here. |
84 GetDisplayService()->Close(NotificationCommon::EXTENSION, | 84 // This is called upon profile destruction and closing a notification |
85 notification->delegate_id()); | 85 // requires a profile. Both the message center and the bridge |
86 } | 86 // notificatiosn will clean up notifications upon exit so all |
| 87 // that is needed here is cleaning up the internal state. |
87 | 88 |
88 notifications_.clear(); | 89 notifications_.clear(); |
89 } | 90 } |
90 | 91 |
91 NotificationDisplayService* | 92 NotificationDisplayService* |
92 ExtensionNotificationDisplayHelper::GetDisplayService() { | 93 ExtensionNotificationDisplayHelper::GetDisplayService() { |
93 return NotificationDisplayServiceFactory::GetForProfile(profile_); | 94 return NotificationDisplayServiceFactory::GetForProfile(profile_); |
94 } | 95 } |
95 | 96 |
96 } // namespace extensions | 97 } // namespace extensions |
OLD | NEW |