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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // stringWithFormat. It seems that the informativeText font is constant. | 112 // stringWithFormat. It seems that the informativeText font is constant. |
113 NSString* informativeText = | 113 NSString* informativeText = |
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+ | 122 // Some functionality is only available in 10.9+ or requires private APIs |
123 // Icon | 123 // Icon |
124 if ([toast respondsToSelector:@selector(setContentImage:)]) { | 124 if ([toast respondsToSelector:@selector(_identityImage)]) { |
125 [toast setValue:notification.icon().ToNSImage() forKey:@"contentImage"]; | 125 [toast setValue:notification.icon().ToNSImage() forKey:@"_identityImage"]; |
| 126 [toast setValue:@NO forKey:@"_identityImageHasBorder"]; |
126 } | 127 } |
127 | 128 |
128 // Tag | 129 // Tag |
129 if ([toast respondsToSelector:@selector(setIdentifier:)] && | 130 if ([toast respondsToSelector:@selector(setIdentifier:)] && |
130 !notification.tag().empty()) { | 131 !notification.tag().empty()) { |
131 [toast setValue:base::SysUTF8ToNSString(notification.tag()) | 132 [toast setValue:base::SysUTF8ToNSString(notification.tag()) |
132 forKey:@"identifier"]; | 133 forKey:@"identifier"]; |
133 } | 134 } |
134 | 135 |
135 int64_t persistent_notification_id = delegate->persistent_notification_id(); | 136 int64_t persistent_notification_id = delegate->persistent_notification_id(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 -1 /* buttons not yet implemented */); | 268 -1 /* buttons not yet implemented */); |
268 } | 269 } |
269 | 270 |
270 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 271 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
271 shouldPresentNotification:(NSUserNotification*)nsNotification { | 272 shouldPresentNotification:(NSUserNotification*)nsNotification { |
272 // Always display notifications, regardless of whether the app is foreground. | 273 // Always display notifications, regardless of whether the app is foreground. |
273 return YES; | 274 return YES; |
274 } | 275 } |
275 | 276 |
276 @end | 277 @end |
OLD | NEW |