Index: chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm |
diff --git a/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm b/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm |
index fd582a93865e62652e0af8baa22b7dee079a431c..4564d1103e857ec04e63980b45b2395e428f3b56 100644 |
--- a/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm |
+++ b/chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm |
@@ -45,6 +45,8 @@ enum NotificationOperation { |
objectForKey:notification_constants::kNotificationIncognito]; |
NSNumber* notificationType = [[notification userInfo] |
objectForKey:notification_constants::kNotificationType]; |
+ NSNumber* hasSettingsButton = [[notification userInfo] |
+ objectForKey:notification_constants::kNotificationHasSettingsButton]; |
// Closed notifications are not activated. |
NotificationOperation operation = |
@@ -54,7 +56,7 @@ enum NotificationOperation { |
int buttonIndex = -1; |
// Determine whether the user clicked on a button, and if they did, whether it |
- // was a developer-provided button or the mandatory Settings button. |
+ // was a developer-provided button or the Settings button. |
if (notification.activationType == |
NSUserNotificationActivationTypeActionButtonClicked) { |
NSArray* alternateButtons = @[]; |
@@ -64,26 +66,29 @@ enum NotificationOperation { |
[notification valueForKey:@"_alternateActionButtonTitles"]; |
} |
- bool multipleButtons = (alternateButtons.count > 0); |
+ BOOL settingsButtonRequired = [hasSettingsButton boolValue]; |
+ BOOL multipleButtons = (alternateButtons.count > 0); |
// No developer actions, just the settings button. |
if (!multipleButtons) { |
+ DCHECK(settingsButtonRequired); |
operation = NOTIFICATION_SETTINGS; |
buttonIndex = -1; |
} else { |
// 0 based array containing. |
// Button 1 |
// Button 2 (optional) |
- // Settings |
+ // Settings (if required) |
NSNumber* actionIndex = |
[notification valueForKey:@"_alternateActionIndex"]; |
- operation = (actionIndex.unsignedLongValue == alternateButtons.count - 1) |
+ operation = settingsButtonRequired && (actionIndex.unsignedLongValue == |
+ alternateButtons.count - 1) |
? NOTIFICATION_SETTINGS |
: NOTIFICATION_CLICK; |
- buttonIndex = |
- (actionIndex.unsignedLongValue == alternateButtons.count - 1) |
- ? -1 |
- : actionIndex.intValue; |
+ buttonIndex = settingsButtonRequired && (actionIndex.unsignedLongValue == |
+ alternateButtons.count - 1) |
Peter Beverloo
2017/04/07 16:19:05
nit: this would become a lot easier to read if you
|
+ ? -1 |
+ : actionIndex.intValue; |
} |
} |