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_ui_manager_mac.h" | 5 #include "chrome/browser/notifications/notification_ui_manager_mac.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 notification.context_message().empty() | 114 notification.context_message().empty() |
115 ? base::SysUTF8ToNSString(notification.origin_url().spec()) | 115 ? base::SysUTF8ToNSString(notification.origin_url().spec()) |
116 : base::SysUTF16ToNSString(notification.context_message()); | 116 : base::SysUTF16ToNSString(notification.context_message()); |
117 [toast setInformativeText:informativeText]; | 117 [toast setInformativeText:informativeText]; |
118 | 118 |
119 // TODO(miguelg): Implement support for buttons | 119 // TODO(miguelg): Implement support for buttons |
120 toast.get().hasActionButton = NO; | 120 toast.get().hasActionButton = NO; |
121 | 121 |
122 // Some functionality is only available in 10.9+ or requires private APIs | 122 // Some functionality is only available in 10.9+ or requires private APIs |
123 // Icon | 123 // Icon |
124 if ([toast respondsToSelector:@selector(_identityImage)]) { | 124 if ([toast respondsToSelector:@selector(_identityImage)] && |
| 125 !notification.icon().IsEmpty()) { |
125 [toast setValue:notification.icon().ToNSImage() forKey:@"_identityImage"]; | 126 [toast setValue:notification.icon().ToNSImage() forKey:@"_identityImage"]; |
126 [toast setValue:@NO forKey:@"_identityImageHasBorder"]; | 127 [toast setValue:@NO forKey:@"_identityImageHasBorder"]; |
127 } | 128 } |
128 | 129 |
129 // Tag | 130 // Tag |
130 if ([toast respondsToSelector:@selector(setIdentifier:)] && | 131 if ([toast respondsToSelector:@selector(setIdentifier:)] && |
131 !notification.tag().empty()) { | 132 !notification.tag().empty()) { |
132 [toast setValue:base::SysUTF8ToNSString(notification.tag()) | 133 [toast setValue:base::SysUTF8ToNSString(notification.tag()) |
133 forKey:@"identifier"]; | 134 forKey:@"identifier"]; |
134 } | 135 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 -1 /* buttons not yet implemented */); | 269 -1 /* buttons not yet implemented */); |
269 } | 270 } |
270 | 271 |
271 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 272 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
272 shouldPresentNotification:(NSUserNotification*)nsNotification { | 273 shouldPresentNotification:(NSUserNotification*)nsNotification { |
273 // Always display notifications, regardless of whether the app is foreground. | 274 // Always display notifications, regardless of whether the app is foreground. |
274 return YES; | 275 return YES; |
275 } | 276 } |
276 | 277 |
277 @end | 278 @end |
OLD | NEW |