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

Side by Side Diff: chrome/browser/notifications/notification_platform_bridge_mac.mm

Issue 2817813006: Make progress notifications an alert. (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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/notification_platform_bridge_mac.h" 5 #include "chrome/browser/notifications/notification_platform_bridge_mac.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 const Notification& notification) { 175 const Notification& notification) {
176 base::scoped_nsobject<NotificationBuilder> builder( 176 base::scoped_nsobject<NotificationBuilder> builder(
177 [[NotificationBuilder alloc] 177 [[NotificationBuilder alloc]
178 initWithCloseLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_CLOSE) 178 initWithCloseLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_CLOSE)
179 optionsLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_MORE) 179 optionsLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_MORE)
180 settingsLabel:l10n_util::GetNSString( 180 settingsLabel:l10n_util::GetNSString(
181 IDS_NOTIFICATION_BUTTON_SETTINGS)]); 181 IDS_NOTIFICATION_BUTTON_SETTINGS)]);
182 182
183 [builder 183 [builder
184 setTitle:base::SysUTF16ToNSString(CreateNotificationTitle(notification))]; 184 setTitle:base::SysUTF16ToNSString(CreateNotificationTitle(notification))];
185
185 [builder setContextMessage:base::SysUTF16ToNSString(notification.message())]; 186 [builder setContextMessage:base::SysUTF16ToNSString(notification.message())];
186 187
187 bool requires_attribution = 188 bool requires_attribution =
188 notification.context_message().empty() && 189 notification.context_message().empty() &&
189 notification_type != NotificationCommon::EXTENSION; 190 notification_type != NotificationCommon::EXTENSION;
190 191
191 base::string16 subtitle = 192 base::string16 subtitle =
192 requires_attribution 193 requires_attribution
193 ? url_formatter::FormatOriginForSecurityDisplay( 194 ? url_formatter::FormatOriginForSecurityDisplay(
194 url::Origin(notification.origin_url()), 195 url::Origin(notification.origin_url()),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 240
240 [builder setOrigin:base::SysUTF8ToNSString(notification.origin_url().spec())]; 241 [builder setOrigin:base::SysUTF8ToNSString(notification.origin_url().spec())];
241 [builder setNotificationId:base::SysUTF8ToNSString(notification_id)]; 242 [builder setNotificationId:base::SysUTF8ToNSString(notification_id)];
242 [builder setProfileId:base::SysUTF8ToNSString(profile_id)]; 243 [builder setProfileId:base::SysUTF8ToNSString(profile_id)];
243 [builder setIncognito:incognito]; 244 [builder setIncognito:incognito];
244 [builder setNotificationType:[NSNumber numberWithInteger:notification_type]]; 245 [builder setNotificationType:[NSNumber numberWithInteger:notification_type]];
245 246
246 // Send persistent notifications to the XPC service so they 247 // Send persistent notifications to the XPC service so they
247 // can be displayed as alerts. Chrome itself can only display 248 // can be displayed as alerts. Chrome itself can only display
248 // banners. 249 // banners.
249 if (notification.never_timeout()) { 250 if (notification.never_timeout() || notification.progress() > 0) {
Peter Beverloo 2017/04/13 14:14:14 Please detail why we're doing this in the comment
Miguel Garcia 2017/04/13 16:36:19 Done.
250 NSDictionary* dict = [builder buildDictionary]; 251 NSDictionary* dict = [builder buildDictionary];
251 [alert_dispatcher_ dispatchNotification:dict]; 252 [alert_dispatcher_ dispatchNotification:dict];
252 } else { 253 } else {
253 NSUserNotification* toast = [builder buildUserNotification]; 254 NSUserNotification* toast = [builder buildUserNotification];
254 [notification_center_ deliverNotification:toast]; 255 [notification_center_ deliverNotification:toast];
255 } 256 }
256 } 257 }
257 258
258 void NotificationPlatformBridgeMac::Close(const std::string& profile_id, 259 void NotificationPlatformBridgeMac::Close(const std::string& profile_id,
259 const std::string& notification_id) { 260 const std::string& notification_id) {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 base::scoped_nsobject<CrXPCMachPort> xpcPort( 548 base::scoped_nsobject<CrXPCMachPort> xpcPort(
548 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); 549 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]);
549 [proxy setMachExceptionPort:xpcPort]; 550 [proxy setMachExceptionPort:xpcPort];
550 setExceptionPort_ = YES; 551 setExceptionPort_ = YES;
551 } 552 }
552 553
553 return proxy; 554 return proxy;
554 } 555 }
555 556
556 @end 557 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698