summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-19 22:52:53 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-19 22:52:53 +0000
commitc6003334deb317c834f6a3dab5f834303c24217a (patch)
tree110f686ce07c2e76db92da5388de891abe461322
parenta922a784b2e5d42e3663cbc03714e4564bf882bf (diff)
downloadchromium_src-c6003334deb317c834f6a3dab5f834303c24217a.zip
chromium_src-c6003334deb317c834f6a3dab5f834303c24217a.tar.gz
chromium_src-c6003334deb317c834f6a3dab5f834303c24217a.tar.bz2
AutoFill Prefs dialog on Mac should list derived labels for profiles, not summaries.
Changes the AutoFill dialog on Mac to display list of derived labels and not summaries. BUG=49344 TEST=Manual test as in bug. AutoFillDialogControllerTest.* Review URL: http://codereview.chromium.org/3041007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52957 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_dialog_controller_mac.mm25
-rw-r--r--chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm21
-rw-r--r--chrome/browser/webdata/web_data_service.cc4
3 files changed, 47 insertions, 3 deletions
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac.mm b/chrome/browser/autofill/autofill_dialog_controller_mac.mm
index 9c0cd077..377e1cd 100644
--- a/chrome/browser/autofill/autofill_dialog_controller_mac.mm
+++ b/chrome/browser/autofill/autofill_dialog_controller_mac.mm
@@ -23,6 +23,24 @@
#include "grit/app_resources.h"
#include "grit/theme_resources.h"
+namespace {
+
+// Update profile labels passed as |input|. When profile data changes as a
+// result of adding new profiles, edititing existing profiles, or deleting a
+// profile, then the list of profiles need to have their derived labels
+// recomputed.
+void UpdateProfileLabels(std::vector<AutoFillProfile>* input) {
+ DCHECK(input);
+ std::vector<AutoFillProfile*> profiles;
+ profiles.resize(input->size());
+ for (size_t i = 0; i < input->size(); ++i) {
+ profiles[i] = &(*input)[i];
+ }
+ AutoFillProfile::AdjustInferredLabels(&profiles);
+}
+
+} // namespace
+
// Delegate protocol that needs to be in place for the AutoFillTableView's
// handling of delete and backspace keys.
@protocol DeleteKeyDelegate
@@ -302,6 +320,7 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() {
profiles_.push_back(newAddress);
// Refresh the view based on new data.
+ UpdateProfileLabels(&profiles_);
[tableView_ reloadData];
// Update the selection to the newly added item.
@@ -355,6 +374,7 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() {
[tableView_ selectRowIndexes:[NSIndexSet indexSet]
byExtendingSelection:NO];
}
+ UpdateProfileLabels(&profiles_);
[tableView_ reloadData];
} else if ([self isCreditCardRow:selectedRow]) {
creditCards_.erase(
@@ -434,6 +454,7 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() {
if (returnCode) {
AutoFillProfile* profile = static_cast<AutoFillProfile*>(contextInfo);
[addressSheetController copyModelToProfile:profile];
+ UpdateProfileLabels(&profiles_);
[tableView_ reloadData];
}
[sheet orderOut:self];
@@ -493,7 +514,7 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() {
if ([self isProfileRow:row]) {
if ([[tableColumn identifier] isEqualToString:@"Summary"]) {
return SysUTF16ToNSString(
- profiles_[[self profileIndexFromRow:row]].PreviewSummary());
+ profiles_[[self profileIndexFromRow:row]].Label());
}
return @"";
@@ -673,6 +694,8 @@ void PersonalDataManagerObserver::OnPersonalDataLoaded() {
iter != creditCards.end(); ++iter)
creditCards_.push_back(**iter);
}
+
+ UpdateProfileLabels(&profiles_);
}
- (BOOL)isProfileRow:(NSInteger)row {
diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
index 97c2467..d3e2550 100644
--- a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
+++ b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm
@@ -284,6 +284,9 @@ TEST_F(AutoFillDialogControllerTest, AutoFillDataMutation) {
ASSERT_TRUE(observer_.profiles_.size() == 1);
profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id());
+ // Do not compare labels. Label is a derived field.
+ observer_.profiles_[0].set_label(string16());
+ profiles()[0]->set_label(string16());
ASSERT_EQ(observer_.profiles_[0], *profiles()[0]);
}
@@ -340,6 +343,10 @@ TEST_F(AutoFillDialogControllerTest, TwoProfiles) {
// Contents should match. With the exception of the |unique_id|.
for (size_t i = 0, count = profiles().size(); i < count; i++) {
profiles()[i]->set_unique_id(observer_.profiles_[i].unique_id());
+
+ // Do not compare labels. Label is a derived field.
+ observer_.profiles_[i].set_label(string16());
+ profiles()[i]->set_label(string16());
ASSERT_EQ(observer_.profiles_[i], *profiles()[i]);
}
}
@@ -470,6 +477,10 @@ TEST_F(AutoFillDialogControllerTest, TwoProfilesDeleteOne) {
// First address should match.
profiles()[0]->set_unique_id(observer_.profiles_[0].unique_id());
+
+ // Do not compare labels. Label is a derived field.
+ observer_.profiles_[0].set_label(string16());
+ profile.set_label(string16());
ASSERT_EQ(observer_.profiles_[0], profile);
}
@@ -558,8 +569,12 @@ TEST_F(AutoFillDialogControllerTest, WaitForDataToLoad) {
// Contents should match.
size_t i = 0;
size_t count = profiles().size();
- for (i = 0; i < count; i++)
+ for (i = 0; i < count; i++) {
+ // Do not compare labels. Label is a derived field.
+ observer_.profiles_[i].set_label(string16());
+ profiles()[i]->set_label(string16());
ASSERT_EQ(observer_.profiles_[i], *profiles()[i]);
+ }
count = credit_cards().size();
for (i = 0; i < count; i++) {
ASSERT_EQ(observer_.credit_cards_[i], *credit_cards()[i]);
@@ -590,6 +605,10 @@ TEST_F(AutoFillDialogControllerTest, ImportedParameters) {
ASSERT_EQ(1UL, observer_.profiles_.size());
ASSERT_EQ(1UL, observer_.credit_cards_.size());
+ // Do not compare labels. Label is a derived field.
+ observer_.profiles_[0].set_label(string16());
+ profile.set_label(string16());
+
// Contents should match.
ASSERT_EQ(observer_.profiles_[0], profile);
ASSERT_EQ(observer_.credit_cards_[0], credit_card);
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index 45c463e..4b7f93e 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -870,8 +870,10 @@ void WebDataService::AddAutoFillProfileImpl(
InitializeDatabaseIfNecessary();
if (db_ && !request->IsCancelled()) {
const AutoFillProfile& profile = request->GetArgument();
- if (!db_->AddAutoFillProfile(profile))
+ if (!db_->AddAutoFillProfile(profile)) {
NOTREACHED();
+ return;
+ }
ScheduleCommit();
AutofillProfileChange change(AutofillProfileChange::ADD,