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

Unified 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 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..94a25c5176d436aa026c2b85a0e10ec91c8ec360
--- /dev/null
+++ b/chrome/browser/ui/autofill/chrome_autofill_client_mac.mm
@@ -0,0 +1,106 @@
+// 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 relevant ones on to the
+// PersonalDataManager.
+@interface AutofillKeystoneBridge : NSObject {
+ @private
+ // The PersonalDataManager, if it exists, is expected to outlive this object.
+ autofill::PersonalDataManager* personal_data_manager_;
+}
+
+// Designated initializer. The PersonalDataManager, if it exists, is expected
+// 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 :)
+- (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 {
+ 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 {
+ if (!personal_data_manager_)
+ return;
+
+ 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_wrapper_ = new AutofillKeystoneBridgeWrapper(GetPersonalDataManager());
+}
+
+void ChromeAutofillClient::UnregisterFromKeystoneNotifications() {
+ delete bridge_wrapper_;
+}
+
+} // 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