| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 // Progress Notifications are always considered persistent. |
| 251 if (notification.never_timeout() || notification.progress() > 0) { |
| 250 NSDictionary* dict = [builder buildDictionary]; | 252 NSDictionary* dict = [builder buildDictionary]; |
| 251 [alert_dispatcher_ dispatchNotification:dict]; | 253 [alert_dispatcher_ dispatchNotification:dict]; |
| 252 } else { | 254 } else { |
| 253 NSUserNotification* toast = [builder buildUserNotification]; | 255 NSUserNotification* toast = [builder buildUserNotification]; |
| 254 [notification_center_ deliverNotification:toast]; | 256 [notification_center_ deliverNotification:toast]; |
| 255 } | 257 } |
| 256 } | 258 } |
| 257 | 259 |
| 258 void NotificationPlatformBridgeMac::Close(const std::string& profile_id, | 260 void NotificationPlatformBridgeMac::Close(const std::string& profile_id, |
| 259 const std::string& notification_id) { | 261 const std::string& notification_id) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 base::scoped_nsobject<CrXPCMachPort> xpcPort( | 549 base::scoped_nsobject<CrXPCMachPort> xpcPort( |
| 548 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); | 550 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); |
| 549 [proxy setMachExceptionPort:xpcPort]; | 551 [proxy setMachExceptionPort:xpcPort]; |
| 550 setExceptionPort_ = YES; | 552 setExceptionPort_ = YES; |
| 551 } | 553 } |
| 552 | 554 |
| 553 return proxy; | 555 return proxy; |
| 554 } | 556 } |
| 555 | 557 |
| 556 @end | 558 @end |
| OLD | NEW |