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

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: Add metrics. Note the addition of histograms.xml 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 // The delegate is expected to outlive this bridge.
17 autofill::AutofillKeystoneObserverMacDelegate* delegate_;
18 }
19
20 // Designated initializer. The delegate is expected to outlive this object.
21 - (instancetype)initWithDelegate:
22 (autofill::AutofillKeystoneObserverMacDelegate*)delegate;
23
24 // Receieved a notification from Keystone.
25 - (void)handleStatusNotification:(NSNotification*)notification;
26 @end
27
28 @implementation AutofillKeystoneBridge
29
30 - (instancetype)init {
31 NOTREACHED();
32 return nil;
33 }
34
35 - (instancetype)initWithDelegate:
36 (autofill::AutofillKeystoneObserverMacDelegate*)delegate {
37 DCHECK(delegate);
38 self = [super init];
39 if (self) {
40 delegate_ = delegate;
41 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
42 [center addObserver:self
43 selector:@selector(handleStatusNotification:)
44 name:kAutoupdateStatusNotification
45 object:nil];
46 }
47 return self;
48 }
49
50 - (void)dealloc {
51 [[NSNotificationCenter defaultCenter] removeObserver:self];
52 [super dealloc];
53 }
54
55 - (void)handleStatusNotification:(NSNotification*)notification {
56 NSNumber* statusNumber =
57 [[notification userInfo] objectForKey:kAutoupdateStatusStatus];
58 DCHECK(statusNumber);
59 DCHECK([statusNumber isKindOfClass:[NSNumber class]]);
60 keystone_glue::AutoupdateStatus status =
61 static_cast<keystone_glue::AutoupdateStatus>([statusNumber intValue]);
62 delegate_->OnKeystoneNotification(status);
63 }
64
65 @end
66
67 namespace autofill {
68
69 AutofillKeystoneObserverMac::AutofillKeystoneObserverMac(
70 AutofillKeystoneObserverMacDelegate* delegate) {
71 bridge_.reset([[AutofillKeystoneBridge alloc] initWithDelegate:delegate]);
72 }
73
74 AutofillKeystoneObserverMac::~AutofillKeystoneObserverMac() {
75 }
76
77 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698