| Index: chrome/browser/autofill/autofill_keystone_observer_mac.mm
|
| diff --git a/chrome/browser/autofill/autofill_keystone_observer_mac.mm b/chrome/browser/autofill/autofill_keystone_observer_mac.mm
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e6327260ab4d4597f9f280499b88ee9a654b917a
|
| --- /dev/null
|
| +++ b/chrome/browser/autofill/autofill_keystone_observer_mac.mm
|
| @@ -0,0 +1,77 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#import "chrome/browser/autofill/autofill_keystone_observer_mac.h"
|
| +
|
| +#import <Cocoa/Cocoa.h>
|
| +
|
| +#include "base/logging.h"
|
| +#import "chrome/browser/autofill/autofill_keystone_observer_mac_delegate.h"
|
| +#import "chrome/browser/mac/keystone_glue.h"
|
| +
|
| +// Listens to Keystone notifications and passes them on to the delegate.
|
| +@interface AutofillKeystoneBridge : NSObject {
|
| + @private
|
| + // The delegate is expected to outlive this bridge.
|
| + autofill::AutofillKeystoneObserverMacDelegate* delegate_;
|
| +}
|
| +
|
| +// Designated initializer. The delegate is expected to outlive this object.
|
| +- (instancetype)initWithDelegate:
|
| + (autofill::AutofillKeystoneObserverMacDelegate*)delegate;
|
| +
|
| +// Receieved a notification from Keystone.
|
| +- (void)handleStatusNotification:(NSNotification*)notification;
|
| +@end
|
| +
|
| +@implementation AutofillKeystoneBridge
|
| +
|
| +- (instancetype)init {
|
| + NOTREACHED();
|
| + return nil;
|
| +}
|
| +
|
| +- (instancetype)initWithDelegate:
|
| + (autofill::AutofillKeystoneObserverMacDelegate*)delegate {
|
| + DCHECK(delegate);
|
| + self = [super init];
|
| + if (self) {
|
| + delegate_ = delegate;
|
| + NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
| + [center addObserver:self
|
| + selector:@selector(handleStatusNotification:)
|
| + name:kAutoupdateStatusNotification
|
| + object:nil];
|
| + }
|
| + return self;
|
| +}
|
| +
|
| +- (void)dealloc {
|
| + [[NSNotificationCenter defaultCenter] removeObserver:self];
|
| + [super dealloc];
|
| +}
|
| +
|
| +- (void)handleStatusNotification:(NSNotification*)notification {
|
| + NSNumber* statusNumber =
|
| + [[notification userInfo] objectForKey:kAutoupdateStatusStatus];
|
| + DCHECK(statusNumber);
|
| + DCHECK([statusNumber isKindOfClass:[NSNumber class]]);
|
| + keystone_glue::AutoupdateStatus status =
|
| + static_cast<keystone_glue::AutoupdateStatus>([statusNumber intValue]);
|
| + delegate_->OnKeystoneNotification(status);
|
| +}
|
| +
|
| +@end
|
| +
|
| +namespace autofill {
|
| +
|
| +AutofillKeystoneObserverMac::AutofillKeystoneObserverMac(
|
| + AutofillKeystoneObserverMacDelegate* delegate) {
|
| + bridge_.reset([[AutofillKeystoneBridge alloc] initWithDelegate:delegate]);
|
| +}
|
| +
|
| +AutofillKeystoneObserverMac::~AutofillKeystoneObserverMac() {
|
| +}
|
| +
|
| +} // namespace autofill
|
|
|