diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 23:17:34 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 23:17:34 +0000 |
commit | 027dd44a72b43d91eb6185a9be73cc9ae616b485 (patch) | |
tree | dbc63b73f7d2c2dbdba12afff0e82590654a88e6 /chrome/browser | |
parent | 0e34852ad6c4d5bc35f7000392467837211c9a87 (diff) | |
download | chromium_src-027dd44a72b43d91eb6185a9be73cc9ae616b485.zip chromium_src-027dd44a72b43d91eb6185a9be73cc9ae616b485.tar.gz chromium_src-027dd44a72b43d91eb6185a9be73cc9ae616b485.tar.bz2 |
Autofill cleanup of labels
This removes remaining vestiges of profile and credit card labels as a means for identification. Labels do remain in the profile and credit card classes but are private, not persisted to the database, and created upon demand. This also cleans up the web_data_service and web_database methods that used labels as identifiers.
BUG=72929
TEST=WebDataServiceAutofillTest.*:WebDatabaseTest.* and miscellaneous others.
Review URL: http://codereview.chromium.org/6480073
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
27 files changed, 330 insertions, 711 deletions
diff --git a/chrome/browser/autofill/autofill_address_model_mac_unittest.mm b/chrome/browser/autofill/autofill_address_model_mac_unittest.mm index 5d7ab4e..b54219f 100644 --- a/chrome/browser/autofill/autofill_address_model_mac_unittest.mm +++ b/chrome/browser/autofill/autofill_address_model_mac_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,7 +28,6 @@ TEST(AutoFillAddressModelTest, InitializationFromProfile) { AutoFillProfile profile; autofill_test::SetProfileInfo( &profile, - "Billing", "Marion", "Mitchell", "Morrison", @@ -62,7 +61,6 @@ TEST(AutoFillAddressModelTest, CopyModelToProfile) { AutoFillProfile profile; autofill_test::SetProfileInfo( &profile, - "Billing", "Marion", "Mitchell", "Morrison", diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc index 9d36e16..7ff46fc 100644 --- a/chrome/browser/autofill/autofill_browsertest.cc +++ b/chrome/browser/autofill/autofill_browsertest.cc @@ -79,7 +79,7 @@ class AutoFillTest : public InProcessBrowserTest { AutoFillProfile profile; autofill_test::SetProfileInfo( - &profile, "Office Space", "Milton", "C.", "Waddams", + &profile, "Milton", "C.", "Waddams", "red.swingline@initech.com", "Initech", "4120 Freidrich Lane", "Basement", "Austin", "Texas", "78744", "United States", "5125551234", "5125550000"); diff --git a/chrome/browser/autofill/autofill_common_test.cc b/chrome/browser/autofill/autofill_common_test.cc index c926b8e..2e3af51 100644 --- a/chrome/browser/autofill/autofill_common_test.cc +++ b/chrome/browser/autofill/autofill_common_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,14 +32,11 @@ inline void check_and_set( } void SetProfileInfo(AutoFillProfile* profile, - const char* label, const char* first_name, const char* middle_name, + const char* first_name, const char* middle_name, const char* last_name, const char* email, const char* company, const char* address1, const char* address2, const char* city, const char* state, const char* zipcode, const char* country, const char* phone, const char* fax) { - // TODO(jhawkins): Remove |label|. - if (label) - profile->set_label(ASCIIToUTF16(label)); check_and_set(profile, NAME_FIRST, first_name); check_and_set(profile, NAME_MIDDLE, middle_name); check_and_set(profile, NAME_LAST, last_name); @@ -63,15 +60,14 @@ void SetProfileInfoWithGuid(AutoFillProfile* profile, const char* phone, const char* fax) { if (guid) profile->set_guid(guid); - SetProfileInfo(profile, NULL, first_name, middle_name, last_name, email, + SetProfileInfo(profile, first_name, middle_name, last_name, email, company, address1, address2, city, state, zipcode, country, phone, fax); } void SetCreditCardInfo(CreditCard* credit_card, - const char* label, const char* name_on_card, const char* card_number, + const char* name_on_card, const char* card_number, const char* expiration_month, const char* expiration_year) { - credit_card->set_label(ASCIIToUTF16(label)); check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card); check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); diff --git a/chrome/browser/autofill/autofill_common_test.h b/chrome/browser/autofill/autofill_common_test.h index fa5ca2c..0a1dcfc 100644 --- a/chrome/browser/autofill/autofill_common_test.h +++ b/chrome/browser/autofill/autofill_common_test.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -28,7 +28,7 @@ void CreateTestFormField(const char* label, // tests. |SetProfileInfo| provides a quick way to populate a profile with // c-strings. void SetProfileInfo(AutoFillProfile* profile, - const char* label, const char* first_name, const char* middle_name, + const char* first_name, const char* middle_name, const char* last_name, const char* email, const char* company, const char* address1, const char* address2, const char* city, const char* state, const char* zipcode, const char* country, @@ -45,7 +45,7 @@ void SetProfileInfoWithGuid(AutoFillProfile* profile, // tests. |SetCreditCardInfo| provides a quick way to populate a credit card // with c-strings. void SetCreditCardInfo(CreditCard* credit_card, - const char* label, const char* name_on_card, const char* card_number, + const char* name_on_card, const char* card_number, const char* expiration_month, const char* expiration_year); // TODO(isherman): We should do this automatically for all tests, not manually diff --git a/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm b/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm index 5be95d1..90f9ef4 100644 --- a/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm +++ b/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,7 +26,7 @@ TEST(AutoFillCreditCardModelTest, Basic) { TEST(AutoFillCreditCardModelTest, InitializationFromCreditCard) { CreditCard credit_card; - autofill_test::SetCreditCardInfo(&credit_card, "Corporate", + autofill_test::SetCreditCardInfo(&credit_card, "John Dillinger", "123456789012", "01", "2010"); scoped_nsobject<AutoFillCreditCardModel> model( [[AutoFillCreditCardModel alloc] initWithCreditCard:credit_card]); @@ -40,7 +40,7 @@ TEST(AutoFillCreditCardModelTest, InitializationFromCreditCard) { TEST(AutoFillCreditCardModelTest, CopyModelToCreditCard) { CreditCard credit_card; - autofill_test::SetCreditCardInfo(&credit_card, "Corporate", + autofill_test::SetCreditCardInfo(&credit_card, "John Dillinger", "123456789012", "01", "2010"); scoped_nsobject<AutoFillCreditCardModel> model( [[AutoFillCreditCardModel alloc] initWithCreditCard:credit_card]); diff --git a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm index 1731340..6e885e3 100644 --- a/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm +++ b/chrome/browser/autofill/autofill_dialog_controller_mac_unittest.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -612,8 +612,6 @@ TEST_F(AutoFillDialogControllerTest, WaitForDataToLoad) { size_t count = profiles().size(); for (i = 0; i < count; i++) { // Do not compare labels. Label is a derived field. - [controller_ profiles][i].set_label(string16()); - profiles()[i]->set_label(string16()); ASSERT_EQ([controller_ profiles][i], *profiles()[i]); } count = credit_cards().size(); diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index ad668e4..e6c2548 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -61,19 +61,10 @@ class TestPersonalDataManager : public PersonalDataManager { virtual void SaveImportedFormData() {} virtual bool IsDataLoaded() const { return true; } - AutoFillProfile* GetLabeledProfile(const char* label) { + AutoFillProfile* GetProfileWithGUID(const char* guid) { for (std::vector<AutoFillProfile *>::iterator it = web_profiles_.begin(); it != web_profiles_.end(); ++it) { - if (!(*it)->Label().compare(ASCIIToUTF16(label))) - return *it; - } - return NULL; - } - - CreditCard* GetLabeledCreditCard(const char* label) { - for (std::vector<CreditCard *>::iterator it = credit_cards_.begin(); - it != credit_cards_.end(); ++it) { - if (!(*it)->Label().compare(ASCIIToUTF16(label))) + if (!(*it)->guid().compare(guid)) return *it; } return NULL; @@ -94,7 +85,7 @@ class TestPersonalDataManager : public PersonalDataManager { void CreateTestCreditCardsYearAndMonth(const char* year, const char* month) { ClearCreditCards(); CreditCard* credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Miku", "Miku Hatsune", + autofill_test::SetCreditCardInfo(credit_card, "Miku Hatsune", "4234567890654321", // Visa month, year); credit_card->set_guid("00000000-0000-0000-0000-000000000007"); @@ -104,7 +95,7 @@ class TestPersonalDataManager : public PersonalDataManager { private: void CreateTestAutoFillProfiles(ScopedVector<AutoFillProfile>* profiles) { AutoFillProfile* profile = new AutoFillProfile; - autofill_test::SetProfileInfo(profile, "Home", "Elvis", "Aaron", + autofill_test::SetProfileInfo(profile, "Elvis", "Aaron", "Presley", "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", "Tennessee", "38116", "USA", @@ -112,7 +103,7 @@ class TestPersonalDataManager : public PersonalDataManager { profile->set_guid("00000000-0000-0000-0000-000000000001"); profiles->push_back(profile); profile = new AutoFillProfile; - autofill_test::SetProfileInfo(profile, "Work", "Charles", "Hardin", + autofill_test::SetProfileInfo(profile, "Charles", "Hardin", "Holley", "buddy@gmail.com", "Decca", "123 Apple St.", "unit 6", "Lubbock", "Texas", "79401", "USA", "23456789012", @@ -120,7 +111,7 @@ class TestPersonalDataManager : public PersonalDataManager { profile->set_guid("00000000-0000-0000-0000-000000000002"); profiles->push_back(profile); profile = new AutoFillProfile; - autofill_test::SetProfileInfo(profile, "Empty", "", "", "", "", "", "", "", + autofill_test::SetProfileInfo(profile, "", "", "", "", "", "", "", "", "", "", "", "", ""); profile->set_guid("00000000-0000-0000-0000-000000000003"); profiles->push_back(profile); @@ -128,19 +119,21 @@ class TestPersonalDataManager : public PersonalDataManager { void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { CreditCard* credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "First", "Elvis Presley", + autofill_test::SetCreditCardInfo(credit_card, "Elvis Presley", "4234567890123456", // Visa "04", "2012"); credit_card->set_guid("00000000-0000-0000-0000-000000000004"); credit_cards->push_back(credit_card); + credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Second", "Buddy Holly", + autofill_test::SetCreditCardInfo(credit_card, "Buddy Holly", "5187654321098765", // Mastercard "10", "2014"); credit_card->set_guid("00000000-0000-0000-0000-000000000005"); credit_cards->push_back(credit_card); + credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", ""); + autofill_test::SetCreditCardInfo(credit_card, "", "", "", ""); credit_card->set_guid("00000000-0000-0000-0000-000000000006"); credit_cards->push_back(credit_card); } @@ -425,12 +418,8 @@ class TestAutoFillManager : public AutoFillManager { autofill_enabled_ = autofill_enabled; } - AutoFillProfile* GetLabeledProfile(const char* label) { - return test_personal_data_->GetLabeledProfile(label); - } - - CreditCard* GetLabeledCreditCard(const char* label) { - return test_personal_data_->GetLabeledCreditCard(label); + AutoFillProfile* GetProfileWithGUID(const char* guid) { + return test_personal_data_->GetProfileWithGUID(guid); } void AddProfile(AutoFillProfile* profile) { @@ -686,7 +675,8 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsWithDuplicates) { // Add a duplicate profile. AutoFillProfile* duplicate_profile = static_cast<AutoFillProfile*>( - autofill_manager_->GetLabeledProfile("Home")->Clone()); + autofill_manager_->GetProfileWithGUID( + "00000000-0000-0000-0000-000000000001")->Clone()); autofill_manager_->AddProfile(duplicate_profile); const FormField& field = form.fields[0]; @@ -1272,7 +1262,7 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) { // |profile| will be owned by the mock PersonalDataManager. AutoFillProfile* profile = new AutoFillProfile; - autofill_test::SetProfileInfo(profile, "Duplicate", "Elvis", "", "", "", "", + autofill_test::SetProfileInfo(profile, "Elvis", "", "", "", "", "", "", "", "", "", "", "", ""); profile->set_guid("00000000-0000-0000-0000-000000000101"); autofill_manager_->AddProfile(profile); @@ -1314,7 +1304,7 @@ TEST_F(AutoFillManagerTest, FillAddressForm) { std::vector<FormData> forms(1, form); FormsSeen(forms); - std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000001"; FillAutoFillFormData( kDefaultPageID, form, form.fields[0], autofill_manager_->PackGUIDs(std::string(), guid)); @@ -1333,7 +1323,7 @@ TEST_F(AutoFillManagerTest, FillCreditCardForm) { std::vector<FormData> forms(1, form); FormsSeen(forms); - std::string guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000004"; FillAutoFillFormData( kDefaultPageID, form, *form.fields.begin(), autofill_manager_->PackGUIDs(guid, std::string())); @@ -1356,7 +1346,7 @@ TEST_F(AutoFillManagerTest, FillCreditCardFormNoYearNoMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - std::string guid = autofill_manager_->GetLabeledCreditCard("Miku")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000007"; FillAutoFillFormData( kDefaultPageID, form, *form.fields.begin(), autofill_manager_->PackGUIDs(guid, std::string())); @@ -1381,7 +1371,7 @@ TEST_F(AutoFillManagerTest, FillCreditCardFormNoYearMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - std::string guid = autofill_manager_->GetLabeledCreditCard("Miku")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000007"; FillAutoFillFormData( kDefaultPageID, form, *form.fields.begin(), autofill_manager_->PackGUIDs(guid, std::string())); @@ -1405,7 +1395,7 @@ TEST_F(AutoFillManagerTest, FillCreditCardFormYearNoMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - std::string guid = autofill_manager_->GetLabeledCreditCard("Miku")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000007"; FillAutoFillFormData( kDefaultPageID, form, *form.fields.begin(), autofill_manager_->PackGUIDs(guid, std::string())); @@ -1430,7 +1420,7 @@ TEST_F(AutoFillManagerTest, FillCreditCardFormYearMonth) { std::vector<FormData> forms(1, form); FormsSeen(forms); - std::string guid = autofill_manager_->GetLabeledCreditCard("Miku")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000007"; FillAutoFillFormData( kDefaultPageID, form, *form.fields.begin(), autofill_manager_->PackGUIDs(guid, std::string())); @@ -1452,7 +1442,7 @@ TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) { FormsSeen(forms); // First fill the address data. - std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000001"; FillAutoFillFormData(kDefaultPageID, form, form.fields[0], autofill_manager_->PackGUIDs(std::string(), guid)); @@ -1466,7 +1456,7 @@ TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) { // Now fill the credit card data. const int kPageID2 = 2; - guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); + guid = "00000000-0000-0000-0000-000000000004"; FillAutoFillFormData( kPageID2, form, form.fields.back(), autofill_manager_->PackGUIDs(guid, std::string())); @@ -1495,7 +1485,7 @@ TEST_F(AutoFillManagerTest, FillFormWithMultipleSections) { FormsSeen(forms); // Fill the first section. - std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000001"; FillAutoFillFormData(kDefaultPageID, form, form.fields[0], autofill_manager_->PackGUIDs(std::string(), guid)); @@ -1519,7 +1509,7 @@ TEST_F(AutoFillManagerTest, FillFormWithMultipleSections) { // Fill the second section, with the initiating field somewhere in the middle // of the section. const int kPageID2 = 2; - guid = autofill_manager_->GetLabeledProfile("Home")->guid(); + guid = "00000000-0000-0000-0000-000000000001"; ASSERT_LT(9U, kAddressFormSize); FillAutoFillFormData(kPageID2, form, form.fields[kAddressFormSize + 9], autofill_manager_->PackGUIDs(std::string(), guid)); @@ -1562,7 +1552,7 @@ TEST_F(AutoFillManagerTest, FillAutoFilledForm) { FormsSeen(forms); // First fill the address data. - std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000001"; FillAutoFillFormData( kDefaultPageID, form, *form.fields.begin(), autofill_manager_->PackGUIDs(std::string(), guid)); @@ -1579,7 +1569,7 @@ TEST_F(AutoFillManagerTest, FillAutoFilledForm) { // Now fill the credit card data. const int kPageID2 = 2; - guid = autofill_manager_->GetLabeledCreditCard("First")->guid(); + guid = "00000000-0000-0000-0000-000000000004"; FillAutoFillFormData( kPageID2, form, form.fields.back(), autofill_manager_->PackGUIDs(guid, std::string())); @@ -1649,7 +1639,8 @@ TEST_F(AutoFillManagerTest, FillPhoneNumber) { std::vector<FormData> forms(1, form); FormsSeen(forms); - AutoFillProfile *work_profile = autofill_manager_->GetLabeledProfile("Work"); + AutoFillProfile *work_profile = autofill_manager_->GetProfileWithGUID( + "00000000-0000-0000-0000-000000000002"); ASSERT_TRUE(work_profile != NULL); const AutoFillType phone_type(PHONE_HOME_NUMBER); string16 saved_phone = work_profile->GetFieldText(phone_type); @@ -1698,7 +1689,7 @@ TEST_F(AutoFillManagerTest, FormChangesRemoveField) { // Now, after the call to |FormsSeen|, we remove the field before filling. form.fields.erase(form.fields.begin() + 3); - std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000001"; FillAutoFillFormData( kDefaultPageID, form, form.fields[0], autofill_manager_->PackGUIDs(std::string(), guid)); @@ -1729,7 +1720,7 @@ TEST_F(AutoFillManagerTest, FormChangesAddField) { // Now, after the call to |FormsSeen|, we restore the field before filling. form.fields.insert(pos, field); - std::string guid = autofill_manager_->GetLabeledProfile("Home")->guid(); + std::string guid = "00000000-0000-0000-0000-000000000001"; FillAutoFillFormData( kDefaultPageID, form, form.fields[0], autofill_manager_->PackGUIDs(std::string(), guid)); diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc index 0362f3b..b955792 100644 --- a/chrome/browser/autofill/autofill_metrics_unittest.cc +++ b/chrome/browser/autofill/autofill_metrics_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -40,7 +40,7 @@ class TestPersonalDataManager : public PersonalDataManager { private: void CreateTestAutoFillProfiles(ScopedVector<AutoFillProfile>* profiles) { AutoFillProfile* profile = new AutoFillProfile; - autofill_test::SetProfileInfo(profile, "Home", "Elvis", "Aaron", + autofill_test::SetProfileInfo(profile, "Elvis", "Aaron", "Presley", "theking@gmail.com", "RCA", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", "Tennessee", "38116", "USA", @@ -48,7 +48,7 @@ class TestPersonalDataManager : public PersonalDataManager { profile->set_guid("00000000-0000-0000-0000-000000000001"); profiles->push_back(profile); profile = new AutoFillProfile; - autofill_test::SetProfileInfo(profile, "Work", "Charles", "Hardin", + autofill_test::SetProfileInfo(profile, "Charles", "Hardin", "Holley", "buddy@gmail.com", "Decca", "123 Apple St.", "unit 6", "Lubbock", "Texas", "79401", "USA", "23456789012", @@ -56,7 +56,7 @@ class TestPersonalDataManager : public PersonalDataManager { profile->set_guid("00000000-0000-0000-0000-000000000002"); profiles->push_back(profile); profile = new AutoFillProfile; - autofill_test::SetProfileInfo(profile, "Empty", "", "", "", "", "", "", "", + autofill_test::SetProfileInfo(profile, "", "", "", "", "", "", "", "", "", "", "", "", ""); profile->set_guid("00000000-0000-0000-0000-000000000003"); profiles->push_back(profile); @@ -64,19 +64,19 @@ class TestPersonalDataManager : public PersonalDataManager { void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { CreditCard* credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "First", "Elvis Presley", + autofill_test::SetCreditCardInfo(credit_card, "Elvis Presley", "4234567890123456", // Visa "04", "2012"); credit_card->set_guid("00000000-0000-0000-0000-000000000004"); credit_cards->push_back(credit_card); credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Second", "Buddy Holly", + autofill_test::SetCreditCardInfo(credit_card, "Buddy Holly", "5187654321098765", // Mastercard "10", "2014"); credit_card->set_guid("00000000-0000-0000-0000-000000000005"); credit_cards->push_back(credit_card); credit_card = new CreditCard; - autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", ""); + autofill_test::SetCreditCardInfo(credit_card, "", "", "", ""); credit_card->set_guid("00000000-0000-0000-0000-000000000006"); credit_cards->push_back(credit_card); } diff --git a/chrome/browser/autofill/autofill_profile.h b/chrome/browser/autofill/autofill_profile.h index 964568a..f86ea9b 100644 --- a/chrome/browser/autofill/autofill_profile.h +++ b/chrome/browser/autofill/autofill_profile.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -102,7 +102,6 @@ class AutoFillProfile : public FormGroup { // http://crbug.com/58813 bool operator==(const AutoFillProfile& profile) const; virtual bool operator!=(const AutoFillProfile& profile) const; - void set_label(const string16& label) { label_ = label; } // Returns concatenation of full name and address line 1. This acts as the // basis of comparison for new values that are submitted through forms to @@ -129,6 +128,8 @@ class AutoFillProfile : public FormGroup { size_t num_fields_to_include, std::vector<string16>* created_labels); + void set_label(const string16& label) { label_ = label; } + // The label presented to the user when selecting a profile. string16 label_; diff --git a/chrome/browser/autofill/autofill_profile_unittest.cc b/chrome/browser/autofill/autofill_profile_unittest.cc index 93e9602..d207bc4 100644 --- a/chrome/browser/autofill/autofill_profile_unittest.cc +++ b/chrome/browser/autofill/autofill_profile_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -35,7 +35,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 0a/empty name and address, so the first two fields of the rest of the // data is used: "Hollywood, CA" AutoFillProfile profile00; - autofill_test::SetProfileInfo(&profile00, "Billing", "", "Mitchell", "", + autofill_test::SetProfileInfo(&profile00, "", "Mitchell", "", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile00)); @@ -44,7 +44,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 1: "<address>" AutoFillProfile profile1; - autofill_test::SetProfileInfo(&profile1, "Billing", "", "Mitchell", "", + autofill_test::SetProfileInfo(&profile1, "", "Mitchell", "", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile1)); @@ -53,7 +53,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 2: "<lastname>" AutoFillProfile profile2; - autofill_test::SetProfileInfo(&profile2, "Billing", "", "Mitchell", + autofill_test::SetProfileInfo(&profile2, "", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile2)); @@ -63,7 +63,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 3: "<lastname>, <address>" AutoFillProfile profile3; - autofill_test::SetProfileInfo(&profile3, "Billing", "", "Mitchell", + autofill_test::SetProfileInfo(&profile3, "", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile3)); @@ -72,7 +72,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 4: "<firstname>" AutoFillProfile profile4; - autofill_test::SetProfileInfo(&profile4, "Billing", "Marion", "Mitchell", "", + autofill_test::SetProfileInfo(&profile4, "Marion", "Mitchell", "", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile4)); @@ -81,7 +81,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 5: "<firstname>, <address>" AutoFillProfile profile5; - autofill_test::SetProfileInfo(&profile5, "Billing", "Marion", "Mitchell", "", + autofill_test::SetProfileInfo(&profile5, "Marion", "Mitchell", "", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile5)); @@ -90,7 +90,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 6: "<firstname> <lastname>" AutoFillProfile profile6; - autofill_test::SetProfileInfo(&profile6, "Billing", "Marion", "Mitchell", + autofill_test::SetProfileInfo(&profile6, "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile6)); @@ -100,7 +100,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 7: "<firstname> <lastname>, <address>" AutoFillProfile profile7; - autofill_test::SetProfileInfo(&profile7, "Billing", "Marion", "Mitchell", + autofill_test::SetProfileInfo(&profile7, "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); EXPECT_TRUE(UpdateProfileLabel(&profile7)); @@ -111,7 +111,7 @@ TEST(AutoFillProfileTest, PreviewSummaryString) { // Case 7a: "<firstname> <lastname>, <address>" - same as #7, except for // e-mail. AutoFillProfile profile7a; - autofill_test::SetProfileInfo(&profile7a, "Billing", "Marion", "Mitchell", + autofill_test::SetProfileInfo(&profile7a, "Marion", "Mitchell", "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); std::vector<AutoFillProfile*> profiles; @@ -131,7 +131,6 @@ TEST(AutoFillProfileTest, AdjustInferredLabels) { profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo( profiles[0], - "", "John", "", "Doe", @@ -147,7 +146,6 @@ TEST(AutoFillProfileTest, AdjustInferredLabels) { profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo( profiles[1], - "", "Jane", "", "Doe", @@ -172,7 +170,6 @@ TEST(AutoFillProfileTest, AdjustInferredLabels) { profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo( profiles[2], - "", "John", "", "Doe", @@ -201,7 +198,6 @@ TEST(AutoFillProfileTest, AdjustInferredLabels) { profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo( profiles[2], - "", "John", "", "Doe", @@ -228,7 +224,6 @@ TEST(AutoFillProfileTest, AdjustInferredLabels) { profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo( profiles[3], - "", "John", "", "Doe", @@ -260,7 +255,6 @@ TEST(AutoFillProfileTest, AdjustInferredLabels) { profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo( profiles[4], - "", "John", "", "Doe", @@ -302,7 +296,6 @@ TEST(AutoFillProfileTest, CreateInferredLabels) { std::vector<AutoFillProfile*> profiles; profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[0], - "", "John", "", "Doe", @@ -317,7 +310,6 @@ TEST(AutoFillProfileTest, CreateInferredLabels) { "22222222222"); profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[1], - "", "Jane", "", "Doe", @@ -406,11 +398,11 @@ TEST(AutoFillProfileTest, CreateInferredLabelsFallsBackToFullName) { ScopedVector<AutoFillProfile> profiles; profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[0], - "", "John", "", "Doe", "doe@example.com", "", + "John", "", "Doe", "doe@example.com", "", "88 Nowhere Ave.", "", "", "", "", "", "", ""); profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[1], - "", "Johnny", "K", "Doe", "doe@example.com", "", + "Johnny", "K", "Doe", "doe@example.com", "", "88 Nowhere Ave.", "", "", "", "", "", "", ""); // If the only name field in the suggested fields is the excluded field, we @@ -440,11 +432,11 @@ TEST(AutoFillProfileTest, CreateInferredLabelsNoDuplicatedFields) { ScopedVector<AutoFillProfile> profiles; profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[0], - "", "John", "", "Doe", "doe@example.com", "", + "John", "", "Doe", "doe@example.com", "", "88 Nowhere Ave.", "", "", "", "", "", "", ""); profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[1], - "", "John", "", "Doe", "dojo@example.com", "", + "John", "", "Doe", "dojo@example.com", "", "88 Nowhere Ave.", "", "", "", "", "", "", ""); // If the only name field in the suggested fields is the excluded field, we @@ -466,15 +458,15 @@ TEST(AutoFillProfileTest, CreateInferredLabelsSkipsEmptyFields) { ScopedVector<AutoFillProfile> profiles; profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[0], - "", "John", "", "Doe", "doe@example.com", + "John", "", "Doe", "doe@example.com", "Gogole", "", "", "", "", "", "", "", ""); profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[1], - "", "John", "", "Doe", "doe@example.com", + "John", "", "Doe", "doe@example.com", "Ggoole", "", "", "", "", "", "", "", ""); profiles.push_back(new AutoFillProfile); autofill_test::SetProfileInfo(profiles[2], - "", "John", "", "Doe", "john.doe@example.com", + "John", "", "Doe", "john.doe@example.com", "Goolge", "", "", "", "", "", "", "", ""); std::vector<string16> labels; @@ -504,10 +496,10 @@ TEST(AutoFillProfileTest, IsSubsetOf) { // |a| is a subset of |b|. a.reset(new AutoFillProfile); b.reset(new AutoFillProfile); - autofill_test::SetProfileInfo(a.get(), "label1", "Thomas", NULL, "Jefferson", + autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - autofill_test::SetProfileInfo(b.get(), "label2", "Thomas", NULL, "Jefferson", + autofill_test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", "United States Government", "Monticello", NULL, "Charlottesville", "Virginia", "22902", NULL, NULL, NULL); EXPECT_TRUE(a->IsSubsetOf(*b)); @@ -521,10 +513,10 @@ TEST(AutoFillProfileTest, IsSubsetOf) { // One field in |b| is different. a.reset(new AutoFillProfile); b.reset(new AutoFillProfile); - autofill_test::SetProfileInfo(a.get(), "label1", "Thomas", NULL, "Jefferson", + autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - autofill_test::SetProfileInfo(a.get(), "label2", "Thomas", NULL, "Adams", + autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Adams", "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); EXPECT_FALSE(a->IsSubsetOf(*b)); @@ -538,10 +530,10 @@ TEST(AutoFillProfileTest, IntersectionOfTypesHasEqualValues) { // profiles. a.reset(new AutoFillProfile); b.reset(new AutoFillProfile); - autofill_test::SetProfileInfo(a.get(), "label1", "Thomas", NULL, "Jefferson", + autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, "12134759123", "19384284720"); - autofill_test::SetProfileInfo(b.get(), "label2", "Thomas", NULL, "Jefferson", + autofill_test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson", "declaration_guy@gmail.com", "United States Government", "Monticello", NULL, "Charlottesville", "Virginia", "22902", NULL, NULL, NULL); EXPECT_TRUE(a->IntersectionOfTypesHasEqualValues(*b)); @@ -550,10 +542,10 @@ TEST(AutoFillProfileTest, IntersectionOfTypesHasEqualValues) { // EMAIL_ADDRESS. The value of EMAIL_ADDRESS differs between the two profiles. a.reset(new AutoFillProfile); b.reset(new AutoFillProfile); - autofill_test::SetProfileInfo(a.get(), "label1", "Thomas", NULL, "Jefferson", + autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", "poser@yahoo.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, "12134759123", "19384284720"); - autofill_test::SetProfileInfo(b.get(), "label2", "Thomas", NULL, "Jefferson",\ + autofill_test::SetProfileInfo(b.get(), "Thomas", NULL, "Jefferson",\ "declaration_guy@gmail.com", "United States Government", "Monticello", NULL, "Charlottesville", "Virginia", "22902", NULL, NULL, NULL); EXPECT_FALSE(a->IntersectionOfTypesHasEqualValues(*b)); @@ -561,10 +553,10 @@ TEST(AutoFillProfileTest, IntersectionOfTypesHasEqualValues) { // Intersection of types is empty. a.reset(new AutoFillProfile); b.reset(new AutoFillProfile); - autofill_test::SetProfileInfo(a.get(), "label1", "Thomas", NULL, "Jefferson", + autofill_test::SetProfileInfo(a.get(), "Thomas", NULL, "Jefferson", "poser@yahoo.com", NULL, NULL, NULL, NULL, NULL, NULL, NULL, "12134759123", "19384284720"); - autofill_test::SetProfileInfo(b.get(), "label2", NULL, NULL, NULL, NULL, + autofill_test::SetProfileInfo(b.get(), NULL, NULL, NULL, NULL, "United States Government", "Monticello", NULL, "Charlottesville", "Virginia", "22902", NULL, NULL, NULL); EXPECT_FALSE(a->IntersectionOfTypesHasEqualValues(*b)); @@ -576,16 +568,16 @@ TEST(AutoFillProfileTest, MergeWith) { // Merge |b| into |a|. a.reset(new AutoFillProfile); b.reset(new AutoFillProfile); - autofill_test::SetProfileInfo(a.get(), "label1", "Jimmy", NULL, NULL, NULL, + autofill_test::SetProfileInfo(a.get(), "Jimmy", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "12134759123", "19384284720"); - autofill_test::SetProfileInfo(b.get(), "label2", "James", NULL, "Madison", + autofill_test::SetProfileInfo(b.get(), "James", NULL, "Madison", "constitutionalist@gmail.com", "United States Government", "Monticello", NULL, "Charlottesville", "Virginia", "22902", NULL, NULL, NULL); AutoFillProfile expected_b(*b); a->MergeWith(*b); AutoFillProfile expected_a; - autofill_test::SetProfileInfo(&expected_a, "label1", "Jimmy", NULL, "Madison", + autofill_test::SetProfileInfo(&expected_a, "Jimmy", NULL, "Madison", "constitutionalist@gmail.com", "United States Government", "Monticello", NULL, "Charlottesville", "Virginia", "22902", NULL, "12134759123", "19384284720"); @@ -597,7 +589,7 @@ TEST(AutoFillProfileTest, AssignmentOperator){ AutoFillProfile a, b; // Result of assignment should be logically equal to the original profile. - autofill_test::SetProfileInfo(&a, "Billing", "Marion", "Mitchell", "Morrison", + autofill_test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); @@ -613,7 +605,7 @@ TEST(AutoFillProfileTest, Clone) { AutoFillProfile a; // Clone should be logically equal to the original. - autofill_test::SetProfileInfo(&a, "Billing", "Marion", "Mitchell", "Morrison", + autofill_test::SetProfileInfo(&a, "Marion", "Mitchell", "Morrison", "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); @@ -633,9 +625,9 @@ TEST(AutoFillProfileTest, Compare) { EXPECT_EQ(0, a.Compare(b)); // Different values produce non-zero results. - autofill_test::SetProfileInfo(&a, "label1", "Jimmy", NULL, NULL, NULL, + autofill_test::SetProfileInfo(&a, "Jimmy", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - autofill_test::SetProfileInfo(&b, "label1", "Ringo", NULL, NULL, NULL, + autofill_test::SetProfileInfo(&b, "Ringo", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); EXPECT_GT(0, a.Compare(b)); EXPECT_LT(0, b.Compare(a)); diff --git a/chrome/browser/autofill/credit_card.h b/chrome/browser/autofill/credit_card.h index 951b605..e7368e4 100644 --- a/chrome/browser/autofill/credit_card.h +++ b/chrome/browser/autofill/credit_card.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -64,7 +64,6 @@ class CreditCard : public FormGroup { // Used by tests. bool operator==(const CreditCard& credit_card) const; bool operator!=(const CreditCard& credit_card) const; - void set_label(const string16& label) { label_ = label; } // Returns true if |value| is a credit card number. Uses the Luhn formula to // validate the number. diff --git a/chrome/browser/autofill/credit_card_unittest.cc b/chrome/browser/autofill/credit_card_unittest.cc index 89e73d7..2cd9b85 100644 --- a/chrome/browser/autofill/credit_card_unittest.cc +++ b/chrome/browser/autofill/credit_card_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -23,7 +23,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 00: Empty credit card with empty strings. CreditCard credit_card00; - autofill_test::SetCreditCardInfo(&credit_card00, "Corporate", + autofill_test::SetCreditCardInfo(&credit_card00, "John Dillinger", "", "", ""); string16 summary00 = credit_card00.PreviewSummary(); EXPECT_EQ(string16(), summary00); @@ -32,7 +32,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 1: No credit card number. CreditCard credit_card1; - autofill_test::SetCreditCardInfo(&credit_card1, "Corporate", + autofill_test::SetCreditCardInfo(&credit_card1, "John Dillinger", "", "01", "2010"); string16 summary1 = credit_card1.PreviewSummary(); EXPECT_EQ(string16(), summary1); @@ -41,7 +41,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 2: No month. CreditCard credit_card2; - autofill_test::SetCreditCardInfo(&credit_card2, "Corporate", + autofill_test::SetCreditCardInfo(&credit_card2, "John Dillinger", "123456789012", "", "2010"); string16 summary2 = credit_card2.PreviewSummary(); EXPECT_EQ(string16(ASCIIToUTF16("************9012")), summary2); @@ -50,7 +50,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 3: No year. CreditCard credit_card3; - autofill_test::SetCreditCardInfo(&credit_card3, "Corporate", + autofill_test::SetCreditCardInfo(&credit_card3, "John Dillinger", "123456789012", "01", ""); string16 summary3 = credit_card3.PreviewSummary(); EXPECT_EQ(string16(ASCIIToUTF16("************9012")), summary3); @@ -59,7 +59,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) { // Case 4: Have everything. CreditCard credit_card4; - autofill_test::SetCreditCardInfo(&credit_card4, "Corporate", + autofill_test::SetCreditCardInfo(&credit_card4, "John Dillinger", "123456789012", "01", "2010"); string16 summary4 = credit_card4.PreviewSummary(); EXPECT_EQ(string16(ASCIIToUTF16("************9012, Exp: 01/2010")), summary4); @@ -71,7 +71,7 @@ TEST(CreditCardTest, AssignmentOperator){ CreditCard a, b; // Result of assignment should be logically equal to the original profile. - autofill_test::SetCreditCardInfo(&a, "Corporate", "John Dillinger", + autofill_test::SetCreditCardInfo(&a, "John Dillinger", "123456789012", "01", "2010"); b = a; EXPECT_TRUE(a == b); diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc index edef1d9..78c656a 100644 --- a/chrome/browser/autofill/personal_data_manager.cc +++ b/chrome/browser/autofill/personal_data_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -325,14 +325,14 @@ void PersonalDataManager::SetProfiles(std::vector<AutoFillProfile>* profiles) { web_profiles_.begin(); iter != web_profiles_.end(); ++iter) { if (!FindByGUID<AutoFillProfile>(*profiles, (*iter)->guid())) - wds->RemoveAutoFillProfileGUID((*iter)->guid()); + wds->RemoveAutoFillProfile((*iter)->guid()); } // Update the web database with the existing profiles. for (std::vector<AutoFillProfile>::iterator iter = profiles->begin(); iter != profiles->end(); ++iter) { if (FindByGUID<AutoFillProfile>(web_profiles_, iter->guid())) - wds->UpdateAutoFillProfileGUID(*iter); + wds->UpdateAutoFillProfile(*iter); } // Add the new profiles to the web database. Don't add a duplicate. @@ -340,7 +340,7 @@ void PersonalDataManager::SetProfiles(std::vector<AutoFillProfile>* profiles) { iter != profiles->end(); ++iter) { if (!FindByGUID<AutoFillProfile>(web_profiles_, iter->guid()) && !FindByContents(web_profiles_, *iter)) - wds->AddAutoFillProfileGUID(*iter); + wds->AddAutoFillProfile(*iter); } // Copy in the new profiles. @@ -368,8 +368,6 @@ void PersonalDataManager::SetCreditCards( std::mem_fun_ref(&CreditCard::IsEmpty)), credit_cards->end()); - SetUniqueCreditCardLabels(credit_cards); - WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); if (!wds) return; @@ -379,14 +377,14 @@ void PersonalDataManager::SetCreditCards( for (std::vector<CreditCard*>::const_iterator iter = credit_cards_.begin(); iter != credit_cards_.end(); ++iter) { if (!FindByGUID<CreditCard>(*credit_cards, (*iter)->guid())) - wds->RemoveCreditCardGUID((*iter)->guid()); + wds->RemoveCreditCard((*iter)->guid()); } // Update the web database with the existing credit cards. for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); iter != credit_cards->end(); ++iter) { if (FindByGUID<CreditCard>(credit_cards_, iter->guid())) - wds->UpdateCreditCardGUID(*iter); + wds->UpdateCreditCard(*iter); } // Add the new credit cards to the web database. Don't add a duplicate. @@ -394,7 +392,7 @@ void PersonalDataManager::SetCreditCards( iter != credit_cards->end(); ++iter) { if (!FindByGUID<CreditCard>(credit_cards_, iter->guid()) && !FindByContents(credit_cards_, *iter)) - wds->AddCreditCardGUID(*iter); + wds->AddCreditCard(*iter); } // Copy in the new credit cards. @@ -444,7 +442,7 @@ void PersonalDataManager::UpdateProfile(const AutoFillProfile& profile) { // Ensure that profile labels are up to date. AutoFillProfile::AdjustInferredLabels(&web_profiles_.get()); - wds->UpdateAutoFillProfileGUID(profile); + wds->UpdateAutoFillProfile(profile); FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged()); } @@ -500,7 +498,7 @@ void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) { } } - wds->UpdateCreditCardGUID(credit_card); + wds->UpdateCreditCard(credit_card); FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged()); } @@ -602,15 +600,6 @@ const std::vector<CreditCard*>& PersonalDataManager::credit_cards() { return credit_cards_.get(); } -AutoFillProfile* PersonalDataManager::CreateNewEmptyAutoFillProfileForDBThread( - const string16& label) { - // See comment in header for thread details. - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); - AutoFillProfile* p = new AutoFillProfile; - p->set_label(label); - return p; -} - void PersonalDataManager::Refresh() { LoadProfiles(); LoadCreditCards(); @@ -709,28 +698,6 @@ void PersonalDataManager::CancelPendingQuery(WebDataService::Handle* handle) { *handle = 0; } -void PersonalDataManager::SetUniqueCreditCardLabels( - std::vector<CreditCard>* credit_cards) { - std::map<string16, std::vector<CreditCard*> > label_map; - for (std::vector<CreditCard>::iterator iter = credit_cards->begin(); - iter != credit_cards->end(); ++iter) { - label_map[iter->Label()].push_back(&(*iter)); - } - - for (std::map<string16, std::vector<CreditCard*> >::iterator iter = - label_map.begin(); - iter != label_map.end(); ++iter) { - // Start at the second element because the first label should not be - // renamed. The appended label number starts at 2, because the first label - // has an implicit index of 1. - for (size_t i = 1; i < iter->second.size(); ++i) { - string16 newlabel = iter->second[i]->Label() + - base::UintToString16(static_cast<unsigned int>(i + 1)); - iter->second[i]->set_label(newlabel); - } - } -} - void PersonalDataManager::SaveImportedProfile( const AutoFillProfile& imported_profile) { if (profile_->IsOffTheRecord()) diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h index f8bdc99..a876bf9 100644 --- a/chrome/browser/autofill/personal_data_manager.h +++ b/chrome/browser/autofill/personal_data_manager.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -136,13 +136,6 @@ class PersonalDataManager virtual const std::vector<AutoFillProfile*>& web_profiles(); virtual const std::vector<CreditCard*>& credit_cards(); - // Creates a profile labeled |label|. - // This must be called on the DB thread with the expectation that the - // returned form will be synchronously persisted to the WebDatabase. See - // Refresh and SetProfiles for details. - AutoFillProfile* CreateNewEmptyAutoFillProfileForDBThread( - const string16& label); - // Re-loads profiles and credit cards from the WebDatabase asynchronously. // In the general case, this is a no-op and will re-create the same // in-memory model as existed prior to the call. If any change occurred to @@ -194,12 +187,6 @@ class PersonalDataManager // query handle. void CancelPendingQuery(WebDataService::Handle* handle); - // Ensures that all profile labels are unique by appending an increasing digit - // to the end of non-unique labels. - // TODO(jhawkins): Create a new interface for labeled entities and turn these - // two methods into one. - void SetUniqueCreditCardLabels(std::vector<CreditCard>* credit_cards); - // Saves |imported_profile| to the WebDB if it exists. virtual void SaveImportedProfile(const AutoFillProfile& imported_profile); diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc index afda4dc..aa5b0af 100644 --- a/chrome/browser/autofill/personal_data_manager_unittest.cc +++ b/chrome/browser/autofill/personal_data_manager_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -90,19 +90,19 @@ class PersonalDataManagerTest : public testing::Test { TEST_F(PersonalDataManagerTest, SetProfiles) { AutoFillProfile profile0; autofill_test::SetProfileInfo(&profile0, - "Billing", "Marion", "Mitchell", "Morrison", + "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); AutoFillProfile profile1; autofill_test::SetProfileInfo(&profile1, - "Home", "Josephine", "Alicia", "Saenz", + "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", "US", "19482937549", "13502849239"); AutoFillProfile profile2; autofill_test::SetProfileInfo(&profile2, - "Work", "Josephine", "Alicia", "Saenz", + "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", "32801", "US", "19482937549", "13502849239"); @@ -163,15 +163,15 @@ TEST_F(PersonalDataManagerTest, SetProfiles) { // TODO(jhawkins): Test SetCreditCards w/out a WebDataService in the profile. TEST_F(PersonalDataManagerTest, SetCreditCards) { CreditCard creditcard0; - autofill_test::SetCreditCardInfo(&creditcard0, "Corporate", + autofill_test::SetCreditCardInfo(&creditcard0, "John Dillinger", "423456789012" /* Visa */, "01", "2010"); CreditCard creditcard1; - autofill_test::SetCreditCardInfo(&creditcard1, "Personal", + autofill_test::SetCreditCardInfo(&creditcard1, "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012"); CreditCard creditcard2; - autofill_test::SetCreditCardInfo(&creditcard2, "Savings", + autofill_test::SetCreditCardInfo(&creditcard2, "Clyde Barrow", "347666888555" /* American Express */, "04", "2015"); // This will verify that the web database has been loaded and the notification @@ -231,22 +231,22 @@ TEST_F(PersonalDataManagerTest, SetCreditCards) { TEST_F(PersonalDataManagerTest, SetProfilesAndCreditCards) { AutoFillProfile profile0; autofill_test::SetProfileInfo(&profile0, - "Billing", "Marion", "Mitchell", "Morrison", + "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); AutoFillProfile profile1; autofill_test::SetProfileInfo(&profile1, - "Home", "Josephine", "Alicia", "Saenz", + "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", "US", "19482937549", "13502849239"); CreditCard creditcard0; - autofill_test::SetCreditCardInfo(&creditcard0, "Corporate", + autofill_test::SetCreditCardInfo(&creditcard0, "John Dillinger", "423456789012" /* Visa */, "01", "2010"); CreditCard creditcard1; - autofill_test::SetCreditCardInfo(&creditcard1, "Personal", + autofill_test::SetCreditCardInfo(&creditcard1, "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012"); // This will verify that the web database has been loaded and the notification @@ -298,7 +298,7 @@ TEST_F(PersonalDataManagerTest, SetProfilesAndCreditCards) { TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { AutoFillProfile profile0; autofill_test::SetProfileInfo(&profile0, - "", "y", "", "", "", "", "", "", "", "", "", "", "", ""); + "y", "", "", "", "", "", "", "", "", "", "", "", ""); // This will verify that the web database has been loaded and the notification // sent out. @@ -327,7 +327,7 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { // Add a new profile. AutoFillProfile profile1; autofill_test::SetProfileInfo(&profile1, - "", "y", "", "", "", "", "", "", "", "", "", "", "", ""); + "y", "", "", "", "", "", "", "", "", "", "", "", ""); update.clear(); update.push_back(*results2[0]); update.push_back(profile1); @@ -345,7 +345,7 @@ TEST_F(PersonalDataManagerTest, PopulateUniqueIDsOnLoad) { TEST_F(PersonalDataManagerTest, SetEmptyProfile) { AutoFillProfile profile0; autofill_test::SetProfileInfo(&profile0, - "", "", "", "", "", "", "", "", "", "", "", "", "", ""); + "", "", "", "", "", "", "", "", "", "", "", "", ""); // This will verify that the web database has been loaded and the notification // sent out. @@ -384,7 +384,7 @@ TEST_F(PersonalDataManagerTest, SetEmptyProfile) { TEST_F(PersonalDataManagerTest, SetEmptyCreditCard) { CreditCard creditcard0; - autofill_test::SetCreditCardInfo(&creditcard0, "", "", "", "", ""); + autofill_test::SetCreditCardInfo(&creditcard0, "", "", "", ""); // This will verify that the web database has been loaded and the notification // sent out. @@ -424,13 +424,13 @@ TEST_F(PersonalDataManagerTest, SetEmptyCreditCard) { TEST_F(PersonalDataManagerTest, Refresh) { AutoFillProfile profile0; autofill_test::SetProfileInfo(&profile0, - "Billing", "Marion", "Mitchell", "Morrison", + "Marion", "Mitchell", "Morrison", "johnwayne@me.xyz", "Fox", "123 Zoo St.", "unit 5", "Hollywood", "CA", "91601", "US", "12345678910", "01987654321"); AutoFillProfile profile1; autofill_test::SetProfileInfo(&profile1, - "Home", "Josephine", "Alicia", "Saenz", + "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "903 Apple Ct.", NULL, "Orlando", "FL", "32801", "US", "19482937549", "13502849239"); @@ -464,7 +464,7 @@ TEST_F(PersonalDataManagerTest, Refresh) { AutoFillProfile profile2; autofill_test::SetProfileInfo(&profile2, - "Work", "Josephine", "Alicia", "Saenz", + "Josephine", "Alicia", "Saenz", "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", "32801", "US", "19482937549", "13502849239"); @@ -474,7 +474,7 @@ TEST_F(PersonalDataManagerTest, Refresh) { WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); ASSERT_TRUE(wds); - wds->AddAutoFillProfileGUID(profile2); + wds->AddAutoFillProfile(profile2); personal_data_->Refresh(); @@ -490,8 +490,8 @@ TEST_F(PersonalDataManagerTest, Refresh) { EXPECT_EQ(profile1, *results2.at(1)); EXPECT_EQ(profile2, *results2.at(2)); - wds->RemoveAutoFillProfileGUID(profile1.guid()); - wds->RemoveAutoFillProfileGUID(profile2.guid()); + wds->RemoveAutoFillProfile(profile1.guid()); + wds->RemoveAutoFillProfile(profile2.guid()); // Before telling the PDM to refresh, simulate an edit to one of the profiles // via a SetProfile update (this would happen if the AutoFill window was @@ -554,7 +554,7 @@ TEST_F(PersonalDataManagerTest, ImportFormData) { MessageLoop::current()->Run(); AutoFillProfile expected; - autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL, NULL); const std::vector<AutoFillProfile*>& results = personal_data_->profiles(); @@ -600,7 +600,7 @@ TEST_F(PersonalDataManagerTest, ImportFormDataBadEmail) { MessageLoop::current()->Run(); AutoFillProfile expected; - autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected, "George", NULL, "Washington", NULL, NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL, NULL); const std::vector<AutoFillProfile*>& results = personal_data_->profiles(); @@ -686,7 +686,7 @@ TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) { MessageLoop::current()->Run(); AutoFillProfile expected; - autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected, "George", NULL, "Washington", NULL, NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, "6505550000", NULL); const std::vector<AutoFillProfile*>& results = personal_data_->profiles(); @@ -696,22 +696,16 @@ TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) { TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { CreditCard credit_card0; - credit_card0.set_label(ASCIIToUTF16("Home")); credit_card0.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("John")); CreditCard credit_card1; - credit_card1.set_label(ASCIIToUTF16("Home")); credit_card1.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Paul")); CreditCard credit_card2; - credit_card2.set_label(ASCIIToUTF16("Home")); credit_card2.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Ringo")); CreditCard credit_card3; - credit_card3.set_label(ASCIIToUTF16("NotHome")); credit_card3.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Other")); CreditCard credit_card4; - credit_card4.set_label(ASCIIToUTF16("Work")); credit_card4.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Ozzy")); CreditCard credit_card5; - credit_card5.set_label(ASCIIToUTF16("Work")); credit_card5.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Dio")); // This will verify that the web database has been loaded and the notification @@ -747,12 +741,12 @@ TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(6U, results.size()); - EXPECT_EQ(ASCIIToUTF16("Home"), results[0]->Label()); - EXPECT_EQ(ASCIIToUTF16("Home2"), results[1]->Label()); - EXPECT_EQ(ASCIIToUTF16("Home3"), results[2]->Label()); - EXPECT_EQ(ASCIIToUTF16("NotHome"), results[3]->Label()); - EXPECT_EQ(ASCIIToUTF16("Work"), results[4]->Label()); - EXPECT_EQ(ASCIIToUTF16("Work2"), results[5]->Label()); + EXPECT_EQ(credit_card0.guid(), results[0]->guid()); + EXPECT_EQ(credit_card1.guid(), results[1]->guid()); + EXPECT_EQ(credit_card2.guid(), results[2]->guid()); + EXPECT_EQ(credit_card3.guid(), results[3]->guid()); + EXPECT_EQ(credit_card4.guid(), results[4]->guid()); + EXPECT_EQ(credit_card5.guid(), results[5]->guid()); } TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { @@ -794,7 +788,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { MessageLoop::current()->Run(); AutoFillProfile expected; - autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL, NULL); const std::vector<AutoFillProfile*>& results1 = personal_data_->profiles(); @@ -840,7 +834,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentProfiles) { const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles(); AutoFillProfile expected2; - autofill_test::SetProfileInfo(&expected2, NULL, "John", NULL, + autofill_test::SetProfileInfo(&expected2, "John", NULL, "Adams", "second@gmail.com", NULL, "21 Laussat St", NULL, "San Francisco", "California", "94102", NULL, NULL, NULL); ASSERT_EQ(2U, results2.size()); @@ -894,7 +888,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { MessageLoop::current()->Run(); AutoFillProfile expected; - autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", "Suite A", "San Francisco", "California", "94102", NULL, "4445556666", NULL); @@ -952,7 +946,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameProfileWithConflict) { const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles(); AutoFillProfile expected2; - autofill_test::SetProfileInfo(&expected2, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected2, "George", NULL, "Washington", "theprez@gmail.com", NULL, "1600 Pennsylvania Avenue", "Suite A", "San Francisco", "California", "94102", "USA", "1231231234", NULL); @@ -996,7 +990,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { MessageLoop::current()->Run(); AutoFillProfile expected; - autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected, "George", NULL, "Washington", NULL, NULL, "190 High Street", NULL, "Philadelphia", "Pennsylvania", "19106", NULL, NULL, NULL); const std::vector<AutoFillProfile*>& results1 = personal_data_->profiles(); @@ -1042,7 +1036,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInOld) { const std::vector<AutoFillProfile*>& results2 = personal_data_->profiles(); AutoFillProfile expected2; - autofill_test::SetProfileInfo(&expected2, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected2, "George", NULL, "Washington", "theprez@gmail.com", NULL, "190 High Street", NULL, "Philadelphia", "Pennsylvania", "19106", NULL, NULL, NULL); ASSERT_EQ(1U, results2.size()); @@ -1091,7 +1085,7 @@ TEST_F(PersonalDataManagerTest, AggregateProfileWithMissingInfoInNew) { MessageLoop::current()->Run(); AutoFillProfile expected; - autofill_test::SetProfileInfo(&expected, NULL, "George", NULL, + autofill_test::SetProfileInfo(&expected, "George", NULL, "Washington", "theprez@gmail.com", "Government", "190 High Street", NULL, "Philadelphia", "Pennsylvania", "19106", NULL, NULL, NULL); const std::vector<AutoFillProfile*>& results1 = personal_data_->profiles(); @@ -1219,7 +1213,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) { CreditCard expected; autofill_test::SetCreditCardInfo(&expected, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -1255,7 +1249,7 @@ TEST_F(PersonalDataManagerTest, AggregateTwoDifferentCreditCards) { CreditCard expected2; autofill_test::SetCreditCardInfo(&expected2, - "L2", "Jim Johansen", "5500000000000004", "02", "2012"); + "Jim Johansen", "5500000000000004", "02", "2012"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(2U, results2.size()); EXPECT_EQ(0, expected.Compare(*results2[0])); @@ -1297,7 +1291,7 @@ TEST_F(PersonalDataManagerTest, AggregateInvalidCreditCard) { CreditCard expected; autofill_test::SetCreditCardInfo(&expected, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -1365,7 +1359,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) { CreditCard expected; autofill_test::SetCreditCardInfo(&expected, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -1404,7 +1398,7 @@ TEST_F(PersonalDataManagerTest, AggregateSameCreditCardWithConflict) { // updated to "2012". CreditCard expected2; autofill_test::SetCreditCardInfo(&expected2, - "L1", "Biggie Smalls", "4111111111111111", "01", "2012"); + "Biggie Smalls", "4111111111111111", "01", "2012"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected2.Compare(*results2[0])); @@ -1445,7 +1439,7 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) { CreditCard expected; autofill_test::SetCreditCardInfo(&expected, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -1473,7 +1467,7 @@ TEST_F(PersonalDataManagerTest, AggregateEmptyCreditCardWithConflict) { // No change is expected. CreditCard expected2; autofill_test::SetCreditCardInfo(&expected2, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected2.Compare(*results2[0])); @@ -1514,7 +1508,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { CreditCard expected; autofill_test::SetCreditCardInfo(&expected, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -1544,7 +1538,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInNew) { // No change is expected. CreditCard expected2; autofill_test::SetCreditCardInfo(&expected2, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected2.Compare(*results2[0])); @@ -1583,7 +1577,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInOld) { CreditCard expected; autofill_test::SetCreditCardInfo(&expected, - "L1", NULL, "4111111111111111", "01", "2011"); + NULL, "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results = personal_data_->credit_cards(); ASSERT_EQ(1U, results.size()); EXPECT_EQ(0, expected.Compare(*results[0])); @@ -1622,7 +1616,7 @@ TEST_F(PersonalDataManagerTest, AggregateCreditCardWithMissingInfoInOld) { // added to the existing credit card. CreditCard expected2; autofill_test::SetCreditCardInfo(&expected2, - "L1", "Biggie Smalls", "4111111111111111", "01", "2011"); + "Biggie Smalls", "4111111111111111", "01", "2011"); const std::vector<CreditCard*>& results2 = personal_data_->credit_cards(); ASSERT_EQ(1U, results2.size()); EXPECT_EQ(0, expected2.Compare(*results2[0])); diff --git a/chrome/browser/sync/glue/autofill_change_processor.cc b/chrome/browser/sync/glue/autofill_change_processor.cc index 6177f9e..6837f68 100644 --- a/chrome/browser/sync/glue/autofill_change_processor.cc +++ b/chrome/browser/sync/glue/autofill_change_processor.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -361,7 +361,7 @@ void AutofillChangeProcessor::ApplySyncAutofillProfileChange( return; } AutoFillProfile *temp_ptr; - if (!web_database_->GetAutoFillProfileForGUID(*guid, &temp_ptr)) { + if (!web_database_->GetAutoFillProfile(*guid, &temp_ptr)) { LOG(ERROR) << "Autofill profile not found for " << *guid; return; } diff --git a/chrome/browser/sync/glue/autofill_profile_change_processor.cc b/chrome/browser/sync/glue/autofill_profile_change_processor.cc index 51d5b07..5484805 100644 --- a/chrome/browser/sync/glue/autofill_profile_change_processor.cc +++ b/chrome/browser/sync/glue/autofill_profile_change_processor.cc @@ -103,7 +103,7 @@ void AutofillProfileChangeProcessor::ApplyChangesFromSyncModel( void AutofillProfileChangeProcessor::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- DCHECK_EQ(type.value, NotificationType::AUTOFILL_PROFILE_CHANGED_GUID);
+ DCHECK_EQ(type.value, NotificationType::AUTOFILL_PROFILE_CHANGED);
WebDataService* wds = Source<WebDataService>(source).ptr();
if (!wds || wds->GetDatabase() != web_database_)
@@ -117,24 +117,22 @@ void AutofillProfileChangeProcessor::Observe(NotificationType type, return;
}
- AutofillProfileChangeGUID* change =
- Details<AutofillProfileChangeGUID>(details).ptr();
+ AutofillProfileChange* change = Details<AutofillProfileChange>(details).ptr();
ActOnChange(change, &trans, autofill_root);
}
void AutofillProfileChangeProcessor::ActOnChange(
- AutofillProfileChangeGUID* change,
+ AutofillProfileChange* change,
sync_api::WriteTransaction* trans,
sync_api::ReadNode& autofill_root) {
- DCHECK(change->type() == AutofillProfileChangeGUID::REMOVE ||
- change->profile());
+ DCHECK(change->type() == AutofillProfileChange::REMOVE || change->profile());
switch (change->type()) {
- case AutofillProfileChangeGUID::ADD: {
+ case AutofillProfileChange::ADD: {
AddAutofillProfileSyncNode(trans, autofill_root, *(change->profile()));
break;
}
- case AutofillProfileChangeGUID::UPDATE: {
+ case AutofillProfileChange::UPDATE: {
int64 sync_id = model_associator_->GetSyncIdFromChromeId(change->key());
if (sync_api::kInvalidId == sync_id) {
LOG(ERROR) << "Sync id is not found for " << change->key();
@@ -149,7 +147,7 @@ void AutofillProfileChangeProcessor::ActOnChange( WriteAutofillProfile(*(change->profile()), &node);
break;
}
- case AutofillProfileChangeGUID::REMOVE: {
+ case AutofillProfileChange::REMOVE: {
int64 sync_id = model_associator_->GetSyncIdFromChromeId(change->key());
if (sync_api::kInvalidId == sync_id) {
LOG(ERROR) << "Sync id is not found for " << change->key();
@@ -229,10 +227,9 @@ void AutofillProfileChangeProcessor::ApplyAutofillProfileChange( }
case sync_api::SyncManager::ChangeRecord::ACTION_UPDATE: {
AutoFillProfile *p;
- if (!web_database_->GetAutoFillProfileForGUID(
- profile_specifics.guid(), &p)) {
+ if (!web_database_->GetAutoFillProfile(profile_specifics.guid(), &p)) {
LOG(ERROR) << "Could not find the autofill profile to update for " <<
- profile_specifics.guid();
+ profile_specifics.guid();
break;
}
scoped_ptr<AutoFillProfile> autofill_pointer(p);
@@ -295,7 +292,7 @@ void AutofillProfileChangeProcessor::AddAutofillProfileSyncNode( void AutofillProfileChangeProcessor::StartObserving() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
notification_registrar_.Add(this,
- NotificationType::AUTOFILL_PROFILE_CHANGED_GUID,
+ NotificationType::AUTOFILL_PROFILE_CHANGED,
NotificationService::AllSources());
}
diff --git a/chrome/browser/sync/glue/autofill_profile_change_processor.h b/chrome/browser/sync/glue/autofill_profile_change_processor.h index c10a15c..a1d44a3 100644 --- a/chrome/browser/sync/glue/autofill_profile_change_processor.h +++ b/chrome/browser/sync/glue/autofill_profile_change_processor.h @@ -75,7 +75,7 @@ class AutofillProfileChangeProcessor : public ChangeProcessor, sync_api::BaseNode& autofill_profile_root, const AutoFillProfile& profile); - void ActOnChange(AutofillProfileChangeGUID* change, + void ActOnChange(AutofillProfileChange* change, sync_api::WriteTransaction* trans, sync_api::ReadNode& autofill_root); diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc index 808a744..069c501 100644 --- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc @@ -886,12 +886,12 @@ TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeAddProfile) { "joewayne@me.xyz", "Fox", "1212 Center.", "Bld. 5", "Orlando", "FL", "32801", "US", "19482937549", "13502849239"); - AutofillProfileChangeGUID change(AutofillProfileChangeGUID::ADD, + AutofillProfileChange change(AutofillProfileChange::ADD, added_profile.guid(), &added_profile); scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); - notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED_GUID, + notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, Source<WebDataService>(web_data_service_.get()), - Details<AutofillProfileChangeGUID>(&change)); + Details<AutofillProfileChange>(&change)); std::vector<AutoFillProfile> new_sync_profiles; ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( @@ -988,12 +988,12 @@ TEST_F(ProfileSyncServiceAutofillTest, ProcessUserChangeRemoveProfile) { StartSyncService(&task, false, syncable::AUTOFILL_PROFILE); ASSERT_TRUE(task.success()); - AutofillProfileChangeGUID change(AutofillProfileChangeGUID::REMOVE, + AutofillProfileChange change(AutofillProfileChange::REMOVE, sync_profile.guid(), NULL); scoped_refptr<ThreadNotifier> notifier(new ThreadNotifier(&db_thread_)); - notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED_GUID, + notifier->Notify(NotificationType::AUTOFILL_PROFILE_CHANGED, Source<WebDataService>(web_data_service_.get()), - Details<AutofillProfileChangeGUID>(&change)); + Details<AutofillProfileChange>(&change)); std::vector<AutoFillProfile> new_sync_profiles; ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( diff --git a/chrome/browser/webdata/autofill_change.cc b/chrome/browser/webdata/autofill_change.cc index fd0cfbf..e78a4ab 100644 --- a/chrome/browser/webdata/autofill_change.cc +++ b/chrome/browser/webdata/autofill_change.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,45 +14,7 @@ AutofillChange::AutofillChange(Type type, const AutofillKey& key) AutofillChange::~AutofillChange() { } -AutofillProfileChange::AutofillProfileChange(Type type, - string16 key, - const AutoFillProfile* profile, - const string16& pre_update_label) - : GenericAutofillChange<string16>(type, key), - profile_(profile), - pre_update_label_(pre_update_label) { -} - -AutofillProfileChange::~AutofillProfileChange() { -} - -bool AutofillProfileChange::operator==( - const AutofillProfileChange& change) const { - if (type() != change.type() || key() != change.key()) - return false; - if (type() == REMOVE) - return true; - if (*profile() != *change.profile()) - return false; - return type() == ADD || pre_update_label_ == change.pre_update_label(); -} - -AutofillCreditCardChange::AutofillCreditCardChange( - Type type, string16 key, const CreditCard* credit_card) - : GenericAutofillChange<string16>(type, key), credit_card_(credit_card) { -} - -AutofillCreditCardChange::~AutofillCreditCardChange() { -} - -bool AutofillCreditCardChange::operator==( - const AutofillCreditCardChange& change) const { - return type() == change.type() && - key() == change.key() && - (type() != REMOVE) ? *credit_card() == *change.credit_card() : true; -} - -AutofillProfileChangeGUID::AutofillProfileChangeGUID( +AutofillProfileChange::AutofillProfileChange( Type type, std::string key, const AutoFillProfile* profile) : GenericAutofillChange<std::string>(type, key), profile_(profile) { @@ -61,17 +23,17 @@ AutofillProfileChangeGUID::AutofillProfileChangeGUID( DCHECK(type == REMOVE ? !profile : true); } -AutofillProfileChangeGUID::~AutofillProfileChangeGUID() { +AutofillProfileChange::~AutofillProfileChange() { } -bool AutofillProfileChangeGUID::operator==( - const AutofillProfileChangeGUID& change) const { +bool AutofillProfileChange::operator==( + const AutofillProfileChange& change) const { return type() == change.type() && key() == change.key() && (type() != REMOVE) ? *profile() == *change.profile() : true; } -AutofillCreditCardChangeGUID::AutofillCreditCardChangeGUID( +AutofillCreditCardChange::AutofillCreditCardChange( Type type, std::string key, const CreditCard* credit_card) : GenericAutofillChange<std::string>(type, key), credit_card_(credit_card) { DCHECK(type == ADD ? (credit_card && credit_card->guid() == key) : true); @@ -79,11 +41,11 @@ AutofillCreditCardChangeGUID::AutofillCreditCardChangeGUID( DCHECK(type == REMOVE ? !credit_card : true); } -AutofillCreditCardChangeGUID::~AutofillCreditCardChangeGUID() { +AutofillCreditCardChange::~AutofillCreditCardChange() { } -bool AutofillCreditCardChangeGUID::operator==( - const AutofillCreditCardChangeGUID& change) const { +bool AutofillCreditCardChange::operator==( + const AutofillCreditCardChange& change) const { return type() == change.type() && key() == change.key() && (type() != REMOVE) ? *credit_card() == *change.credit_card() : true; diff --git a/chrome/browser/webdata/autofill_change.h b/chrome/browser/webdata/autofill_change.h index 2a46399..1c7449e 100644 --- a/chrome/browser/webdata/autofill_change.h +++ b/chrome/browser/webdata/autofill_change.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -45,44 +45,37 @@ class AutofillChange : public GenericAutofillChange<AutofillKey> { } }; -// DEPRECATED -// TODO(dhollowa): Remove use of labels for sync. http://crbug.com/58813 -class AutofillProfileChange : public GenericAutofillChange<string16> { +// Change notification details for AutoFill profile changes. +class AutofillProfileChange : public GenericAutofillChange<std::string> { public: // The |type| input specifies the change type. The |key| input is the key, - // which is expected to be the label identifying the |profile|. + // which is expected to be the GUID identifying the |profile|. // When |type| == ADD, |profile| should be non-NULL. // When |type| == UPDATE, |profile| should be non-NULL. // When |type| == REMOVE, |profile| should be NULL. - // The |pre_update_label| input specifies the label as it was prior to the - // change (applicable only for UPDATE). AutofillProfileChange(Type type, - string16 key, - const AutoFillProfile* profile, - const string16& pre_update_label); + std::string key, + const AutoFillProfile* profile); virtual ~AutofillProfileChange(); const AutoFillProfile* profile() const { return profile_; } - const string16& pre_update_label() const { return pre_update_label_; } bool operator==(const AutofillProfileChange& change) const; private: // Weak reference, can be NULL. const AutoFillProfile* profile_; - const string16 pre_update_label_; }; -// DEPRECATED -// TODO(dhollowa): Remove use of labels for sync. http://crbug.com/58813 -class AutofillCreditCardChange : public GenericAutofillChange<string16> { +// Change notification details for AutoFill credit card changes. +class AutofillCreditCardChange : public GenericAutofillChange<std::string> { public: // The |type| input specifies the change type. The |key| input is the key, - // which is expected to be the label identifying the |credit_card|. + // which is expected to be the GUID identifying the |credit_card|. // When |type| == ADD, |credit_card| should be non-NULL. // When |type| == UPDATE, |credit_card| should be non-NULL. // When |type| == REMOVE, |credit_card| should be NULL. AutofillCreditCardChange(Type type, - string16 key, + std::string key, const CreditCard* credit_card); virtual ~AutofillCreditCardChange(); @@ -94,46 +87,4 @@ class AutofillCreditCardChange : public GenericAutofillChange<string16> { const CreditCard* credit_card_; }; -// Change notification details for AutoFill profile changes. -class AutofillProfileChangeGUID : public GenericAutofillChange<std::string> { - public: - // The |type| input specifies the change type. The |key| input is the key, - // which is expected to be the GUID identifying the |profile|. - // When |type| == ADD, |profile| should be non-NULL. - // When |type| == UPDATE, |profile| should be non-NULL. - // When |type| == REMOVE, |profile| should be NULL. - AutofillProfileChangeGUID(Type type, - std::string key, - const AutoFillProfile* profile); - virtual ~AutofillProfileChangeGUID(); - - const AutoFillProfile* profile() const { return profile_; } - bool operator==(const AutofillProfileChangeGUID& change) const; - - private: - // Weak reference, can be NULL. - const AutoFillProfile* profile_; -}; - -// Change notification details for AutoFill credit card changes. -class AutofillCreditCardChangeGUID : public GenericAutofillChange<std::string> { - public: - // The |type| input specifies the change type. The |key| input is the key, - // which is expected to be the GUID identifying the |credit_card|. - // When |type| == ADD, |credit_card| should be non-NULL. - // When |type| == UPDATE, |credit_card| should be non-NULL. - // When |type| == REMOVE, |credit_card| should be NULL. - AutofillCreditCardChangeGUID(Type type, - std::string key, - const CreditCard* credit_card); - virtual ~AutofillCreditCardChangeGUID(); - - const CreditCard* credit_card() const { return credit_card_; } - bool operator==(const AutofillCreditCardChangeGUID& change) const; - - private: - // Weak reference, can be NULL. - const CreditCard* credit_card_; -}; - #endif // CHROME_BROWSER_WEBDATA_AUTOFILL_CHANGE_H__ diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index b52f225..ac635fa 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -391,33 +391,33 @@ void WebDataService::RemoveFormValueForElementName( request)); } -void WebDataService::AddAutoFillProfileGUID(const AutoFillProfile& profile) { +void WebDataService::AddAutoFillProfile(const AutoFillProfile& profile) { GenericRequest<AutoFillProfile>* request = new GenericRequest<AutoFillProfile>( this, GetNextRequestHandle(), NULL, profile); RegisterRequest(request); ScheduleTask(NewRunnableMethod(this, - &WebDataService::AddAutoFillProfileGUIDImpl, + &WebDataService::AddAutoFillProfileImpl, request)); } -void WebDataService::UpdateAutoFillProfileGUID(const AutoFillProfile& profile) { +void WebDataService::UpdateAutoFillProfile(const AutoFillProfile& profile) { GenericRequest<AutoFillProfile>* request = new GenericRequest<AutoFillProfile>( this, GetNextRequestHandle(), NULL, profile); RegisterRequest(request); ScheduleTask(NewRunnableMethod(this, - &WebDataService::UpdateAutoFillProfileGUIDImpl, + &WebDataService::UpdateAutoFillProfileImpl, request)); } -void WebDataService::RemoveAutoFillProfileGUID(const std::string& guid) { +void WebDataService::RemoveAutoFillProfile(const std::string& guid) { GenericRequest<std::string>* request = new GenericRequest<std::string>( this, GetNextRequestHandle(), NULL, guid); RegisterRequest(request); ScheduleTask(NewRunnableMethod(this, - &WebDataService::RemoveAutoFillProfileGUIDImpl, + &WebDataService::RemoveAutoFillProfileImpl, request)); } @@ -433,33 +433,33 @@ WebDataService::Handle WebDataService::GetAutoFillProfiles( return request->GetHandle(); } -void WebDataService::AddCreditCardGUID(const CreditCard& credit_card) { +void WebDataService::AddCreditCard(const CreditCard& credit_card) { GenericRequest<CreditCard>* request = new GenericRequest<CreditCard>( this, GetNextRequestHandle(), NULL, credit_card); RegisterRequest(request); ScheduleTask(NewRunnableMethod(this, - &WebDataService::AddCreditCardGUIDImpl, + &WebDataService::AddCreditCardImpl, request)); } -void WebDataService::UpdateCreditCardGUID(const CreditCard& credit_card) { +void WebDataService::UpdateCreditCard(const CreditCard& credit_card) { GenericRequest<CreditCard>* request = new GenericRequest<CreditCard>( this, GetNextRequestHandle(), NULL, credit_card); RegisterRequest(request); ScheduleTask(NewRunnableMethod(this, - &WebDataService::UpdateCreditCardGUIDImpl, + &WebDataService::UpdateCreditCardImpl, request)); } -void WebDataService::RemoveCreditCardGUID(const std::string& guid) { +void WebDataService::RemoveCreditCard(const std::string& guid) { GenericRequest<std::string>* request = new GenericRequest<std::string>( this, GetNextRequestHandle(), NULL, guid); RegisterRequest(request); ScheduleTask(NewRunnableMethod(this, - &WebDataService::RemoveCreditCardGUIDImpl, + &WebDataService::RemoveCreditCardImpl, request)); } @@ -991,7 +991,7 @@ void WebDataService::RemoveFormValueForElementNameImpl( request->RequestComplete(); } -void WebDataService::AddAutoFillProfileGUIDImpl( +void WebDataService::AddAutoFillProfileImpl( GenericRequest<AutoFillProfile>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { @@ -1003,42 +1003,27 @@ void WebDataService::AddAutoFillProfileGUIDImpl( ScheduleCommit(); // Send GUID-based notification. - AutofillProfileChangeGUID change(AutofillProfileChangeGUID::ADD, - profile.guid(), &profile); - NotificationService::current()->Notify( - NotificationType::AUTOFILL_PROFILE_CHANGED_GUID, - Source<WebDataService>(this), - Details<AutofillProfileChangeGUID>(&change)); - - // TODO(dhollowa): Remove labels. http://crbug.com/58813 - // Send out old Label-based notification until sync can switch over to - // GUID-based notifications. - AutofillProfileChange deprecated_change(AutofillProfileChange::ADD, - profile.Label(), - &profile, - string16()); + AutofillProfileChange change(AutofillProfileChange::ADD, + profile.guid(), &profile); NotificationService::current()->Notify( NotificationType::AUTOFILL_PROFILE_CHANGED, Source<WebDataService>(this), - Details<AutofillProfileChange>(&deprecated_change)); + Details<AutofillProfileChange>(&change)); } request->RequestComplete(); } -void WebDataService::UpdateAutoFillProfileGUIDImpl( +void WebDataService::UpdateAutoFillProfileImpl( GenericRequest<AutoFillProfile>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { const AutoFillProfile& profile = request->GetArgument(); - // TODO(dhollowa): Remove labels. http://crbug.com/58813 - // Send out old Label-based notification until sync can switch over to - // GUID-based notifications. // Only perform the update if the profile exists. It is currently // valid to try to update a missing profile. We simply drop the write and // the caller will detect this on the next refresh. AutoFillProfile* original_profile = NULL; - if (!db_->GetAutoFillProfileForGUID(profile.guid(), &original_profile)) { + if (!db_->GetAutoFillProfile(profile.guid(), &original_profile)) { request->RequestComplete(); return; } @@ -1051,37 +1036,24 @@ void WebDataService::UpdateAutoFillProfileGUIDImpl( ScheduleCommit(); // Send GUID-based notification. - AutofillProfileChangeGUID change(AutofillProfileChangeGUID::UPDATE, - profile.guid(), &profile); - NotificationService::current()->Notify( - NotificationType::AUTOFILL_PROFILE_CHANGED_GUID, - Source<WebDataService>(this), - Details<AutofillProfileChangeGUID>(&change)); - - // TODO(dhollowa): Remove labels. http://crbug.com/58813 - // Send old Label-based notification. - AutofillProfileChange deprecated_change(AutofillProfileChange::UPDATE, - profile.Label(), &profile, - original_profile->Label()); + AutofillProfileChange change(AutofillProfileChange::UPDATE, + profile.guid(), &profile); NotificationService::current()->Notify( NotificationType::AUTOFILL_PROFILE_CHANGED, Source<WebDataService>(this), - Details<AutofillProfileChange>(&deprecated_change)); + Details<AutofillProfileChange>(&change)); } request->RequestComplete(); } -void WebDataService::RemoveAutoFillProfileGUIDImpl( +void WebDataService::RemoveAutoFillProfileImpl( GenericRequest<std::string>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { std::string guid = request->GetArgument(); - // TODO(dhollowa): Remove labels. http://crbug.com/58813 - // Send out old Label-based notification until sync can switch over to - // GUID-based notifications. AutoFillProfile* profile = NULL; - if (!db_->GetAutoFillProfileForGUID(guid, &profile)) { + if (!db_->GetAutoFillProfile(guid, &profile)) { NOTREACHED(); return; } @@ -1094,22 +1066,11 @@ void WebDataService::RemoveAutoFillProfileGUIDImpl( ScheduleCommit(); // Send GUID-based notification. - AutofillProfileChangeGUID change(AutofillProfileChangeGUID::REMOVE, - guid, NULL); - NotificationService::current()->Notify( - NotificationType::AUTOFILL_PROFILE_CHANGED_GUID, - Source<WebDataService>(this), - Details<AutofillProfileChangeGUID>(&change)); - - // TODO(dhollowa): Remove labels. http://crbug.com/58813 - // Send old Label-based notification. - AutofillProfileChange deprecated_change(AutofillProfileChange::REMOVE, - scoped_profile->Label(), - NULL, string16()); + AutofillProfileChange change(AutofillProfileChange::REMOVE, guid, NULL); NotificationService::current()->Notify( NotificationType::AUTOFILL_PROFILE_CHANGED, Source<WebDataService>(this), - Details<AutofillProfileChange>(&deprecated_change)); + Details<AutofillProfileChange>(&change)); } request->RequestComplete(); } @@ -1126,7 +1087,7 @@ void WebDataService::GetAutoFillProfilesImpl(WebDataRequest* request) { request->RequestComplete(); } -void WebDataService::AddCreditCardGUIDImpl( +void WebDataService::AddCreditCardImpl( GenericRequest<CreditCard>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { @@ -1138,17 +1099,17 @@ void WebDataService::AddCreditCardGUIDImpl( ScheduleCommit(); // Send GUID-based notification. - AutofillCreditCardChangeGUID change(AutofillCreditCardChangeGUID::ADD, - credit_card.guid(), &credit_card); + AutofillCreditCardChange change(AutofillCreditCardChange::ADD, + credit_card.guid(), &credit_card); NotificationService::current()->Notify( - NotificationType::AUTOFILL_CREDIT_CARD_CHANGED_GUID, + NotificationType::AUTOFILL_CREDIT_CARD_CHANGED, Source<WebDataService>(this), - Details<AutofillCreditCardChangeGUID>(&change)); + Details<AutofillCreditCardChange>(&change)); } request->RequestComplete(); } -void WebDataService::UpdateCreditCardGUIDImpl( +void WebDataService::UpdateCreditCardImpl( GenericRequest<CreditCard>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { @@ -1157,7 +1118,7 @@ void WebDataService::UpdateCreditCardGUIDImpl( // It is currently valid to try to update a missing profile. We simply drop // the write and the caller will detect this on the next refresh. CreditCard* original_credit_card = NULL; - if (!db_->GetCreditCardForGUID(credit_card.guid(), &original_credit_card)) { + if (!db_->GetCreditCard(credit_card.guid(), &original_credit_card)) { request->RequestComplete(); return; } @@ -1170,17 +1131,17 @@ void WebDataService::UpdateCreditCardGUIDImpl( ScheduleCommit(); // Send GUID-based notification. - AutofillCreditCardChangeGUID change(AutofillCreditCardChangeGUID::UPDATE, - credit_card.guid(), &credit_card); + AutofillCreditCardChange change(AutofillCreditCardChange::UPDATE, + credit_card.guid(), &credit_card); NotificationService::current()->Notify( - NotificationType::AUTOFILL_CREDIT_CARD_CHANGED_GUID, + NotificationType::AUTOFILL_CREDIT_CARD_CHANGED, Source<WebDataService>(this), - Details<AutofillCreditCardChangeGUID>(&change)); + Details<AutofillCreditCardChange>(&change)); } request->RequestComplete(); } -void WebDataService::RemoveCreditCardGUIDImpl( +void WebDataService::RemoveCreditCardImpl( GenericRequest<std::string>* request) { InitializeDatabaseIfNecessary(); if (db_ && !request->IsCancelled()) { @@ -1192,12 +1153,12 @@ void WebDataService::RemoveCreditCardGUIDImpl( ScheduleCommit(); // Send GUID-based notification. - AutofillCreditCardChangeGUID change(AutofillCreditCardChangeGUID::REMOVE, - guid, NULL); + AutofillCreditCardChange change(AutofillCreditCardChange::REMOVE, + guid, NULL); NotificationService::current()->Notify( - NotificationType::AUTOFILL_CREDIT_CARD_CHANGED_GUID, + NotificationType::AUTOFILL_CREDIT_CARD_CHANGED, Source<WebDataService>(this), - Details<AutofillCreditCardChangeGUID>(&change)); + Details<AutofillCreditCardChange>(&change)); } request->RequestComplete(); } diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index b881837..a9fc924 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -438,14 +438,14 @@ class WebDataService const string16& value); // Schedules a task to add an AutoFill profile to the web database. - void AddAutoFillProfileGUID(const AutoFillProfile& profile); + void AddAutoFillProfile(const AutoFillProfile& profile); // Schedules a task to update an AutoFill profile in the web database. - void UpdateAutoFillProfileGUID(const AutoFillProfile& profile); + void UpdateAutoFillProfile(const AutoFillProfile& profile); // Schedules a task to remove an AutoFill profile from the web database. // |guid| is the identifer of the profile to remove. - void RemoveAutoFillProfileGUID(const std::string& guid); + void RemoveAutoFillProfile(const std::string& guid); // Initiates the request for all AutoFill profiles. The method // OnWebDataServiceRequestDone of |consumer| gets called when the request is @@ -454,14 +454,14 @@ class WebDataService Handle GetAutoFillProfiles(WebDataServiceConsumer* consumer); // Schedules a task to add credit card to the web database. - void AddCreditCardGUID(const CreditCard& credit_card); + void AddCreditCard(const CreditCard& credit_card); // Schedules a task to update credit card in the web database. - void UpdateCreditCardGUID(const CreditCard& credit_card); + void UpdateCreditCard(const CreditCard& credit_card); // Schedules a task to remove a credit card from the web database. // |guid| is identifer of the credit card to remove. - void RemoveCreditCardGUID(const std::string& guid); + void RemoveCreditCard(const std::string& guid); // Initiates the request for all credit cards. The method // OnWebDataServiceRequestDone of |consumer| gets called when the request is @@ -599,13 +599,13 @@ class WebDataService GenericRequest2<base::Time, base::Time>* request); void RemoveFormValueForElementNameImpl( GenericRequest2<string16, string16>* request); - void AddAutoFillProfileGUIDImpl(GenericRequest<AutoFillProfile>* request); - void UpdateAutoFillProfileGUIDImpl(GenericRequest<AutoFillProfile>* request); - void RemoveAutoFillProfileGUIDImpl(GenericRequest<std::string>* request); + void AddAutoFillProfileImpl(GenericRequest<AutoFillProfile>* request); + void UpdateAutoFillProfileImpl(GenericRequest<AutoFillProfile>* request); + void RemoveAutoFillProfileImpl(GenericRequest<std::string>* request); void GetAutoFillProfilesImpl(WebDataRequest* request); - void AddCreditCardGUIDImpl(GenericRequest<CreditCard>* request); - void UpdateCreditCardGUIDImpl(GenericRequest<CreditCard>* request); - void RemoveCreditCardGUIDImpl(GenericRequest<std::string>* request); + void AddCreditCardImpl(GenericRequest<CreditCard>* request); + void UpdateCreditCardImpl(GenericRequest<CreditCard>* request); + void RemoveCreditCardImpl(GenericRequest<std::string>* request); void GetCreditCardsImpl(WebDataRequest* request); void RemoveAutoFillProfilesAndCreditCardsModifiedBetweenImpl( GenericRequest2<base::Time, base::Time>* request); diff --git a/chrome/browser/webdata/web_data_service_unittest.cc b/chrome/browser/webdata/web_data_service_unittest.cc index 98a277c..806ef90 100644 --- a/chrome/browser/webdata/web_data_service_unittest.cc +++ b/chrome/browser/webdata/web_data_service_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,14 +62,8 @@ class AutofillDBThreadObserverHelper : public DBThreadObserverHelper { NotificationType::AUTOFILL_PROFILE_CHANGED, NotificationService::AllSources()); registrar_.Add(&observer_, - NotificationType::AUTOFILL_PROFILE_CHANGED_GUID, - NotificationService::AllSources()); - registrar_.Add(&observer_, NotificationType::AUTOFILL_CREDIT_CARD_CHANGED, NotificationService::AllSources()); - registrar_.Add(&observer_, - NotificationType::AUTOFILL_CREDIT_CARD_CHANGED_GUID, - NotificationService::AllSources()); } }; @@ -257,35 +251,21 @@ TEST_F(WebDataServiceAutofillTest, FormFillRemoveMany) { done_event_.TimedWait(test_timeout_); } -TEST_F(WebDataServiceAutofillTest, ProfileAddGUID) { +TEST_F(WebDataServiceAutofillTest, ProfileAdd) { AutoFillProfile profile; - // TODO(dhollowa): Remove this notification. http://crbug.com/58813 - // Old Label-based notifications will be sent out until Sync can switch over - // to GUID-based notifications. - profile.set_label(name1_); - const AutofillProfileChange deprecated_expected_change( - AutofillProfileChange::ADD, name1_, &profile, string16()); + // Check that GUID-based notification was sent. + const AutofillProfileChange expected_change( + AutofillProfileChange::ADD, profile.guid(), &profile); EXPECT_CALL( *observer_helper_->observer(), Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED), Source<WebDataService>(wds_.get()), Property(&Details<const AutofillProfileChange>::ptr, - Pointee(deprecated_expected_change)))). - WillOnce(SignalEvent(&done_event_)); - - // Check that GUID-based notification was sent. - const AutofillProfileChangeGUID expected_change( - AutofillProfileChangeGUID::ADD, profile.guid(), &profile); - EXPECT_CALL( - *observer_helper_->observer(), - Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED_GUID), - Source<WebDataService>(wds_.get()), - Property(&Details<const AutofillProfileChangeGUID>::ptr, Pointee(expected_change)))). WillOnce(DoDefault()); - wds_->AddAutoFillProfileGUID(profile); + wds_->AddAutoFillProfile(profile); done_event_.TimedWait(test_timeout_); // Check that it was added. @@ -298,16 +278,14 @@ TEST_F(WebDataServiceAutofillTest, ProfileAddGUID) { STLDeleteElements(&consumer.result()); } -TEST_F(WebDataServiceAutofillTest, ProfileRemoveGUID) { +TEST_F(WebDataServiceAutofillTest, ProfileRemove) { AutoFillProfile profile; - profile.set_label(name1_); // Add a profile. EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). - Times(2). - WillOnce(DoDefault()). + Times(1). WillOnce(SignalEvent(&done_event_)); - wds_->AddAutoFillProfileGUID(profile); + wds_->AddAutoFillProfile(profile); done_event_.TimedWait(test_timeout_); // Check that it was added. @@ -319,32 +297,19 @@ TEST_F(WebDataServiceAutofillTest, ProfileRemoveGUID) { EXPECT_EQ(profile, *consumer.result()[0]); STLDeleteElements(&consumer.result()); - // TODO(dhollowa): Remove this notification. http://crbug.com/58813 - // Old Label-based notifications will be sent out until Sync can switch over - // to GUID-based notifications. - const AutofillProfileChange deprecated_expected_change( - AutofillProfileChange::REMOVE, name1_, NULL, string16()); + // Check that GUID-based notification was sent. + const AutofillProfileChange expected_change( + AutofillProfileChange::REMOVE, profile.guid(), NULL); EXPECT_CALL( *observer_helper_->observer(), Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED), Source<WebDataService>(wds_.get()), Property(&Details<const AutofillProfileChange>::ptr, - Pointee(deprecated_expected_change)))). - WillOnce(SignalEvent(&done_event_)); - - // Check that GUID-based notification was sent. - const AutofillProfileChangeGUID expected_change( - AutofillProfileChangeGUID::REMOVE, profile.guid(), NULL); - EXPECT_CALL( - *observer_helper_->observer(), - Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED_GUID), - Source<WebDataService>(wds_.get()), - Property(&Details<const AutofillProfileChangeGUID>::ptr, Pointee(expected_change)))). WillOnce(DoDefault()); // Remove the profile. - wds_->RemoveAutoFillProfileGUID(profile.guid()); + wds_->RemoveAutoFillProfile(profile.guid()); done_event_.TimedWait(test_timeout_); // Check that it was removed. @@ -355,7 +320,7 @@ TEST_F(WebDataServiceAutofillTest, ProfileRemoveGUID) { ASSERT_EQ(0U, consumer2.result().size()); } -TEST_F(WebDataServiceAutofillTest, ProfileUpdateGUID) { +TEST_F(WebDataServiceAutofillTest, ProfileUpdate) { AutoFillProfile profile1; profile1.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Abe")); AutoFillProfile profile2; @@ -363,11 +328,9 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdateGUID) { EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). WillOnce(DoDefault()). - WillOnce(DoDefault()). - WillOnce(DoDefault()). WillOnce(SignalEvent(&done_event_)); - wds_->AddAutoFillProfileGUID(profile1); - wds_->AddAutoFillProfileGUID(profile2); + wds_->AddAutoFillProfile(profile1); + wds_->AddAutoFillProfile(profile2); done_event_.TimedWait(test_timeout_); // Check that they were added. @@ -380,38 +343,21 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdateGUID) { EXPECT_EQ(profile2, *consumer.result()[1]); STLDeleteElements(&consumer.result()); - // TODO(dhollowa): Remove this notification. http://crbug.com/58813 - // Old Label-based notifications will be sent out until Sync can switch over - // to GUID-based notifications. - AutoFillProfile deprecated_profile1_changed(profile1); - deprecated_profile1_changed.SetInfo(AutoFillType(NAME_FIRST), - ASCIIToUTF16("Bill")); - const AutofillProfileChangeGUID deprecated_expected_change( - AutofillProfileChangeGUID::UPDATE, profile1.guid(), - &deprecated_profile1_changed); - EXPECT_CALL( - *observer_helper_->observer(), - Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED), - Source<WebDataService>(wds_.get()), - Property(&Details<const AutofillProfileChangeGUID>::ptr, - Pointee(deprecated_expected_change)))). - WillOnce(SignalEvent(&done_event_)); - AutoFillProfile profile1_changed(profile1); profile1_changed.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Bill")); - const AutofillProfileChangeGUID expected_change( - AutofillProfileChangeGUID::UPDATE, profile1.guid(), &profile1_changed); + const AutofillProfileChange expected_change( + AutofillProfileChange::UPDATE, profile1.guid(), &profile1_changed); EXPECT_CALL( *observer_helper_->observer(), - Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED_GUID), + Observe(NotificationType(NotificationType::AUTOFILL_PROFILE_CHANGED), Source<WebDataService>(wds_.get()), - Property(&Details<const AutofillProfileChangeGUID>::ptr, + Property(&Details<const AutofillProfileChange>::ptr, Pointee(expected_change)))). WillOnce(DoDefault()); // Update the profile. - wds_->UpdateAutoFillProfileGUID(profile1_changed); + wds_->UpdateAutoFillProfile(profile1_changed); done_event_.TimedWait(test_timeout_); // Check that the updates were made. @@ -426,21 +372,21 @@ TEST_F(WebDataServiceAutofillTest, ProfileUpdateGUID) { STLDeleteElements(&consumer2.result()); } -TEST_F(WebDataServiceAutofillTest, CreditAddGUID) { +TEST_F(WebDataServiceAutofillTest, CreditAdd) { CreditCard card; - const AutofillCreditCardChangeGUID expected_change( - AutofillCreditCardChangeGUID::ADD, card.guid(), &card); + const AutofillCreditCardChange expected_change( + AutofillCreditCardChange::ADD, card.guid(), &card); EXPECT_CALL( *observer_helper_->observer(), Observe( - NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED_GUID), + NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED), Source<WebDataService>(wds_.get()), - Property(&Details<const AutofillCreditCardChangeGUID>::ptr, + Property(&Details<const AutofillCreditCardChange>::ptr, Pointee(expected_change)))). WillOnce(SignalEvent(&done_event_)); - wds_->AddCreditCardGUID(card); + wds_->AddCreditCard(card); done_event_.TimedWait(test_timeout_); // Check that it was added. @@ -453,13 +399,13 @@ TEST_F(WebDataServiceAutofillTest, CreditAddGUID) { STLDeleteElements(&consumer.result()); } -TEST_F(WebDataServiceAutofillTest, CreditCardRemoveGUID) { +TEST_F(WebDataServiceAutofillTest, CreditCardRemove) { CreditCard credit_card; // Add a credit card. EXPECT_CALL(*observer_helper_->observer(), Observe(_, _, _)). WillOnce(SignalEvent(&done_event_)); - wds_->AddCreditCardGUID(credit_card); + wds_->AddCreditCard(credit_card); done_event_.TimedWait(test_timeout_); // Check that it was added. @@ -472,17 +418,17 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemoveGUID) { STLDeleteElements(&consumer.result()); // Remove the credit card. - const AutofillCreditCardChangeGUID expected_change( - AutofillCreditCardChangeGUID::REMOVE, credit_card.guid(), NULL); + const AutofillCreditCardChange expected_change( + AutofillCreditCardChange::REMOVE, credit_card.guid(), NULL); EXPECT_CALL( *observer_helper_->observer(), Observe( - NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED_GUID), + NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED), Source<WebDataService>(wds_.get()), - Property(&Details<const AutofillCreditCardChangeGUID>::ptr, + Property(&Details<const AutofillCreditCardChange>::ptr, Pointee(expected_change)))). WillOnce(SignalEvent(&done_event_)); - wds_->RemoveCreditCardGUID(credit_card.guid()); + wds_->RemoveCreditCard(credit_card.guid()); done_event_.TimedWait(test_timeout_); // Check that it was removed. @@ -493,7 +439,7 @@ TEST_F(WebDataServiceAutofillTest, CreditCardRemoveGUID) { ASSERT_EQ(0U, consumer2.result().size()); } -TEST_F(WebDataServiceAutofillTest, CreditUpdateGUID) { +TEST_F(WebDataServiceAutofillTest, CreditUpdate) { CreditCard card1; card1.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Abe")); CreditCard card2; @@ -503,8 +449,8 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdateGUID) { Times(2). WillOnce(DoDefault()). WillOnce(SignalEvent(&done_event_)); - wds_->AddCreditCardGUID(card1); - wds_->AddCreditCardGUID(card2); + wds_->AddCreditCard(card1); + wds_->AddCreditCard(card2); done_event_.TimedWait(test_timeout_); // Check that they got added. @@ -519,19 +465,19 @@ TEST_F(WebDataServiceAutofillTest, CreditUpdateGUID) { CreditCard card1_changed(card1); card1_changed.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Bill")); - const AutofillCreditCardChangeGUID expected_change( - AutofillCreditCardChangeGUID::UPDATE, card1.guid(), &card1_changed); + const AutofillCreditCardChange expected_change( + AutofillCreditCardChange::UPDATE, card1.guid(), &card1_changed); EXPECT_CALL( *observer_helper_->observer(), Observe( - NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED_GUID), + NotificationType(NotificationType::AUTOFILL_CREDIT_CARD_CHANGED), Source<WebDataService>(wds_.get()), - Property(&Details<const AutofillCreditCardChangeGUID>::ptr, + Property(&Details<const AutofillCreditCardChange>::ptr, Pointee(expected_change)))). WillOnce(SignalEvent(&done_event_)); - wds_->UpdateCreditCardGUID(card1_changed); + wds_->UpdateCreditCard(card1_changed); done_event_.TimedWait(test_timeout_); // Check that the updates were made. diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc index 6f510c6..d97698a 100644 --- a/chrome/browser/webdata/web_database.cc +++ b/chrome/browser/webdata/web_database.cc @@ -292,7 +292,8 @@ AutoFillProfile* AutoFillProfileFromStatement(const sql::Statement& s) { AutoFillProfile* profile = new AutoFillProfile; profile->set_guid(s.ColumnString(0)); DCHECK(guid::IsValidGUID(profile->guid())); - profile->set_label(s.ColumnString16(1)); + // TODO(dhollowa): remove label from |autofill_profiles| table. + // Column 1 is label. profile->SetInfo(AutoFillType(NAME_FIRST), s.ColumnString16(2)); @@ -350,7 +351,8 @@ CreditCard* CreditCardFromStatement(const sql::Statement& s) { credit_card->set_guid(s.ColumnString(0)); DCHECK(guid::IsValidGUID(credit_card->guid())); - credit_card->set_label(s.ColumnString16(1)); + // TODO(dhollowa): remove label from |credit_cards| table. + // Column 1 is label. credit_card->SetInfo(AutoFillType(CREDIT_CARD_NAME), s.ColumnString16(2)); @@ -1624,31 +1626,8 @@ bool WebDatabase::AddAutoFillProfile(const AutoFillProfile& profile) { return s.Succeeded(); } -bool WebDatabase::GetAutoFillProfileForLabel(const string16& label, - AutoFillProfile** profile) { - DCHECK(profile); - sql::Statement s(db_.GetUniqueStatement( - "SELECT guid, label, first_name, middle_name, last_name, email, " - "company_name, address_line_1, address_line_2, city, state, zipcode, " - "country, phone, fax, date_modified " - "FROM autofill_profiles " - "WHERE label = ?")); - if (!s) { - NOTREACHED() << "Statement prepare failed"; - return false; - } - - s.BindString16(0, label); - if (!s.Step()) - return false; - - *profile = AutoFillProfileFromStatement(s); - - return s.Succeeded(); -} - -bool WebDatabase::GetAutoFillProfileForGUID(const std::string& guid, - AutoFillProfile** profile) { +bool WebDatabase::GetAutoFillProfile(const std::string& guid, + AutoFillProfile** profile) { DCHECK(guid::IsValidGUID(guid)); DCHECK(profile); sql::Statement s(db_.GetUniqueStatement( @@ -1696,7 +1675,7 @@ bool WebDatabase::UpdateAutoFillProfile(const AutoFillProfile& profile) { DCHECK(guid::IsValidGUID(profile.guid())); AutoFillProfile* tmp_profile = NULL; - if (!GetAutoFillProfileForGUID(profile.guid(), &tmp_profile)) + if (!GetAutoFillProfile(profile.guid(), &tmp_profile)) return false; // Preserve appropriate modification dates by not updating unchanged profiles. @@ -1758,29 +1737,7 @@ bool WebDatabase::AddCreditCard(const CreditCard& credit_card) { return s.Succeeded(); } -bool WebDatabase::GetCreditCardForLabel(const string16& label, - CreditCard** credit_card) { - DCHECK(credit_card); - sql::Statement s(db_.GetUniqueStatement( - "SELECT guid, label, name_on_card, expiration_month, expiration_year, " - "card_number_encrypted, date_modified " - "FROM credit_cards " - "WHERE label = ?")); - if (!s) { - NOTREACHED() << "Statement prepare failed"; - return false; - } - - s.BindString16(0, label); - if (!s.Step()) - return false; - - *credit_card = CreditCardFromStatement(s); - - return s.Succeeded(); -} - -bool WebDatabase::GetCreditCardForGUID(const std::string& guid, +bool WebDatabase::GetCreditCard(const std::string& guid, CreditCard** credit_card) { DCHECK(guid::IsValidGUID(guid)); sql::Statement s(db_.GetUniqueStatement( @@ -1826,7 +1783,7 @@ bool WebDatabase::UpdateCreditCard(const CreditCard& credit_card) { DCHECK(guid::IsValidGUID(credit_card.guid())); CreditCard* tmp_credit_card = NULL; - if (!GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card)) + if (!GetCreditCard(credit_card.guid(), &tmp_credit_card)) return false; // Preserve appropriate modification dates by not updating unchanged cards. diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h index 0356381..49d8677 100644 --- a/chrome/browser/webdata/web_database.h +++ b/chrome/browser/webdata/web_database.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -231,15 +231,8 @@ class WebDatabase { // of the profile to remove. virtual bool RemoveAutoFillProfile(const std::string& guid); - // Retrieves a profile with label |label|. The caller owns |profile|. - // DEPRECATED: In favor of |GetAutoFillProfileForGUID(...)|. - // TODO(dhollowa): Remove labels. http://crbug.com/58813 - bool GetAutoFillProfileForLabel(const string16& label, - AutoFillProfile** profile); - // Retrieves a profile with guid |guid|. The caller owns |profile|. - bool GetAutoFillProfileForGUID(const std::string& guid, - AutoFillProfile** profile); + bool GetAutoFillProfile(const std::string& guid, AutoFillProfile** profile); // Retrieves all profiles in the database. Caller owns the returned profiles. virtual bool GetAutoFillProfiles(std::vector<AutoFillProfile*>* profiles); @@ -254,16 +247,9 @@ class WebDatabase { // credit card to remove. bool RemoveCreditCard(const std::string& guid); - // Retrieves a credit card with label |label|. The caller owns - // |credit_card_id|. - // DEPRECATED: In favor of |GetCreditCardForGUID()|. - // TODO(dhollowa): Remove labels. http://crbug.com/58813 - bool GetCreditCardForLabel(const string16& label, - CreditCard** credit_card); - // Retrieves a credit card with guid |guid|. The caller owns // |credit_card_id|. - bool GetCreditCardForGUID(const std::string& guid, CreditCard** credit_card); + bool GetCreditCard(const std::string& guid, CreditCard** credit_card); // Retrieves all credit cards in the database. Caller owns the returned // credit cards. diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc index 41489e9..0c9b758 100644 --- a/chrome/browser/webdata/web_database_unittest.cc +++ b/chrome/browser/webdata/web_database_unittest.cc @@ -1394,7 +1394,6 @@ TEST_F(WebDatabaseTest, AutoFillProfile) { // Add a 'Home' profile. AutoFillProfile home_profile; - home_profile.set_label(ASCIIToUTF16("Home")); home_profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("John")); home_profile.SetInfo(AutoFillType(NAME_MIDDLE), ASCIIToUTF16("Q.")); home_profile.SetInfo(AutoFillType(NAME_LAST), ASCIIToUTF16("Smith")); @@ -1421,11 +1420,12 @@ TEST_F(WebDatabaseTest, AutoFillProfile) { // Get the 'Home' profile. AutoFillProfile* db_profile; - ASSERT_TRUE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Home"), &db_profile)); + ASSERT_TRUE(db.GetAutoFillProfile(home_profile.guid(), &db_profile)); EXPECT_EQ(home_profile, *db_profile); sql::Statement s_home(db.db_.GetUniqueStatement( "SELECT date_modified " - "FROM autofill_profiles WHERE label='Home'")); + "FROM autofill_profiles WHERE guid=?")); + s_home.BindString(0, home_profile.guid()); ASSERT_TRUE(s_home); ASSERT_TRUE(s_home.Step()); EXPECT_GE(s_home.ColumnInt64(0), pre_creation_time.ToTimeT()); @@ -1435,23 +1435,22 @@ TEST_F(WebDatabaseTest, AutoFillProfile) { // Add a 'Billing' profile. AutoFillProfile billing_profile = home_profile; - billing_profile.set_label(ASCIIToUTF16("Billing")); + billing_profile.set_guid(guid::GenerateGUID()); billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), ASCIIToUTF16("5678 Bottom Street")); billing_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), ASCIIToUTF16("suite 3")); - billing_profile.set_guid(guid::GenerateGUID()); pre_creation_time = Time::Now(); EXPECT_TRUE(db.AddAutoFillProfile(billing_profile)); post_creation_time = Time::Now(); // Get the 'Billing' profile. - ASSERT_TRUE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Billing"), - &db_profile)); + ASSERT_TRUE(db.GetAutoFillProfile(billing_profile.guid(), &db_profile)); EXPECT_EQ(billing_profile, *db_profile); sql::Statement s_billing(db.db_.GetUniqueStatement( - "SELECT date_modified FROM autofill_profiles WHERE label='Billing'")); + "SELECT date_modified FROM autofill_profiles WHERE guid=?")); + s_billing.BindString(0, billing_profile.guid()); ASSERT_TRUE(s_billing); ASSERT_TRUE(s_billing.Step()); EXPECT_GE(s_billing.ColumnInt64(0), pre_creation_time.ToTimeT()); @@ -1464,11 +1463,11 @@ TEST_F(WebDatabaseTest, AutoFillProfile) { Time pre_modification_time = Time::Now(); EXPECT_TRUE(db.UpdateAutoFillProfile(billing_profile)); Time post_modification_time = Time::Now(); - ASSERT_TRUE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Billing"), - &db_profile)); + ASSERT_TRUE(db.GetAutoFillProfile(billing_profile.guid(), &db_profile)); EXPECT_EQ(billing_profile, *db_profile); sql::Statement s_billing_updated(db.db_.GetUniqueStatement( - "SELECT date_modified FROM autofill_profiles WHERE label='Billing'")); + "SELECT date_modified FROM autofill_profiles WHERE guid=?")); + s_billing_updated.BindString(0, billing_profile.guid()); ASSERT_TRUE(s_billing_updated); ASSERT_TRUE(s_billing_updated.Step()); EXPECT_GE(s_billing_updated.ColumnInt64(0), @@ -1480,36 +1479,7 @@ TEST_F(WebDatabaseTest, AutoFillProfile) { // Remove the 'Billing' profile. EXPECT_TRUE(db.RemoveAutoFillProfile(billing_profile.guid())); - EXPECT_FALSE(db.GetAutoFillProfileForLabel(ASCIIToUTF16("Billing"), - &db_profile)); - - // Add a 'GUID' profile. - AutoFillProfile guid_profile = home_profile; - guid_profile.set_label(ASCIIToUTF16("GUID")); - guid_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), - ASCIIToUTF16("5678 Top Street")); - guid_profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), - ASCIIToUTF16("suite 4")); - guid_profile.set_guid(guid::GenerateGUID()); - - EXPECT_TRUE(db.AddAutoFillProfile(guid_profile)); - ASSERT_TRUE(db.GetAutoFillProfileForGUID(guid_profile.guid(), - &db_profile)); - EXPECT_EQ(guid_profile, *db_profile); - delete db_profile; - - // Update the 'GUID' profile. - guid_profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("Jimmy")); - EXPECT_TRUE(db.UpdateAutoFillProfile(guid_profile)); - ASSERT_TRUE(db.GetAutoFillProfileForGUID(guid_profile.guid(), - &db_profile)); - EXPECT_EQ(guid_profile, *db_profile); - delete db_profile; - - // Remove the 'GUID' profile. - EXPECT_TRUE(db.RemoveAutoFillProfile(guid_profile.guid())); - EXPECT_FALSE(db.GetAutoFillProfileForGUID(guid_profile.guid(), - &db_profile)); + EXPECT_FALSE(db.GetAutoFillProfile(billing_profile.guid(), &db_profile)); } TEST_F(WebDatabaseTest, CreditCard) { @@ -1519,7 +1489,6 @@ TEST_F(WebDatabaseTest, CreditCard) { // Add a 'Work' credit card. CreditCard work_creditcard; - work_creditcard.set_label(ASCIIToUTF16("Work")); work_creditcard.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Jack Torrance")); work_creditcard.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), @@ -1535,12 +1504,13 @@ TEST_F(WebDatabaseTest, CreditCard) { // Get the 'Work' credit card. CreditCard* db_creditcard; - ASSERT_TRUE(db.GetCreditCardForLabel(ASCIIToUTF16("Work"), &db_creditcard)); + ASSERT_TRUE(db.GetCreditCard(work_creditcard.guid(), &db_creditcard)); EXPECT_EQ(work_creditcard, *db_creditcard); sql::Statement s_work(db.db_.GetUniqueStatement( "SELECT guid, label, name_on_card, expiration_month, expiration_year, " "card_number_encrypted, date_modified " - "FROM credit_cards WHERE label='Work'")); + "FROM credit_cards WHERE guid=?")); + s_work.BindString(0, work_creditcard.guid()); ASSERT_TRUE(s_work); ASSERT_TRUE(s_work.Step()); EXPECT_GE(s_work.ColumnInt64(6), pre_creation_time.ToTimeT()); @@ -1550,7 +1520,6 @@ TEST_F(WebDatabaseTest, CreditCard) { // Add a 'Target' credit card. CreditCard target_creditcard; - target_creditcard.set_label(ASCIIToUTF16("Target")); target_creditcard.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Jack Torrance")); target_creditcard.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), @@ -1563,13 +1532,13 @@ TEST_F(WebDatabaseTest, CreditCard) { pre_creation_time = Time::Now(); EXPECT_TRUE(db.AddCreditCard(target_creditcard)); post_creation_time = Time::Now(); - ASSERT_TRUE(db.GetCreditCardForLabel(ASCIIToUTF16("Target"), - &db_creditcard)); + ASSERT_TRUE(db.GetCreditCard(target_creditcard.guid(), &db_creditcard)); EXPECT_EQ(target_creditcard, *db_creditcard); sql::Statement s_target(db.db_.GetUniqueStatement( "SELECT guid, label, name_on_card, expiration_month, expiration_year, " "card_number_encrypted, date_modified " - "FROM credit_cards WHERE label='Target'")); + "FROM credit_cards WHERE guid=?")); + s_target.BindString(0, target_creditcard.guid()); ASSERT_TRUE(s_target); ASSERT_TRUE(s_target.Step()); EXPECT_GE(s_target.ColumnInt64(6), pre_creation_time.ToTimeT()); @@ -1583,12 +1552,13 @@ TEST_F(WebDatabaseTest, CreditCard) { Time pre_modification_time = Time::Now(); EXPECT_TRUE(db.UpdateCreditCard(target_creditcard)); Time post_modification_time = Time::Now(); - ASSERT_TRUE(db.GetCreditCardForLabel(ASCIIToUTF16("Target"), &db_creditcard)); + ASSERT_TRUE(db.GetCreditCard(target_creditcard.guid(), &db_creditcard)); EXPECT_EQ(target_creditcard, *db_creditcard); sql::Statement s_target_updated(db.db_.GetUniqueStatement( "SELECT guid, label, name_on_card, expiration_month, expiration_year, " "card_number_encrypted, date_modified " - "FROM credit_cards WHERE label='Target'")); + "FROM credit_cards WHERE guid=?")); + s_target_updated.BindString(0, target_creditcard.guid()); ASSERT_TRUE(s_target_updated); ASSERT_TRUE(s_target_updated.Step()); EXPECT_GE(s_target_updated.ColumnInt64(6), @@ -1600,39 +1570,7 @@ TEST_F(WebDatabaseTest, CreditCard) { // Remove the 'Target' credit card. EXPECT_TRUE(db.RemoveCreditCard(target_creditcard.guid())); - EXPECT_FALSE(db.GetCreditCardForLabel(ASCIIToUTF16("Target"), - &db_creditcard)); - - // Add a 'GUID' profile. - CreditCard guid_creditcard; - guid_creditcard.set_label(ASCIIToUTF16("GUID")); - guid_creditcard.SetInfo(AutoFillType(CREDIT_CARD_NAME), - ASCIIToUTF16("Jimmy Jones")); - guid_creditcard.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), - ASCIIToUTF16("9999222233334444")); - guid_creditcard.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), - ASCIIToUTF16("07")); - guid_creditcard.SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), - ASCIIToUTF16("2013")); - - EXPECT_TRUE(db.AddCreditCard(guid_creditcard)); - ASSERT_TRUE(db.GetCreditCardForGUID(guid_creditcard.guid(), - &db_creditcard)); - EXPECT_EQ(guid_creditcard, *db_creditcard); - delete db_creditcard; - - // Update the 'GUID' profile. - guid_creditcard.SetInfo(AutoFillType(CREDIT_CARD_NAME), - ASCIIToUTF16("Jimmy Grady")); - EXPECT_TRUE(db.UpdateCreditCard(guid_creditcard)); - ASSERT_TRUE(db.GetCreditCardForGUID(guid_creditcard.guid(), &db_creditcard)); - EXPECT_EQ(guid_creditcard, *db_creditcard); - delete db_creditcard; - - // Remove the 'GUID' profile. - EXPECT_TRUE(db.RemoveCreditCard(guid_creditcard.guid())); - EXPECT_FALSE(db.GetCreditCardForGUID(guid_creditcard.guid(), - &db_creditcard)); + EXPECT_FALSE(db.GetCreditCard(target_creditcard.guid(), &db_creditcard)); } TEST_F(WebDatabaseTest, UpdateAutoFillProfile) { @@ -1641,7 +1579,6 @@ TEST_F(WebDatabaseTest, UpdateAutoFillProfile) { // Add a profile to the db. AutoFillProfile profile; - profile.set_label(ASCIIToUTF16("Test Profile")); profile.SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16("John")); profile.SetInfo(AutoFillType(NAME_MIDDLE), ASCIIToUTF16("Q.")); profile.SetInfo(AutoFillType(NAME_LAST), ASCIIToUTF16("Smith")); @@ -1670,7 +1607,7 @@ TEST_F(WebDatabaseTest, UpdateAutoFillProfile) { // Get the profile. AutoFillProfile* tmp_profile; - ASSERT_TRUE(db.GetAutoFillProfileForGUID(profile.guid(), &tmp_profile)); + ASSERT_TRUE(db.GetAutoFillProfile(profile.guid(), &tmp_profile)); scoped_ptr<AutoFillProfile> db_profile(tmp_profile); EXPECT_EQ(profile, *db_profile); sql::Statement s_original(db.db_.GetUniqueStatement( @@ -1686,7 +1623,7 @@ TEST_F(WebDatabaseTest, UpdateAutoFillProfile) { db.UpdateAutoFillProfile(profile); // Get the profile. - ASSERT_TRUE(db.GetAutoFillProfileForGUID(profile.guid(), &tmp_profile)); + ASSERT_TRUE(db.GetAutoFillProfile(profile.guid(), &tmp_profile)); db_profile.reset(tmp_profile); EXPECT_EQ(profile, *db_profile); sql::Statement s_updated(db.db_.GetUniqueStatement( @@ -1709,7 +1646,7 @@ TEST_F(WebDatabaseTest, UpdateAutoFillProfile) { db.UpdateAutoFillProfile(profile); // Get the profile. - ASSERT_TRUE(db.GetAutoFillProfileForGUID(profile.guid(), &tmp_profile)); + ASSERT_TRUE(db.GetAutoFillProfile(profile.guid(), &tmp_profile)); db_profile.reset(tmp_profile); EXPECT_EQ(profile, *db_profile); sql::Statement s_unchanged(db.db_.GetUniqueStatement( @@ -1726,7 +1663,6 @@ TEST_F(WebDatabaseTest, UpdateCreditCard) { // Add a credit card to the db. CreditCard credit_card; - credit_card.set_label(ASCIIToUTF16("Test Credit Card")); credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), ASCIIToUTF16("Jack Torrance")); credit_card.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), @@ -1747,7 +1683,7 @@ TEST_F(WebDatabaseTest, UpdateCreditCard) { // Get the credit card. CreditCard* tmp_credit_card; - ASSERT_TRUE(db.GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card)); + ASSERT_TRUE(db.GetCreditCard(credit_card.guid(), &tmp_credit_card)); scoped_ptr<CreditCard> db_credit_card(tmp_credit_card); EXPECT_EQ(credit_card, *db_credit_card); sql::Statement s_original(db.db_.GetUniqueStatement( @@ -1763,7 +1699,7 @@ TEST_F(WebDatabaseTest, UpdateCreditCard) { db.UpdateCreditCard(credit_card); // Get the credit card. - ASSERT_TRUE(db.GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card)); + ASSERT_TRUE(db.GetCreditCard(credit_card.guid(), &tmp_credit_card)); db_credit_card.reset(tmp_credit_card); EXPECT_EQ(credit_card, *db_credit_card); sql::Statement s_updated(db.db_.GetUniqueStatement( @@ -1786,7 +1722,7 @@ TEST_F(WebDatabaseTest, UpdateCreditCard) { db.UpdateCreditCard(credit_card); // Get the profile. - ASSERT_TRUE(db.GetCreditCardForGUID(credit_card.guid(), &tmp_credit_card)); + ASSERT_TRUE(db.GetCreditCard(credit_card.guid(), &tmp_credit_card)); db_credit_card.reset(tmp_credit_card); EXPECT_EQ(credit_card, *db_credit_card); sql::Statement s_unchanged(db.db_.GetUniqueStatement( |