diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-03 00:58:19 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-03 00:58:19 +0000 |
commit | 4baa9c88e98f72de4d2ebb2f4436834c8f9e2453 (patch) | |
tree | c1fc8c57dc05dbb2cb8825de007f222c39588d3f /chrome/browser/autofill | |
parent | efff195424b347f56b9d56f8a1466a8b8d1334fd (diff) | |
download | chromium_src-4baa9c88e98f72de4d2ebb2f4436834c8f9e2453.zip chromium_src-4baa9c88e98f72de4d2ebb2f4436834c8f9e2453.tar.gz chromium_src-4baa9c88e98f72de4d2ebb2f4436834c8f9e2453.tar.bz2 |
Remove the AutoFill enable/disable radio from the Options dialog to the AutoFill dialog
These changes remove the AutoFill enabled radio buttons from the Preferences dialog and adds a single checkbox to the AutoFill dialog to do same. Preferences.xib changes by removing the radio buttons and moving other controls up. AutoFillDialog.xib adds checkbox to control AutoFill enabled preference. Also, other controls in AutoFillDialg.xib now bind their enabled states to the value of the enabled checkbox.
BUG=47435
TEST=AutoFillDialogControllerTest.AutoFillEnabled*
Review URL: http://codereview.chromium.org/2799054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51581 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
3 files changed, 55 insertions, 0 deletions
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac.h b/chrome/browser/autofill/autofill_dialog_controller_mac.h index 34e40fa..3318443 100644 --- a/chrome/browser/autofill/autofill_dialog_controller_mac.h +++ b/chrome/browser/autofill/autofill_dialog_controller_mac.h @@ -58,6 +58,9 @@ class Profile; // Working list of input credit cards. std::vector<CreditCard> creditCards_; + // State of checkbox for enabling AutoFill in general. + BOOL autoFillEnabled_; + // State of checkbox for enabling Mac Address Book integration. BOOL auxiliaryEnabled_; @@ -81,6 +84,11 @@ class Profile; personalDataManagerObserver_; } +// Property representing state of the AutoFill enabled preference. Checkbox is +// bound to this in nib. Also, enabled state of other controls are also bound +// to this property. +@property (nonatomic) BOOL autoFillEnabled; + // Property representing state of Address Book "me" card usage. Checkbox is // bound to this in nib. @property (nonatomic) BOOL auxiliaryEnabled; diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac.mm b/chrome/browser/autofill/autofill_dialog_controller_mac.mm index 72c301b..941eab9 100644 --- a/chrome/browser/autofill/autofill_dialog_controller_mac.mm +++ b/chrome/browser/autofill/autofill_dialog_controller_mac.mm @@ -169,6 +169,7 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() { @implementation AutoFillDialogController +@synthesize autoFillEnabled = autoFillEnabled_; @synthesize auxiliaryEnabled = auxiliaryEnabled_; @synthesize itemIsSelected = itemIsSelected_; @@ -226,6 +227,7 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() { - (IBAction)save:(id)sender { // If we have an |observer_| then communicate the changes back. if (observer_) { + profile_->GetPrefs()->SetBoolean(prefs::kAutoFillEnabled, autoFillEnabled_); profile_->GetPrefs()->SetBoolean(prefs::kAutoFillAuxiliaryProfilesEnabled, auxiliaryEnabled_); observer_->OnAutoFillDialogApply(&profiles_, &creditCards_); @@ -594,6 +596,10 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() { importedCreditCard_ = importedCreditCard; // Use property here to trigger KVO binding. + [self setAutoFillEnabled:profile_->GetPrefs()->GetBoolean( + prefs::kAutoFillEnabled)]; + + // Use property here to trigger KVO binding. [self setAuxiliaryEnabled:profile_->GetPrefs()->GetBoolean( prefs::kAutoFillAuxiliaryProfilesEnabled)]; diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm index 1fc4373..e0bc14c 100644 --- a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm +++ b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm @@ -598,4 +598,45 @@ TEST_F(AutoFillDialogControllerTest, ImportedParameters) { ASSERT_EQ(observer_.credit_cards_[0], credit_card); } +// AutoFill is enabled by default. +TEST_F(AutoFillDialogControllerTest, AutoFillEnabledTrue) { + LoadDialog(); + [controller_ save:nil]; + + // Should hit our observer. + ASSERT_TRUE(observer_.hit_); + + // AutoFill enabled setting should be unchanged. + ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean( + prefs::kAutoFillEnabled)); +} + +TEST_F(AutoFillDialogControllerTest, AutoFillEnabledFalse) { + helper_.profile()->GetPrefs()->SetBoolean(prefs::kAutoFillEnabled, false); + LoadDialog(); + [controller_ save:nil]; + + // Should hit our observer. + ASSERT_TRUE(observer_.hit_); + + // AutoFill enabled setting should be unchanged. + ASSERT_FALSE(helper_.profile()->GetPrefs()->GetBoolean( + prefs::kAutoFillEnabled)); +} + +TEST_F(AutoFillDialogControllerTest, AutoFillEnabledChanged) { + helper_.profile()->GetPrefs()->SetBoolean( + prefs::kAutoFillAuxiliaryProfilesEnabled, false); + LoadDialog(); + [controller_ setAutoFillEnabled:YES]; + [controller_ save:nil]; + + // Should hit our observer. + ASSERT_TRUE(observer_.hit_); + + // Auxiliary profiles setting should be unchanged. + ASSERT_TRUE(helper_.profile()->GetPrefs()->GetBoolean( + prefs::kAutoFillEnabled)); +} + } // namespace |