| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" | 5 #import "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" |
| 6 | 6 |
| 7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 - (NSUserNotification*)buildUserNotification { | 125 - (NSUserNotification*)buildUserNotification { |
| 126 base::scoped_nsobject<NSUserNotification> toast( | 126 base::scoped_nsobject<NSUserNotification> toast( |
| 127 [[NSUserNotification alloc] init]); | 127 [[NSUserNotification alloc] init]); |
| 128 [toast setTitle:[notificationData_ objectForKey:kNotificationTitle]]; | 128 [toast setTitle:[notificationData_ objectForKey:kNotificationTitle]]; |
| 129 [toast setSubtitle:[notificationData_ objectForKey:kNotificationSubTitle]]; | 129 [toast setSubtitle:[notificationData_ objectForKey:kNotificationSubTitle]]; |
| 130 [toast setInformativeText:[notificationData_ | 130 [toast setInformativeText:[notificationData_ |
| 131 objectForKey:kNotificationInformativeText]]; | 131 objectForKey:kNotificationInformativeText]]; |
| 132 | 132 |
| 133 // Icon | 133 // Icon |
| 134 if ([notificationData_ objectForKey:kNotificationImage]) { | 134 if ([notificationData_ objectForKey:kNotificationImage]) { |
| 135 if ([toast respondsToSelector:@selector(_identityImage)]) { | 135 if ([[NSImage class] conformsToProtocol:@protocol(NSSecureCoding)]) { |
| 136 if ([[NSImage class] conformsToProtocol:@protocol(NSSecureCoding)]) { | 136 NSImage* image = [notificationData_ objectForKey:kNotificationImage]; |
| 137 NSImage* image = [notificationData_ objectForKey:kNotificationImage]; | 137 [toast setContentImage:image]; |
| 138 [toast setValue:image forKey:@"_identityImage"]; | 138 } else { // NSImage only conforms to NSSecureCoding from 10.10 onwards. |
| 139 } else { // NSImage only conforms to NSSecureCoding from 10.10 onwards. | 139 base::scoped_nsobject<NSImage> image([[NSImage alloc] |
| 140 base::scoped_nsobject<NSImage> image([[NSImage alloc] | 140 initWithData:[notificationData_ objectForKey:kNotificationImage]]); |
| 141 initWithData:[notificationData_ objectForKey:kNotificationImage]]); | 141 [toast setContentImage:image]; |
| 142 [toast setValue:image forKey:@"_identityImage"]; | |
| 143 } | |
| 144 [toast setValue:@NO forKey:@"_identityImageHasBorder"]; | |
| 145 } | 142 } |
| 146 } | 143 } |
| 147 | 144 |
| 148 // Buttons | 145 // Buttons |
| 149 if ([toast respondsToSelector:@selector(_showsButtons)]) { | 146 if ([toast respondsToSelector:@selector(_showsButtons)]) { |
| 150 DCHECK([notificationData_ objectForKey:kNotificationCloseButtonTag]); | 147 DCHECK([notificationData_ objectForKey:kNotificationCloseButtonTag]); |
| 151 DCHECK([notificationData_ objectForKey:kNotificationSettingsButtonTag]); | 148 DCHECK([notificationData_ objectForKey:kNotificationSettingsButtonTag]); |
| 152 DCHECK([notificationData_ objectForKey:kNotificationOptionsButtonTag]); | 149 DCHECK([notificationData_ objectForKey:kNotificationOptionsButtonTag]); |
| 153 | 150 |
| 154 [toast setValue:@YES forKey:@"_showsButtons"]; | 151 [toast setValue:@YES forKey:@"_showsButtons"]; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 }; | 228 }; |
| 232 | 229 |
| 233 return toast.autorelease(); | 230 return toast.autorelease(); |
| 234 } | 231 } |
| 235 | 232 |
| 236 - (NSDictionary*)buildDictionary { | 233 - (NSDictionary*)buildDictionary { |
| 237 return [[notificationData_ copy] autorelease]; | 234 return [[notificationData_ copy] autorelease]; |
| 238 } | 235 } |
| 239 | 236 |
| 240 @end | 237 @end |
| OLD | NEW |