summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-02 02:09:37 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-02 02:09:37 +0000
commite033ae9281855a0e83eb9b073fd956f6905f5e8f (patch)
treef60ae8e71ad69c08858265ba3984745b6bcc0e15 /chrome/browser/autofill
parent493d192f856567f441b2a8b436b9fb7ddfdbd4ad (diff)
downloadchromium_src-e033ae9281855a0e83eb9b073fd956f6905f5e8f.zip
chromium_src-e033ae9281855a0e83eb9b073fd956f6905f5e8f.tar.gz
chromium_src-e033ae9281855a0e83eb9b073fd956f6905f5e8f.tar.bz2
AutoFillDialogController leak fixed.
The AutoFillDialogController was leaking view controllers when dynamically adding and removing AutoFillAddressViewController and AutoFillCreditCardViewController views. Ownership of the controllers was not getting relinquished to the NSArray containers correctly. New checks in the unit tests now explicitly check that the controllers have a single owner. BUG=39720 TEST=AutoFillDialogControllerTest.DeleteAddress, AutoFillDialogControllerTest.DeleteCreditCard TBR=avi@chromium.org Review URL: http://codereview.chromium.org/1551011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43432 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_dialog_controller_mac.mm16
-rw-r--r--chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm4
2 files changed, 12 insertions, 8 deletions
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac.mm b/chrome/browser/autofill/autofill_dialog_controller_mac.mm
index 3f6980b..f9a8155 100644
--- a/chrome/browser/autofill/autofill_dialog_controller_mac.mm
+++ b/chrome/browser/autofill/autofill_dialog_controller_mac.mm
@@ -113,11 +113,11 @@
string16 new_address_name = l10n_util::GetStringUTF16(
IDS_AUTOFILL_NEW_ADDRESS);
AutoFillProfile newProfile(new_address_name, 0);
- AutoFillAddressViewController* addressViewController =
+ scoped_nsobject<AutoFillAddressViewController> addressViewController(
[[AutoFillAddressViewController alloc]
initWithProfile:newProfile
disclosure:NSOnState
- controller:self];
+ controller:self]);
[addressFormViewControllers_.get() addObject:addressViewController];
// Embed the new address into our target view.
@@ -148,11 +148,11 @@
string16 new_credit_card_name = l10n_util::GetStringUTF16(
IDS_AUTOFILL_NEW_CREDITCARD);
CreditCard newCreditCard(new_credit_card_name, 0);
- AutoFillCreditCardViewController* creditCardViewController =
+ scoped_nsobject<AutoFillCreditCardViewController> creditCardViewController(
[[AutoFillCreditCardViewController alloc]
initWithCreditCard:newCreditCard
disclosure:NSOnState
- controller:self];
+ controller:self]);
[creditCardFormViewControllers_.get() addObject:creditCardViewController];
// Embed the new address into our target view.
@@ -325,11 +325,11 @@
for (size_t i = 0; i < profiles_.size(); i++) {
// Special case for first address, we want to show full contents.
NSCellStateValue disclosureState = (i == 0) ? NSOnState : NSOffState;
- AutoFillAddressViewController* addressViewController =
+ scoped_nsobject<AutoFillAddressViewController> addressViewController(
[[AutoFillAddressViewController alloc]
initWithProfile:profiles_[i]
disclosure:disclosureState
- controller:self];
+ controller:self]);
[addressFormViewControllers_.get() addObject:addressViewController];
// Embed the child view into our (owned by us) target view.
@@ -341,11 +341,11 @@
insertionPoint = creditCardSection_;
for (size_t i = 0; i < creditCards_.size(); i++) {
- AutoFillCreditCardViewController* creditCardViewController =
+ scoped_nsobject<AutoFillCreditCardViewController> creditCardViewController(
[[AutoFillCreditCardViewController alloc]
initWithCreditCard:creditCards_[i]
disclosure:NSOffState
- controller:self];
+ controller:self]);
[creditCardFormViewControllers_.get() addObject:creditCardViewController];
// Embed the child view into our (owned by us) target view.
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
index 743728f..ca2ee93 100644
--- a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
+++ b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
@@ -315,6 +315,8 @@ TEST_F(AutoFillDialogControllerTest, DeleteProfile) {
profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Joe"));
profiles_.push_back(&profile);
LoadDialog();
+ EXPECT_EQ([[[controller_ addressFormViewControllers] lastObject]
+ retainCount], 1UL);
[controller_ deleteAddress:[[controller_ addressFormViewControllers]
lastObject]];
[controller_ save:nil];
@@ -332,6 +334,8 @@ TEST_F(AutoFillDialogControllerTest, DeleteCreditCard) {
credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Joe"));
credit_cards_.push_back(&credit_card);
LoadDialog();
+ EXPECT_EQ([[[controller_ creditCardFormViewControllers] lastObject]
+ retainCount], 1UL);
[controller_ deleteCreditCard:[[controller_ creditCardFormViewControllers]
lastObject]];
[controller_ save:nil];