| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" | 5 #import "chrome/browser/autofill/autofill_dialog_controller_mac.h" |
| 6 #include "app/l10n_util.h" | 6 #include "app/l10n_util.h" |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 void PersonalDataManagerObserver::OnPersonalDataLoaded() { | 162 void PersonalDataManagerObserver::OnPersonalDataLoaded() { |
| 163 RemoveObserver(); | 163 RemoveObserver(); |
| 164 [controller_ onPersonalDataLoaded:personal_data_manager_->web_profiles() | 164 [controller_ onPersonalDataLoaded:personal_data_manager_->web_profiles() |
| 165 creditCards:personal_data_manager_->credit_cards()]; | 165 creditCards:personal_data_manager_->credit_cards()]; |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace AutoFillDialogControllerInternal | 168 } // namespace AutoFillDialogControllerInternal |
| 169 | 169 |
| 170 @implementation AutoFillDialogController | 170 @implementation AutoFillDialogController |
| 171 | 171 |
| 172 @synthesize autoFillEnabled = autoFillEnabled_; |
| 172 @synthesize auxiliaryEnabled = auxiliaryEnabled_; | 173 @synthesize auxiliaryEnabled = auxiliaryEnabled_; |
| 173 @synthesize itemIsSelected = itemIsSelected_; | 174 @synthesize itemIsSelected = itemIsSelected_; |
| 174 | 175 |
| 175 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer | 176 + (void)showAutoFillDialogWithObserver:(AutoFillDialogObserver*)observer |
| 176 profile:(Profile*)profile | 177 profile:(Profile*)profile |
| 177 importedProfile:(AutoFillProfile*) importedProfile | 178 importedProfile:(AutoFillProfile*) importedProfile |
| 178 importedCreditCard:(CreditCard*) importedCreditCard { | 179 importedCreditCard:(CreditCard*) importedCreditCard { |
| 179 AutoFillDialogController* controller = | 180 AutoFillDialogController* controller = |
| 180 [AutoFillDialogController controllerWithObserver:observer | 181 [AutoFillDialogController controllerWithObserver:observer |
| 181 profile:profile | 182 profile:profile |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 - (void)windowWillClose:(NSNotification *)notification { | 220 - (void)windowWillClose:(NSNotification *)notification { |
| 220 [tableView_ setDataSource:nil]; | 221 [tableView_ setDataSource:nil]; |
| 221 [tableView_ setDelegate:nil]; | 222 [tableView_ setDelegate:nil]; |
| 222 [self autorelease]; | 223 [self autorelease]; |
| 223 } | 224 } |
| 224 | 225 |
| 225 // Called when the user clicks the save button. | 226 // Called when the user clicks the save button. |
| 226 - (IBAction)save:(id)sender { | 227 - (IBAction)save:(id)sender { |
| 227 // If we have an |observer_| then communicate the changes back. | 228 // If we have an |observer_| then communicate the changes back. |
| 228 if (observer_) { | 229 if (observer_) { |
| 230 profile_->GetPrefs()->SetBoolean(prefs::kAutoFillEnabled, autoFillEnabled_); |
| 229 profile_->GetPrefs()->SetBoolean(prefs::kAutoFillAuxiliaryProfilesEnabled, | 231 profile_->GetPrefs()->SetBoolean(prefs::kAutoFillAuxiliaryProfilesEnabled, |
| 230 auxiliaryEnabled_); | 232 auxiliaryEnabled_); |
| 231 observer_->OnAutoFillDialogApply(&profiles_, &creditCards_); | 233 observer_->OnAutoFillDialogApply(&profiles_, &creditCards_); |
| 232 } | 234 } |
| 233 [self closeDialog]; | 235 [self closeDialog]; |
| 234 } | 236 } |
| 235 | 237 |
| 236 // Called when the user clicks the cancel button. All we need to do is stop | 238 // Called when the user clicks the cancel button. All we need to do is stop |
| 237 // the modal session. | 239 // the modal session. |
| 238 - (IBAction)cancel:(id)sender { | 240 - (IBAction)cancel:(id)sender { |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 pathForResource:@"AutoFillDialog" | 589 pathForResource:@"AutoFillDialog" |
| 588 ofType:@"nib"]; | 590 ofType:@"nib"]; |
| 589 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | 591 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
| 590 // Initialize member variables based on input. | 592 // Initialize member variables based on input. |
| 591 observer_ = observer; | 593 observer_ = observer; |
| 592 profile_ = profile; | 594 profile_ = profile; |
| 593 importedProfile_ = importedProfile; | 595 importedProfile_ = importedProfile; |
| 594 importedCreditCard_ = importedCreditCard; | 596 importedCreditCard_ = importedCreditCard; |
| 595 | 597 |
| 596 // Use property here to trigger KVO binding. | 598 // Use property here to trigger KVO binding. |
| 599 [self setAutoFillEnabled:profile_->GetPrefs()->GetBoolean( |
| 600 prefs::kAutoFillEnabled)]; |
| 601 |
| 602 // Use property here to trigger KVO binding. |
| 597 [self setAuxiliaryEnabled:profile_->GetPrefs()->GetBoolean( | 603 [self setAuxiliaryEnabled:profile_->GetPrefs()->GetBoolean( |
| 598 prefs::kAutoFillAuxiliaryProfilesEnabled)]; | 604 prefs::kAutoFillAuxiliaryProfilesEnabled)]; |
| 599 | 605 |
| 600 // Do not use [NSMutableArray array] here; we need predictable destruction | 606 // Do not use [NSMutableArray array] here; we need predictable destruction |
| 601 // which will be prevented by having a reference held by an autorelease | 607 // which will be prevented by having a reference held by an autorelease |
| 602 // pool. | 608 // pool. |
| 603 } | 609 } |
| 604 return self; | 610 return self; |
| 605 } | 611 } |
| 606 | 612 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 if (!image) { | 805 if (!image) { |
| 800 image = rb.GetNSImageNamed(IDR_INPUT_GOOD); | 806 image = rb.GetNSImageNamed(IDR_INPUT_GOOD); |
| 801 DCHECK(image); | 807 DCHECK(image); |
| 802 return image; | 808 return image; |
| 803 } | 809 } |
| 804 | 810 |
| 805 return nil; | 811 return nil; |
| 806 } | 812 } |
| 807 | 813 |
| 808 @end | 814 @end |
| OLD | NEW |