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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/autofill/chrome_autofill_client_mac.mm
diff --git a/chrome/browser/ui/autofill/chrome_autofill_client_mac.mm b/chrome/browser/ui/autofill/chrome_autofill_client_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..c6596635417ae97826e585ad20179f94e0b3e4d4
--- /dev/null
+++ b/chrome/browser/ui/autofill/chrome_autofill_client_mac.mm
@@ -0,0 +1,103 @@
+// 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.
+
+#include "chrome/browser/ui/autofill/chrome_autofill_client.h"
+
+#import <Cocoa/Cocoa.h>
+
+#include "base/logging.h"
+#include "base/mac/scoped_nsobject.h"
+#import "chrome/browser/mac/keystone_glue.h"
+#include "components/autofill/core/browser/personal_data_manager.h"
+
+// Listens to Keystone notifications and passes them on to the delegate.
+@interface AutofillKeystoneBridge : NSObject {
+ @private
+ // The personal data manager is expected to outlive this bridge.
+ autofill::PersonalDataManager* personal_data_manager_;
+}
+
+// Designated initializer. The delegate is expected to outlive this object.
+- (instancetype)initWithPersonalDataManager:
+ (autofill::PersonalDataManager*)personal_data_manager;
+
+// Receieved a notification from Keystone.
+- (void)handleStatusNotification:(NSNotification*)notification;
+@end
+
+@implementation AutofillKeystoneBridge
+
+- (instancetype)init {
+ NOTREACHED();
+ return nil;
+}
+
+- (instancetype)initWithPersonalDataManager:
+ (autofill::PersonalDataManager*)personal_data_manager {
+ DCHECK(personal_data_manager);
+ self = [super init];
+ if (self) {
+ personal_data_manager_ = personal_data_manager;
+ 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]]);
+ AutoupdateStatus status =
+ static_cast<AutoupdateStatus>([statusNumber intValue]);
+
+ switch (status) {
+ case kAutoupdateInstalling:
+ case kAutoupdateInstalled: {
+ personal_data_manager_->BinaryChanging();
+ return;
+ }
+ default:
+ return;
+ }
+}
+
+@end
+
+namespace autofill {
+
+class AutofillKeystoneBridgeWrapper {
+ public:
+ explicit AutofillKeystoneBridgeWrapper(
+ PersonalDataManager* personal_data_manager) {
+ bridge_.reset(
+ [[AutofillKeystoneBridge alloc]
+ initWithPersonalDataManager:personal_data_manager]);
+ }
+ ~AutofillKeystoneBridgeWrapper() {}
+
+ private:
+ base::scoped_nsobject<AutofillKeystoneBridge> bridge_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutofillKeystoneBridgeWrapper);
+};
+
+void ChromeAutofillClient::RegisterForKeystoneNotifications() {
+ bridge_ = new AutofillKeystoneBridgeWrapper(GetPersonalDataManager());
+}
+
+void ChromeAutofillClient::UnregisterFromKeystoneNotifications() {
+ delete bridge_;
+}
+
+} // namespace autofill
« 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