| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import <AppKit/AppKit.h> |
| 6 #import <Foundation/Foundation.h> |
| 7 |
| 8 #import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h" |
| 9 |
| 10 @class NSUserNotificationCenter; |
| 11 |
| 12 @implementation XPCTransactionHandler { |
| 13 bool transactionOpen_; |
| 14 } |
| 15 |
| 16 - (instancetype)init { |
| 17 if ((self = [super init])) { |
| 18 transactionOpen_ = false; |
| 19 } |
| 20 return self; |
| 21 } |
| 22 |
| 23 - (void)openTransactionIfNeeded { |
| 24 @synchronized(self) { |
| 25 if (transactionOpen_) { |
| 26 return; |
| 27 } |
| 28 xpc_transaction_begin(); |
| 29 transactionOpen_ = true; |
| 30 } |
| 31 } |
| 32 |
| 33 - (void)closeTransactionIfNeeded { |
| 34 @synchronized(self) { |
| 35 NSUserNotificationCenter* notificationCenter = |
| 36 [NSUserNotificationCenter defaultUserNotificationCenter]; |
| 37 NSUInteger showing = [[notificationCenter deliveredNotifications] count]; |
| 38 if (showing == 0) { |
| 39 xpc_transaction_end(); |
| 40 transactionOpen_ = false; |
| 41 } |
| 42 } |
| 43 } |
| 44 @end |
| OLD | NEW |