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

Unified Diff: chrome/browser/notifications/notification_platform_bridge_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/notification_platform_bridge_mac.mm
diff --git a/chrome/browser/notifications/notification_platform_bridge_mac.mm b/chrome/browser/notifications/notification_platform_bridge_mac.mm
index 3cc13058b69224b052a853d9f67f8f80d53f12de..6b3c20dc60e789395257adb0ddd1f115608ac000 100644
--- a/chrome/browser/notifications/notification_platform_bridge_mac.mm
+++ b/chrome/browser/notifications/notification_platform_bridge_mac.mm
@@ -48,7 +48,6 @@
// Site settings button is implemented as NSUserNotification's action button
// Not easy to implement:
// -notification.requireInteraction
-// -The event associated to the close button
// TODO(miguelg) implement the following features
// - Sound names can be implemented by setting soundName in NSUserNotification
@@ -88,6 +87,7 @@
const std::string& notification_id,
int32_t button_index) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
ProfileManager* profileManager = g_browser_process->profile_manager();
DCHECK(profileManager);
@@ -378,6 +378,20 @@
notificationResponse);
}
+// Overriden from _NSUserNotificationCenterDelegatePrivate.
+// Emitted when a user clicks the "Close" button in the notification.
+// It not is emitted if the notification is closed from the notification
+// center or if the app is not running at the time the Close button is
+// pressed so it's essentially just a best effort way to detect
+// notifications closed by the user.
+- (void)userNotificationCenter:(NSUserNotificationCenter*)center
+ didDismissAlert:(NSUserNotification*)notification {
+ NSDictionary* notificationResponse =
+ [NotificationResponseBuilder buildDictionary:notification];
+ NotificationPlatformBridgeMac::ProcessNotificationResponse(
+ notificationResponse);
+}
+
- (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center
shouldPresentNotification:(NSUserNotification*)nsNotification {
// Always display notifications, regardless of whether the app is foreground.
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/notifications/notification_response_builder_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698