Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/notifications/notification_platform_bridge_mac.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_mac.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 // can forward commands to C++. | 85 // can forward commands to C++. |
| 86 @interface NotificationCenterDelegate | 86 @interface NotificationCenterDelegate |
| 87 : NSObject<NSUserNotificationCenterDelegate> { | 87 : NSObject<NSUserNotificationCenterDelegate> { |
| 88 } | 88 } |
| 89 @end | 89 @end |
| 90 | 90 |
| 91 // ///////////////////////////////////////////////////////////////////////////// | 91 // ///////////////////////////////////////////////////////////////////////////// |
| 92 | 92 |
| 93 NotificationPlatformBridgeMac::NotificationPlatformBridgeMac( | 93 NotificationPlatformBridgeMac::NotificationPlatformBridgeMac( |
| 94 NSUserNotificationCenter* notification_center) | 94 NSUserNotificationCenter* notification_center) |
| 95 : NotificationPlatformBridgeMac(notification_center, | |
| 96 true /* set_delegate */) {} | |
|
Nico
2016/07/12 17:54:38
please use /*set_delegate=*/true (the spelling you
Miguel Garcia
2016/07/13 14:05:16
Done.
| |
| 97 | |
| 98 NotificationPlatformBridgeMac::NotificationPlatformBridgeMac( | |
| 99 NSUserNotificationCenter* notification_center, | |
| 100 bool set_delegate) | |
| 95 : delegate_([NotificationCenterDelegate alloc]), | 101 : delegate_([NotificationCenterDelegate alloc]), |
| 96 notification_center_(notification_center) { | 102 notification_center_(notification_center) { |
| 97 [notification_center_ setDelegate:delegate_.get()]; | 103 // OCMock does not support dynamic properties yet. |
| 104 // TODO(miguelg): remove once cbug.com/622753 is resolved. | |
| 105 if (set_delegate) | |
| 106 [notification_center_ setDelegate:delegate_.get()]; | |
| 98 } | 107 } |
| 99 | 108 |
| 100 NotificationPlatformBridgeMac::~NotificationPlatformBridgeMac() { | 109 NotificationPlatformBridgeMac::~NotificationPlatformBridgeMac() { |
| 101 [notification_center_ setDelegate:nil]; | 110 [notification_center_ setDelegate:nil]; |
| 102 | 111 |
| 103 // TODO(miguelg) lift this restriction if possible. | 112 // TODO(miguelg) lift this restriction if possible. |
| 104 [notification_center_ removeAllDeliveredNotifications]; | 113 [notification_center_ removeAllDeliveredNotifications]; |
| 105 } | 114 } |
| 106 | 115 |
| 107 void NotificationPlatformBridgeMac::Display( | 116 void NotificationPlatformBridgeMac::Display( |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 notificationOrigin, persistentNotificationId, buttonIndex.intValue)); | 333 notificationOrigin, persistentNotificationId, buttonIndex.intValue)); |
| 325 } | 334 } |
| 326 | 335 |
| 327 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 336 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
| 328 shouldPresentNotification:(NSUserNotification*)nsNotification { | 337 shouldPresentNotification:(NSUserNotification*)nsNotification { |
| 329 // Always display notifications, regardless of whether the app is foreground. | 338 // Always display notifications, regardless of whether the app is foreground. |
| 330 return YES; | 339 return YES; |
| 331 } | 340 } |
| 332 | 341 |
| 333 @end | 342 @end |
| OLD | NEW |