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

Unified Diff: chrome/browser/notifications/notification_platform_bridge_mac.mm

Issue 2390153005: Implement support for closing mac native notifications (Closed)
Patch Set: review 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
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..61fc0f8ceaa384445e562c2075186104902c2b22 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 @@ void DoProcessNotificationResponse(NotificationCommon::Operation operation,
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 @@ bool NotificationPlatformBridgeMac::VerifyNotificationData(
notificationResponse);
}
+// Overriden from _NSUserNotificationCenterDelegatePrivate.
+// Emmitted when a user clicks the "Close" Button in the notification.
Peter Beverloo 2016/10/06 14:35:18 Emmitted -> Emitted Button -> button
Miguel Garcia 2016/10/07 13:42:24 Done.
+// It not is emmitted if the notification is closed from the notification
Peter Beverloo 2016/10/06 14:35:18 emmitted -> emitted
Miguel Garcia 2016/10/07 13:42:24 Done.
+// center or if the app is not running by the time the Close button is
Peter Beverloo 2016/10/06 14:35:18 by the time -> at the time
Miguel Garcia 2016/10/07 13:42:24 Done.
+// 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/BUILD.gn » ('j') | chrome/browser/ui/cocoa/notifications/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698