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

Unified Diff: chrome/browser/autofill/autofill_dialog_controller_mac.mm

Issue 2884051: Merge 53276 - AutoFill Empty profiles should not be saved from AutoFillDialog... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 5 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 | « no previous file | chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_dialog_controller_mac.mm
===================================================================
--- chrome/browser/autofill/autofill_dialog_controller_mac.mm (revision 54215)
+++ chrome/browser/autofill/autofill_dialog_controller_mac.mm (working copy)
@@ -318,16 +318,18 @@
// Create a new address and save it to the |profiles_| list.
AutoFillProfile newAddress(string16(), 0);
[addressSheetController copyModelToProfile:&newAddress];
- profiles_.push_back(newAddress);
+ if (!newAddress.IsEmpty()) {
+ profiles_.push_back(newAddress);
- // Refresh the view based on new data.
- UpdateProfileLabels(&profiles_);
- [tableView_ reloadData];
+ // Refresh the view based on new data.
+ UpdateProfileLabels(&profiles_);
+ [tableView_ reloadData];
- // Update the selection to the newly added item.
- NSInteger row = [self rowFromProfileIndex:profiles_.size() - 1];
- [tableView_ selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
- byExtendingSelection:NO];
+ // Update the selection to the newly added item.
+ NSInteger row = [self rowFromProfileIndex:profiles_.size() - 1];
+ [tableView_ selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
+ byExtendingSelection:NO];
+ }
}
[sheet orderOut:self];
addressSheetController.reset(nil);
@@ -343,15 +345,17 @@
// Create a new credit card and save it to the |creditCards_| list.
CreditCard newCreditCard(string16(), 0);
[creditCardSheetController copyModelToCreditCard:&newCreditCard];
- creditCards_.push_back(newCreditCard);
+ if (!newCreditCard.IsEmpty()) {
+ creditCards_.push_back(newCreditCard);
- // Refresh the view based on new data.
- [tableView_ reloadData];
+ // Refresh the view based on new data.
+ [tableView_ reloadData];
- // Update the selection to the newly added item.
- NSInteger row = [self rowFromCreditCardIndex:creditCards_.size() - 1];
- [tableView_ selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
- byExtendingSelection:NO];
+ // Update the selection to the newly added item.
+ NSInteger row = [self rowFromCreditCardIndex:creditCards_.size() - 1];
+ [tableView_ selectRowIndexes:[NSIndexSet indexSetWithIndex:row]
+ byExtendingSelection:NO];
+ }
}
[sheet orderOut:self];
creditCardSheetController.reset(nil);
@@ -454,6 +458,14 @@
if (returnCode) {
AutoFillProfile* profile = static_cast<AutoFillProfile*>(contextInfo);
[addressSheetController copyModelToProfile:profile];
+
+ if (profile->IsEmpty())
+ [tableView_ deselectAll:self];
+ profiles_.erase(
+ std::remove_if(profiles_.begin(), profiles_.end(),
+ std::mem_fun_ref(&AutoFillProfile::IsEmpty)),
+ profiles_.end());
+
UpdateProfileLabels(&profiles_);
[tableView_ reloadData];
}
@@ -470,6 +482,14 @@
if (returnCode) {
CreditCard* creditCard = static_cast<CreditCard*>(contextInfo);
[creditCardSheetController copyModelToCreditCard:creditCard];
+
+ if (creditCard->IsEmpty())
+ [tableView_ deselectAll:self];
+ creditCards_.erase(
+ std::remove_if(
+ creditCards_.begin(), creditCards_.end(),
+ std::mem_fun_ref(&CreditCard::IsEmpty)),
+ creditCards_.end());
[tableView_ reloadData];
}
[sheet orderOut:self];
« no previous file with comments | « no previous file | chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698