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

Side by Side Diff: chrome/browser/ui/autofill/chrome_autofill_client_mac.mm

Issue 339053003: patched from issue 334653006, modified (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 them on to the delegate.
15 @interface AutofillKeystoneBridge : NSObject {
16 @private
17 // The personal data manager is expected to outlive this bridge.
18 autofill::PersonalDataManager* personal_data_manager_;
19 }
20
21 // Designated initializer. The delegate is expected to outlive this object.
22 - (instancetype)initWithPersonalDataManager:
23 (autofill::PersonalDataManager*)personal_data_manager;
24
25 // Receieved a notification from Keystone.
26 - (void)handleStatusNotification:(NSNotification*)notification;
27 @end
28
29 @implementation AutofillKeystoneBridge
30
31 - (instancetype)init {
32 NOTREACHED();
33 return nil;
34 }
35
36 - (instancetype)initWithPersonalDataManager:
37 (autofill::PersonalDataManager*)personal_data_manager {
38 DCHECK(personal_data_manager);
39 self = [super init];
40 if (self) {
41 personal_data_manager_ = personal_data_manager;
42 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
43 [center addObserver:self
44 selector:@selector(handleStatusNotification:)
45 name:kAutoupdateStatusNotification
46 object:nil];
47 }
48 return self;
49 }
50
51 - (void)dealloc {
52 [[NSNotificationCenter defaultCenter] removeObserver:self];
53 [super dealloc];
54 }
55
56 - (void)handleStatusNotification:(NSNotification*)notification {
57 NSNumber* statusNumber =
58 [[notification userInfo] objectForKey:kAutoupdateStatusStatus];
59 DCHECK(statusNumber);
60 DCHECK([statusNumber isKindOfClass:[NSNumber class]]);
61 AutoupdateStatus status =
62 static_cast<AutoupdateStatus>([statusNumber intValue]);
63
64 switch (status) {
65 case kAutoupdateInstalling:
66 case kAutoupdateInstalled: {
67 personal_data_manager_->BinaryChanging();
68 return;
69 }
70 default:
71 return;
72 }
73 }
74
75 @end
76
77 namespace autofill {
78
79 class AutofillKeystoneBridgeWrapper {
80 public:
81 explicit AutofillKeystoneBridgeWrapper(
82 PersonalDataManager* personal_data_manager) {
83 bridge_.reset(
84 [[AutofillKeystoneBridge alloc]
85 initWithPersonalDataManager:personal_data_manager]);
86 }
87 ~AutofillKeystoneBridgeWrapper() {}
88
89 private:
90 base::scoped_nsobject<AutofillKeystoneBridge> bridge_;
91
92 DISALLOW_COPY_AND_ASSIGN(AutofillKeystoneBridgeWrapper);
93 };
94
95 void ChromeAutofillClient::RegisterForKeystoneNotifications() {
96 bridge_ = new AutofillKeystoneBridgeWrapper(GetPersonalDataManager());
97 }
98
99 void ChromeAutofillClient::UnregisterFromKeystoneNotifications() {
100 delete bridge_;
101 }
102
103 } // 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