Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: chrome/browser/autofill/autofill_keystone_observer_mac.mm

Issue 334653006: mac: Prevent Address Book permissions dialog from erroneously appearing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..a67fdd8e61d659dcb9907db00cc0339299439a4f
--- /dev/null
+++ b/chrome/browser/autofill/autofill_keystone_observer_mac.mm
@@ -0,0 +1,75 @@
+// 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
+ AutofillKeystoneObserverMacDelegate* delegate_;
Ilya Sherman 2014/06/14 01:18:50 Please document lifetime expectations here as well
erikchen 2014/06/16 20:30:45 Done.
+}
+
+// Designated initializer. The delegate is expected to outlive this object.
+- (instancetype)initWithDelegate:(AutofillKeystoneObserverMacDelegate*)delegate;
+
+// Receieved a notification from Keystone.
+- (void)handleStatusNotification:(NSNotification*)notification;
+@end
+
+@implementation AutofillKeystoneBridge
+
+- (instancetype)init {
+ NOTREACHED();
+ return nil;
+}
+
+- (instancetype)initWithDelegate:
+ (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

Powered by Google App Engine
This is Rietveld 408576698