| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 base::scoped_nsobject<NotificationBuilder> builder( | 165 base::scoped_nsobject<NotificationBuilder> builder( |
| 166 [[NotificationBuilder alloc] | 166 [[NotificationBuilder alloc] |
| 167 initWithCloseLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_CLOSE) | 167 initWithCloseLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_CLOSE) |
| 168 optionsLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_MORE) | 168 optionsLabel:l10n_util::GetNSString(IDS_NOTIFICATION_BUTTON_MORE) |
| 169 settingsLabel:l10n_util::GetNSString( | 169 settingsLabel:l10n_util::GetNSString( |
| 170 IDS_NOTIFICATION_BUTTON_SETTINGS)]); | 170 IDS_NOTIFICATION_BUTTON_SETTINGS)]); |
| 171 | 171 |
| 172 [builder setTitle:base::SysUTF16ToNSString(notification.title())]; | 172 [builder setTitle:base::SysUTF16ToNSString(notification.title())]; |
| 173 [builder setContextMessage:base::SysUTF16ToNSString(notification.message())]; | 173 [builder setContextMessage:base::SysUTF16ToNSString(notification.message())]; |
| 174 | 174 |
| 175 bool requires_attribution = |
| 176 notification.context_message().empty() && |
| 177 notification_type != NotificationCommon::EXTENSION; |
| 178 |
| 175 base::string16 subtitle = | 179 base::string16 subtitle = |
| 176 notification.context_message().empty() | 180 requires_attribution |
| 177 ? url_formatter::FormatOriginForSecurityDisplay( | 181 ? url_formatter::FormatOriginForSecurityDisplay( |
| 178 url::Origin(notification.origin_url()), | 182 url::Origin(notification.origin_url()), |
| 179 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS) | 183 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS) |
| 180 : notification.context_message(); | 184 : notification.context_message(); |
| 181 | 185 |
| 182 [builder setSubTitle:base::SysUTF16ToNSString(subtitle)]; | 186 [builder setSubTitle:base::SysUTF16ToNSString(subtitle)]; |
| 183 if (!notification.icon().IsEmpty()) { | 187 if (!notification.icon().IsEmpty()) { |
| 184 [builder setIcon:notification.icon().ToNSImage()]; | 188 [builder setIcon:notification.icon().ToNSImage()]; |
| 185 } | 189 } |
| 186 | 190 |
| 191 [builder setShowSettingsButton:(notification_type != |
| 192 NotificationCommon::EXTENSION)]; |
| 187 std::vector<message_center::ButtonInfo> buttons = notification.buttons(); | 193 std::vector<message_center::ButtonInfo> buttons = notification.buttons(); |
| 188 if (!buttons.empty()) { | 194 if (!buttons.empty()) { |
| 189 DCHECK_LE(buttons.size(), blink::kWebNotificationMaxActions); | 195 DCHECK_LE(buttons.size(), blink::kWebNotificationMaxActions); |
| 190 NSString* buttonOne = SysUTF16ToNSString(buttons[0].title); | 196 NSString* buttonOne = SysUTF16ToNSString(buttons[0].title); |
| 191 NSString* buttonTwo = nullptr; | 197 NSString* buttonTwo = nullptr; |
| 192 if (buttons.size() > 1) | 198 if (buttons.size() > 1) |
| 193 buttonTwo = SysUTF16ToNSString(buttons[1].title); | 199 buttonTwo = SysUTF16ToNSString(buttons[1].title); |
| 194 [builder setButtons:buttonOne secondaryButton:buttonTwo]; | 200 [builder setButtons:buttonOne secondaryButton:buttonTwo]; |
| 195 } | 201 } |
| 196 | 202 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 base::scoped_nsobject<CrXPCMachPort> xpcPort( | 535 base::scoped_nsobject<CrXPCMachPort> xpcPort( |
| 530 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); | 536 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); |
| 531 [proxy setMachExceptionPort:xpcPort]; | 537 [proxy setMachExceptionPort:xpcPort]; |
| 532 setExceptionPort_ = YES; | 538 setExceptionPort_ = YES; |
| 533 } | 539 } |
| 534 | 540 |
| 535 return proxy; | 541 return proxy; |
| 536 } | 542 } |
| 537 | 543 |
| 538 @end | 544 @end |
| OLD | NEW |