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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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 "chrome/browser/autofill/autofill_keystone_observer_mac.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "base/logging.h"
10 #import "chrome/browser/autofill/autofill_keystone_observer_mac_delegate.h"
11 #import "chrome/browser/mac/keystone_glue.h"
12
13 // Listens to Keystone notifications and passes them on to the delegate.
14 @interface AutofillKeystoneBridge : NSObject {
15 @private
16 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.
17 }
18
19 // Designated initializer. The delegate is expected to outlive this object.
20 - (instancetype)initWithDelegate:(AutofillKeystoneObserverMacDelegate*)delegate;
21
22 // Receieved a notification from Keystone.
23 - (void)handleStatusNotification:(NSNotification*)notification;
24 @end
25
26 @implementation AutofillKeystoneBridge
27
28 - (instancetype)init {
29 NOTREACHED();
30 return nil;
31 }
32
33 - (instancetype)initWithDelegate:
34 (AutofillKeystoneObserverMacDelegate*)delegate {
35 DCHECK(delegate);
36 self = [super init];
37 if (self) {
38 delegate_ = delegate;
39 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
40 [center addObserver:self
41 selector:@selector(handleStatusNotification:)
42 name:kAutoupdateStatusNotification
43 object:nil];
44 }
45 return self;
46 }
47
48 - (void)dealloc {
49 [[NSNotificationCenter defaultCenter] removeObserver:self];
50 [super dealloc];
51 }
52
53 - (void)handleStatusNotification:(NSNotification*)notification {
54 NSNumber* statusNumber =
55 [[notification userInfo] objectForKey:kAutoupdateStatusStatus];
56 DCHECK(statusNumber);
57 DCHECK([statusNumber isKindOfClass:[NSNumber class]]);
58 keystone_glue::AutoupdateStatus status =
59 static_cast<keystone_glue::AutoupdateStatus>([statusNumber intValue]);
60 delegate_->OnKeystoneNotification(status);
61 }
62
63 @end
64
65 namespace autofill {
66
67 AutofillKeystoneObserverMac::AutofillKeystoneObserverMac(
68 AutofillKeystoneObserverMacDelegate* delegate) {
69 bridge_.reset([[AutofillKeystoneBridge alloc] initWithDelegate:delegate]);
70 }
71
72 AutofillKeystoneObserverMac::~AutofillKeystoneObserverMac() {
73 }
74
75 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698