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

Side by Side Diff: chrome/browser/notifications/message_center_notification_display_service.cc

Issue 1814923002: Nuke NotificationUIManager from PlatformNotificationServiceImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@profile_manager_load
Patch Set: Rebase Created 4 years, 9 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/notifications/message_center_notification_display_servi ce.h"
6
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/notifications/notification.h"
9 #include "chrome/browser/notifications/notification_ui_manager.h"
10 #include "chrome/browser/profiles/profile.h"
11
12 #if !defined(OS_MACOSX)
13 // static
14 NotificationDisplayService* NotificationDisplayService::Create(
15 Profile* profile) {
16 return new MessageCenterNotificationDisplayService(profile);
17 }
18 #endif
19
20 MessageCenterNotificationDisplayService::
21 MessageCenterNotificationDisplayService(Profile* profile)
22 : NotificationDisplayService(profile) {}
23
24 void MessageCenterNotificationDisplayService::Display(
25 const Notification& notification) {
26 g_browser_process->notification_ui_manager()->Add(notification, profile_);
27 }
28
29 bool MessageCenterNotificationDisplayService::Close(
30 const std::string& notification_id) {
31 return g_browser_process->notification_ui_manager()->CancelById(
32 notification_id, NotificationUIManager::GetProfileID(profile_));
33 }
34
35 std::set<std::string> MessageCenterNotificationDisplayService::GetDisplayed()
36 const {
37 // There may not be a notification ui manager when another feature erroneously
38 // instantiates a storage partition when the browser process is shutting down.
39 // TODO(peter): Remove in favor of a DCHECK when crbug.com/546745 is fixed.
40 NotificationUIManager* ui_manager =
41 g_browser_process->notification_ui_manager();
42 if (!ui_manager)
43 return std::set<std::string>();
44
45 return ui_manager->GetAllIdsByProfile(
46 NotificationUIManager::GetProfileID(profile_));
47 }
48
49 bool MessageCenterNotificationDisplayService::SupportsNotificationCenter()
50 const {
51 return false;
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698