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

Side by Side Diff: chrome/browser/ui/autofill/chrome_autofill_client_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: Fix test. 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
« no previous file with comments | « chrome/browser/ui/autofill/chrome_autofill_client.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
6
7 #import <Cocoa/Cocoa.h>
8
9 #include "base/logging.h"
10 #include "base/mac/scoped_nsobject.h"
11 #import "chrome/browser/mac/keystone_glue.h"
12 #include "components/autofill/core/browser/personal_data_manager.h"
13
14 // Listens to Keystone notifications and passes relevant ones on to the
15 // PersonalDataManager.
16 @interface AutofillKeystoneBridge : NSObject {
17 @private
18 // The PersonalDataManager, if it exists, is expected to outlive this object.
19 autofill::PersonalDataManager* personal_data_manager_;
20 }
21
22 // Designated initializer. The PersonalDataManager, if it exists, is expected
23 // to outlive this object. The PersonalDataManager may be NULL in tests.
Ilya Sherman 2014/06/18 23:10:04 Please add a TODO, either in this CL or in a follo
erikchen 2014/06/18 23:13:51 File a bug against myself to fix this problem: htt
Ilya Sherman 2014/06/18 23:40:55 Thanks :)
24 - (instancetype)initWithPersonalDataManager:
25 (autofill::PersonalDataManager*)personal_data_manager;
26
27 // Receieved a notification from Keystone.
28 - (void)handleStatusNotification:(NSNotification*)notification;
29 @end
30
31 @implementation AutofillKeystoneBridge
32
33 - (instancetype)init {
34 NOTREACHED();
35 return nil;
36 }
37
38 - (instancetype)initWithPersonalDataManager:
39 (autofill::PersonalDataManager*)personal_data_manager {
40 self = [super init];
41 if (self) {
42 personal_data_manager_ = personal_data_manager;
43 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
44 [center addObserver:self
45 selector:@selector(handleStatusNotification:)
46 name:kAutoupdateStatusNotification
47 object:nil];
48 }
49 return self;
50 }
51
52 - (void)dealloc {
53 [[NSNotificationCenter defaultCenter] removeObserver:self];
54 [super dealloc];
55 }
56
57 - (void)handleStatusNotification:(NSNotification*)notification {
58 if (!personal_data_manager_)
59 return;
60
61 NSNumber* statusNumber =
62 [[notification userInfo] objectForKey:kAutoupdateStatusStatus];
63 DCHECK(statusNumber);
64 DCHECK([statusNumber isKindOfClass:[NSNumber class]]);
65 AutoupdateStatus status =
66 static_cast<AutoupdateStatus>([statusNumber intValue]);
67
68 switch (status) {
69 case kAutoupdateInstalling:
70 case kAutoupdateInstalled: {
71 personal_data_manager_->BinaryChanging();
72 return;
73 }
74 default:
75 return;
76 }
77 }
78
79 @end
80
81 namespace autofill {
82
83 class AutofillKeystoneBridgeWrapper {
84 public:
85 explicit AutofillKeystoneBridgeWrapper(
86 PersonalDataManager* personal_data_manager) {
87 bridge_.reset([[AutofillKeystoneBridge alloc]
88 initWithPersonalDataManager:personal_data_manager]);
89 }
90 ~AutofillKeystoneBridgeWrapper() {}
91
92 private:
93 base::scoped_nsobject<AutofillKeystoneBridge> bridge_;
94
95 DISALLOW_COPY_AND_ASSIGN(AutofillKeystoneBridgeWrapper);
96 };
97
98 void ChromeAutofillClient::RegisterForKeystoneNotifications() {
99 bridge_wrapper_ = new AutofillKeystoneBridgeWrapper(GetPersonalDataManager());
100 }
101
102 void ChromeAutofillClient::UnregisterFromKeystoneNotifications() {
103 delete bridge_wrapper_;
104 }
105
106 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/chrome_autofill_client.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698