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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 // A Cocoa class that represents the delegate of NSUserNotificationCenter and | 84 // A Cocoa class that represents the delegate of NSUserNotificationCenter and |
| 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, true /* set_delegate */); | |
|
Peter Beverloo
2016/07/11 17:25:48
You can define a delegating constructor like:
Not
Miguel Garcia
2016/07/12 16:16:24
You know I usually go with the flow with regards t
| |
| 96 } | |
| 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 // Setting up the delegte upsets OCMock. |
|
Peter Beverloo
2016/07/11 17:25:48
delegte -> delegate
Rather than saying that it "u
Miguel Garcia
2016/07/12 16:16:24
Now that we know why sure :)
| |
| 104 if (set_delegate) | |
| 105 notification_center.delegate = delegate_.get(); | |
|
Peter Beverloo
2016/07/11 17:25:48
Why did the syntax for the assignment change?
Miguel Garcia
2016/07/12 16:16:24
It was me trying some things to keep OCMock happy,
| |
| 98 } | 106 } |
| 99 | 107 |
| 100 NotificationPlatformBridgeMac::~NotificationPlatformBridgeMac() { | 108 NotificationPlatformBridgeMac::~NotificationPlatformBridgeMac() { |
| 101 [notification_center_ setDelegate:nil]; | 109 [notification_center_ setDelegate:nil]; |
| 102 | 110 |
| 103 // TODO(miguelg) lift this restriction if possible. | 111 // TODO(miguelg) lift this restriction if possible. |
| 104 [notification_center_ removeAllDeliveredNotifications]; | 112 [notification_center_ removeAllDeliveredNotifications]; |
| 105 } | 113 } |
| 106 | 114 |
| 107 void NotificationPlatformBridgeMac::Display( | 115 void NotificationPlatformBridgeMac::Display( |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 notificationOrigin, persistentNotificationId, buttonIndex.intValue)); | 332 notificationOrigin, persistentNotificationId, buttonIndex.intValue)); |
| 325 } | 333 } |
| 326 | 334 |
| 327 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 335 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
| 328 shouldPresentNotification:(NSUserNotification*)nsNotification { | 336 shouldPresentNotification:(NSUserNotification*)nsNotification { |
| 329 // Always display notifications, regardless of whether the app is foreground. | 337 // Always display notifications, regardless of whether the app is foreground. |
| 330 return YES; | 338 return YES; |
| 331 } | 339 } |
| 332 | 340 |
| 333 @end | 341 @end |
| OLD | NEW |