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

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

Issue 2334613003: Re-write many calls to WrapUnique() with MakeUnique() (Closed)
Patch Set: Changes from review by sky 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 std::unique_ptr<message_center::NotifierSettingsProvider> settings_provider) 50 std::unique_ptr<message_center::NotifierSettingsProvider> settings_provider)
51 : message_center_(message_center), 51 : message_center_(message_center),
52 settings_provider_(std::move(settings_provider)), 52 settings_provider_(std::move(settings_provider)),
53 system_observer_(this), 53 system_observer_(this),
54 stats_collector_(message_center), 54 stats_collector_(message_center),
55 google_now_stats_collector_(message_center) { 55 google_now_stats_collector_(message_center) {
56 message_center_->AddObserver(this); 56 message_center_->AddObserver(this);
57 message_center_->SetNotifierSettingsProvider(settings_provider_.get()); 57 message_center_->SetNotifierSettingsProvider(settings_provider_.get());
58 58
59 #if defined(OS_CHROMEOS) 59 #if defined(OS_CHROMEOS)
60 blockers_.push_back(base::WrapUnique( 60 blockers_.push_back(
61 new LoginStateNotificationBlockerChromeOS(message_center))); 61 base::MakeUnique<LoginStateNotificationBlockerChromeOS>(message_center));
62 #else 62 #else
63 blockers_.push_back( 63 blockers_.push_back(
64 base::WrapUnique(new ScreenLockNotificationBlocker(message_center))); 64 base::MakeUnique<ScreenLockNotificationBlocker>(message_center));
65 #endif 65 #endif
66 blockers_.push_back( 66 blockers_.push_back(
67 base::WrapUnique(new FullscreenNotificationBlocker(message_center))); 67 base::MakeUnique<FullscreenNotificationBlocker>(message_center));
68 68
69 #if defined(OS_WIN) || defined(OS_MACOSX) \ 69 #if defined(OS_WIN) || defined(OS_MACOSX) \
70 || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) 70 || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
71 // On Windows, Linux and Mac, the notification manager owns the tray icon and 71 // On Windows, Linux and Mac, the notification manager owns the tray icon and
72 // views.Other platforms have global ownership and Create will return NULL. 72 // views.Other platforms have global ownership and Create will return NULL.
73 tray_.reset(message_center::CreateMessageCenterTray()); 73 tray_.reset(message_center::CreateMessageCenterTray());
74 #endif 74 #endif
75 } 75 }
76 76
77 MessageCenterNotificationManager::~MessageCenterNotificationManager() { 77 MessageCenterNotificationManager::~MessageCenterNotificationManager() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // Change it to send notifications to message center only when the user chose 109 // Change it to send notifications to message center only when the user chose
110 // default message center (extension_id.empty()). 110 // default message center (extension_id.empty()).
111 111
112 // If there exist apps/extensions that have notificationProvider permission, 112 // If there exist apps/extensions that have notificationProvider permission,
113 // route notifications to one of the apps/extensions. 113 // route notifications to one of the apps/extensions.
114 std::string extension_id = GetExtensionTakingOverNotifications(profile); 114 std::string extension_id = GetExtensionTakingOverNotifications(profile);
115 if (!extension_id.empty()) 115 if (!extension_id.empty())
116 AddNotificationToAlternateProvider(profile_notification->notification(), 116 AddNotificationToAlternateProvider(profile_notification->notification(),
117 profile, extension_id); 117 profile, extension_id);
118 118
119 message_center_->AddNotification(base::WrapUnique( 119 message_center_->AddNotification(
120 new message_center::Notification(profile_notification->notification()))); 120 base::MakeUnique<message_center::Notification>(
121 profile_notification->notification()));
121 } 122 }
122 123
123 bool MessageCenterNotificationManager::Update(const Notification& notification, 124 bool MessageCenterNotificationManager::Update(const Notification& notification,
124 Profile* profile) { 125 Profile* profile) {
125 const std::string& tag = notification.tag(); 126 const std::string& tag = notification.tag();
126 if (tag.empty()) 127 if (tag.empty())
127 return false; 128 return false;
128 129
129 const GURL origin_url = notification.origin_url(); 130 const GURL origin_url = notification.origin_url();
130 DCHECK(origin_url.is_valid()); 131 DCHECK(origin_url.is_valid());
(...skipping 23 matching lines...) Expand all
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
160 // WARNING: You MUST use AddProfileNotification or update the message 161 // WARNING: You MUST use AddProfileNotification or update the message
161 // center via the notification within a ProfileNotification object or the 162 // center via the notification within a ProfileNotification object or the
162 // profile ID will not be correctly set for ChromeOS. 163 // profile ID will not be correctly set for ChromeOS.
163 message_center_->UpdateNotification( 164 message_center_->UpdateNotification(
164 old_id, base::WrapUnique(new message_center::Notification( 165 old_id, base::MakeUnique<message_center::Notification>(
165 new_notification->notification()))); 166 new_notification->notification()));
166 167
167 return true; 168 return true;
168 } 169 }
169 } 170 }
170 return false; 171 return false;
171 } 172 }
172 173
173 const Notification* MessageCenterNotificationManager::FindById( 174 const Notification* MessageCenterNotificationManager::FindById(
174 const std::string& delegate_id, 175 const std::string& delegate_id,
175 ProfileID profile_id) const { 176 ProfileID profile_id) const {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 it != registry->enabled_extensions().end(); 380 it != registry->enabled_extensions().end();
380 ++it) { 381 ++it) {
381 if ((*it->get()).permissions_data()->HasAPIPermission( 382 if ((*it->get()).permissions_data()->HasAPIPermission(
382 extensions::APIPermission::ID::kNotificationProvider)) { 383 extensions::APIPermission::ID::kNotificationProvider)) {
383 extension_id = (*it->get()).id(); 384 extension_id = (*it->get()).id();
384 return extension_id; 385 return extension_id;
385 } 386 }
386 } 387 }
387 return extension_id; 388 return extension_id;
388 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698