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

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

Issue 2423633003: Reland of Implement support for closing mac native notifications (Closed)
Patch Set: Created 4 years, 2 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
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_response_builder_mac .h" 5 #import "chrome/browser/ui/cocoa/notifications/notification_response_builder_mac .h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" 8 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h"
9 9
10 namespace { 10 namespace {
(...skipping 28 matching lines...) Expand all
39 NSString* profileId = [[notification userInfo] 39 NSString* profileId = [[notification userInfo]
40 objectForKey:notification_constants::kNotificationProfileId]; 40 objectForKey:notification_constants::kNotificationProfileId];
41 41
42 DCHECK([[notification userInfo] 42 DCHECK([[notification userInfo]
43 objectForKey:notification_constants::kNotificationIncognito]); 43 objectForKey:notification_constants::kNotificationIncognito]);
44 NSNumber* incognito = [[notification userInfo] 44 NSNumber* incognito = [[notification userInfo]
45 objectForKey:notification_constants::kNotificationIncognito]; 45 objectForKey:notification_constants::kNotificationIncognito];
46 NSNumber* notificationType = [[notification userInfo] 46 NSNumber* notificationType = [[notification userInfo]
47 objectForKey:notification_constants::kNotificationType]; 47 objectForKey:notification_constants::kNotificationType];
48 48
49 // Initialize operation and button index for the case where the 49 // Closed notifications are not activated.
50 // notification itself was clicked. 50 NotificationOperation operation =
51 NotificationOperation operation = NOTIFICATION_CLICK; 51 notification.activationType == NSUserNotificationActivationTypeNone
52 ? NOTIFICATION_CLOSE
53 : NOTIFICATION_CLICK;
52 int buttonIndex = -1; 54 int buttonIndex = -1;
53 55
54 // Determine whether the user clicked on a button, and if they did, whether it 56 // Determine whether the user clicked on a button, and if they did, whether it
55 // was a developer-provided button or the mandatory Settings button. 57 // was a developer-provided button or the mandatory Settings button.
56 if (notification.activationType == 58 if (notification.activationType ==
57 NSUserNotificationActivationTypeActionButtonClicked) { 59 NSUserNotificationActivationTypeActionButtonClicked) {
58 NSArray* alternateButtons = @[]; 60 NSArray* alternateButtons = @[];
59 if ([notification 61 if ([notification
60 respondsToSelector:@selector(_alternateActionButtonTitles)]) { 62 respondsToSelector:@selector(_alternateActionButtonTitles)]) {
61 alternateButtons = 63 alternateButtons =
(...skipping 30 matching lines...) Expand all
92 notification_constants::kNotificationIncognito : incognito, 94 notification_constants::kNotificationIncognito : incognito,
93 notification_constants::kNotificationType : notificationType, 95 notification_constants::kNotificationType : notificationType,
94 notification_constants:: 96 notification_constants::
95 kNotificationOperation : [NSNumber numberWithInt:operation], 97 kNotificationOperation : [NSNumber numberWithInt:operation],
96 notification_constants:: 98 notification_constants::
97 kNotificationButtonIndex : [NSNumber numberWithInt:buttonIndex], 99 kNotificationButtonIndex : [NSNumber numberWithInt:buttonIndex],
98 }; 100 };
99 } 101 }
100 102
101 @end 103 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698