Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/ui/cocoa/notifications/notification_builder_mac.mm

Issue 2764113004: [Mac] Revert to using the public API to display notification icons (Closed)
Patch Set: review Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 setValue:image forKey:@"contentImage"];
Robert Sesek 2017/03/22 21:41:10 Actually, this can now be just setContentImage: ri
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 setValue:image forKey:@"contentImage"];
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698