| Index: chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
|
| diff --git a/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm b/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
|
| index d81f2b6ef1ad8514bcabd04e5fd7dbc3d27a5e66..528e198b6fad9f6c0d3a80010173a5109f479bd5 100644
|
| --- a/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
|
| +++ b/chrome/browser/ui/cocoa/notifications/alert_notification_service.mm
|
| @@ -8,11 +8,17 @@
|
| #import "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h"
|
| #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h"
|
| #import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h"
|
| +#include "third_party/crashpad/crashpad/client/crashpad_client.h"
|
|
|
| @class NSUserNotificationCenter;
|
|
|
| @implementation AlertNotificationService {
|
| XPCTransactionHandler* transactionHandler_;
|
| +
|
| + // Ensures that the XPC service has been configured for crash reporting.
|
| + // Other messages should not be sent to a new instance of the service
|
| + // before -setMachExceptionPort: is called.
|
| + BOOL didSetExceptionPort_;
|
| }
|
|
|
| - (instancetype)initWithTransactionHandler:(XPCTransactionHandler*)handler {
|
| @@ -22,7 +28,21 @@
|
| return self;
|
| }
|
|
|
| +- (void)setMachExceptionPort:(CrXPCMachPort*)port {
|
| + base::mac::ScopedMachSendRight sendRight([port takeRight]);
|
| + if (!sendRight.is_valid()) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| +
|
| + crashpad::CrashpadClient client;
|
| + didSetExceptionPort_ = client.SetHandlerMachPort(std::move(sendRight));
|
| + DCHECK(didSetExceptionPort_);
|
| +}
|
| +
|
| - (void)deliverNotification:(NSDictionary*)notificationData {
|
| + DCHECK(didSetExceptionPort_);
|
| +
|
| base::scoped_nsobject<NotificationBuilder> builder(
|
| [[NotificationBuilder alloc] initWithDictionary:notificationData]);
|
|
|
| @@ -34,6 +54,8 @@
|
|
|
| - (void)closeNotificationWithId:(NSString*)notificationId
|
| withProfileId:(NSString*)profileId {
|
| + DCHECK(didSetExceptionPort_);
|
| +
|
| NSUserNotificationCenter* notificationCenter =
|
| [NSUserNotificationCenter defaultUserNotificationCenter];
|
| for (NSUserNotification* candidate in
|
| @@ -54,6 +76,8 @@
|
| }
|
|
|
| - (void)closeAllNotifications {
|
| + DCHECK(didSetExceptionPort_);
|
| +
|
| [[NSUserNotificationCenter defaultUserNotificationCenter]
|
| removeAllDeliveredNotifications];
|
| [transactionHandler_ closeTransactionIfNeeded];
|
|
|