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

Unified Diff: chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm

Issue 2799343003: Add support for native extension notifications (Closed)
Patch Set: Remove dependent CL to land standalone Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698