Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: chrome/browser/extensions/api/notifications/extension_notification_display_helper.cc

Issue 2799343003: Add support for native extension notifications (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698