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

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

Issue 2300093002: Make //content responsible for generating notification Ids (Closed)
Patch Set: comments Created 4 years, 3 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 (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"
(...skipping 26 matching lines...) Expand all
37 #if defined(OS_CHROMEOS) 37 #if defined(OS_CHROMEOS)
38 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos .h" 38 #include "chrome/browser/notifications/login_state_notification_blocker_chromeos .h"
39 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 39 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
40 #endif 40 #endif
41 41
42 #if defined(USE_ASH) 42 #if defined(USE_ASH)
43 #include "ash/common/system/web_notification/web_notification_tray.h" 43 #include "ash/common/system/web_notification/web_notification_tray.h"
44 #include "ash/shell.h" 44 #include "ash/shell.h"
45 #endif 45 #endif
46 46
47 using message_center::NotifierId;
47 48
48 MessageCenterNotificationManager::MessageCenterNotificationManager( 49 MessageCenterNotificationManager::MessageCenterNotificationManager(
49 message_center::MessageCenter* message_center, 50 message_center::MessageCenter* message_center,
50 std::unique_ptr<message_center::NotifierSettingsProvider> settings_provider) 51 std::unique_ptr<message_center::NotifierSettingsProvider> settings_provider)
51 : message_center_(message_center), 52 : message_center_(message_center),
52 settings_provider_(std::move(settings_provider)), 53 settings_provider_(std::move(settings_provider)),
53 system_observer_(this), 54 system_observer_(this),
54 stats_collector_(message_center), 55 stats_collector_(message_center),
55 google_now_stats_collector_(message_center) { 56 google_now_stats_collector_(message_center) {
56 message_center_->AddObserver(this); 57 message_center_->AddObserver(this);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Delete the old one after the new one is created to ensure we don't run 151 // Delete the old one after the new one is created to ensure we don't run
151 // out of KeepAlives. 152 // out of KeepAlives.
152 delete old_notification; 153 delete old_notification;
153 profile_notifications_.erase(old_id); 154 profile_notifications_.erase(old_id);
154 profile_notifications_[new_notification->notification().id()] = 155 profile_notifications_[new_notification->notification().id()] =
155 new_notification; 156 new_notification;
156 157
157 // TODO(liyanhou): Add routing updated notifications to alternative 158 // TODO(liyanhou): Add routing updated notifications to alternative
158 // providers. 159 // providers.
159 160
161 // Non-persistent Web Notifications rely on receiving the Display() event
162 // to inform the developer, even when replacing a previous notification.
163 if (notification.notifier_id().type == NotifierId::WEB_PAGE)
164 notification.delegate()->Display();
165
160 // WARNING: You MUST use AddProfileNotification or update the message 166 // WARNING: You MUST use AddProfileNotification or update the message
161 // center via the notification within a ProfileNotification object or the 167 // center via the notification within a ProfileNotification object or the
162 // profile ID will not be correctly set for ChromeOS. 168 // profile ID will not be correctly set for ChromeOS.
163 message_center_->UpdateNotification( 169 message_center_->UpdateNotification(
164 old_id, base::WrapUnique(new message_center::Notification( 170 old_id, base::WrapUnique(new message_center::Notification(
165 new_notification->notification()))); 171 new_notification->notification())));
166 172
167 return true; 173 return true;
168 } 174 }
169 } 175 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 it != registry->enabled_extensions().end(); 385 it != registry->enabled_extensions().end();
380 ++it) { 386 ++it) {
381 if ((*it->get()).permissions_data()->HasAPIPermission( 387 if ((*it->get()).permissions_data()->HasAPIPermission(
382 extensions::APIPermission::ID::kNotificationProvider)) { 388 extensions::APIPermission::ID::kNotificationProvider)) {
383 extension_id = (*it->get()).id(); 389 extension_id = (*it->get()).id();
384 return extension_id; 390 return extension_id;
385 } 391 }
386 } 392 }
387 return extension_id; 393 return extension_id;
388 } 394 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698