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

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

Issue 2776933006: CrOS: Do not allow notifications to be added during shutdown. (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
« no previous file with comments | « no previous file | chrome/browser/notifications/message_center_notifications_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/notifications/extension_welcome_notification.h" 14 #include "chrome/browser/notifications/extension_welcome_notification.h"
14 #include "chrome/browser/notifications/extension_welcome_notification_factory.h" 15 #include "chrome/browser/notifications/extension_welcome_notification_factory.h"
15 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" 16 #include "chrome/browser/notifications/fullscreen_notification_blocker.h"
16 #include "chrome/browser/notifications/message_center_settings_controller.h" 17 #include "chrome/browser/notifications/message_center_settings_controller.h"
17 #include "chrome/browser/notifications/notification.h" 18 #include "chrome/browser/notifications/notification.h"
18 #include "chrome/browser/notifications/profile_notification.h" 19 #include "chrome/browser/notifications/profile_notification.h"
19 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" 20 #include "chrome/browser/notifications/screen_lock_notification_blocker.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/url_constants.h" 23 #include "content/public/common/url_constants.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 MessageCenterNotificationManager::~MessageCenterNotificationManager() { 72 MessageCenterNotificationManager::~MessageCenterNotificationManager() {
72 message_center_->SetNotifierSettingsProvider(nullptr); 73 message_center_->SetNotifierSettingsProvider(nullptr);
73 message_center_->RemoveObserver(this); 74 message_center_->RemoveObserver(this);
74 75
75 profile_notifications_.clear(); 76 profile_notifications_.clear();
76 } 77 }
77 78
78 //////////////////////////////////////////////////////////////////////////////// 79 ////////////////////////////////////////////////////////////////////////////////
79 // NotificationUIManager 80 // NotificationUIManager
80 81
81 void MessageCenterNotificationManager::Add(const Notification& notification, 82 void MessageCenterNotificationManager::Add(const Notification& notification,
sky 2017/03/28 22:00:34 Would it make more sense for this class to be dest
sammiequon 2017/03/28 23:12:08 It would, but would this cause a bunch of other bu
stevenjb 2017/03/29 00:21:33 I would also be worried about dereferencing errors
82 Profile* profile) { 83 Profile* profile) {
84 // We won't have time to process and act on this notification.
85 if (g_browser_process->IsShuttingDown())
86 return;
87
83 if (Update(notification, profile)) 88 if (Update(notification, profile))
84 return; 89 return;
85 90
86 std::unique_ptr<ProfileNotification> profile_notification_ptr = 91 std::unique_ptr<ProfileNotification> profile_notification_ptr =
87 base::MakeUnique<ProfileNotification>(profile, notification); 92 base::MakeUnique<ProfileNotification>(profile, notification);
88 ProfileNotification* profile_notification = profile_notification_ptr.get(); 93 ProfileNotification* profile_notification = profile_notification_ptr.get();
89 94
90 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> 95 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)->
91 ShowWelcomeNotificationIfNecessary(profile_notification->notification()); 96 ShowWelcomeNotificationIfNecessary(profile_notification->notification());
92 97
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 340 }
336 341
337 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification( 342 ProfileNotification* MessageCenterNotificationManager::FindProfileNotification(
338 const std::string& id) const { 343 const std::string& id) const {
339 auto iter = profile_notifications_.find(id); 344 auto iter = profile_notifications_.find(id);
340 if (iter == profile_notifications_.end()) 345 if (iter == profile_notifications_.end())
341 return nullptr; 346 return nullptr;
342 347
343 return (*iter).second.get(); 348 return (*iter).second.get();
344 } 349 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/message_center_notifications_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698