Chromium Code Reviews| 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. | |
|
Robert Sesek
2016/10/26 18:49:41
nit: blank line after
Miguel Garcia
2016/10/28 14:53:57
Done.
| |
| 4 #import <AppKit/AppKit.h> | |
| 5 #import <Foundation/Foundation.h> | |
| 6 | |
| 7 #import "chrome/browser/ui/cocoa/notifications/xpc_transaction_handler.h" | |
| 8 | |
| 9 @class NSUserNotificationCenter; | |
| 10 | |
| 11 @implementation XPCTransactionHandler { | |
| 12 bool transactionOpen_; | |
| 13 } | |
|
Robert Sesek
2016/10/26 18:49:41
nit: blank line after
Miguel Garcia
2016/10/28 14:53:56
Done.
| |
| 14 - (instancetype)init { | |
| 15 if ((self = [super init])) { | |
| 16 transactionOpen_ = NO; | |
|
Robert Sesek
2016/10/26 18:49:41
NO -> false
Miguel Garcia
2016/10/28 14:53:57
Done.
| |
| 17 } | |
| 18 return self; | |
| 19 } | |
| 20 | |
| 21 - (void)openTransactionIfNeeded { | |
| 22 @synchronized(self) { | |
| 23 if (transactionOpen_) { | |
| 24 return; | |
| 25 } | |
| 26 xpc_transaction_begin(); | |
| 27 transactionOpen_ = YES; | |
|
Robert Sesek
2016/10/26 18:49:41
YES -> true
Miguel Garcia
2016/10/28 14:53:57
Done.
| |
| 28 } | |
| 29 } | |
| 30 | |
| 31 - (void)closeTransactionIfNeeded { | |
| 32 @synchronized(self) { | |
| 33 NSUserNotificationCenter* notificationCenter = | |
| 34 [NSUserNotificationCenter defaultUserNotificationCenter]; | |
| 35 NSInteger showing = [[notificationCenter deliveredNotifications] count]; | |
|
Robert Sesek
2016/10/26 18:49:41
-[NSArray count] returns NSUInteger
Miguel Garcia
2016/10/28 14:53:57
Done.
| |
| 36 if (showing == 0) { | |
| 37 xpc_transaction_end(); | |
| 38 transactionOpen_ = NO; | |
|
Robert Sesek
2016/10/26 18:49:41
NO -> false
Miguel Garcia
2016/10/28 14:53:56
Done.
| |
| 39 } | |
| 40 } | |
| 41 } | |
| 42 @end | |
| OLD | NEW |