diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-28 00:28:03 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-28 00:28:03 +0000 |
commit | 8fee844e924295356c75ac88d20dd8e48638da3a (patch) | |
tree | cd6c3f572db961e7358ae4c38cebb607d7aa4c01 /chrome/browser/autofill | |
parent | f1cac0efc19086ef04f25b91b6c525da8e96f9f2 (diff) | |
download | chromium_src-8fee844e924295356c75ac88d20dd8e48638da3a.zip chromium_src-8fee844e924295356c75ac88d20dd8e48638da3a.tar.gz chromium_src-8fee844e924295356c75ac88d20dd8e48638da3a.tar.bz2 |
Autofill deprecate unique_ids in favor of guids for DOMUI
Removes use of labels and unique_ids in the Autofill options handler in DOMUI.
BUG=58813
TEST=Manual tests with DOMUI: Add, Update, and Delete both addresses and credit cards.
Review URL: http://codereview.chromium.org/4145008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64186 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/personal_data_manager.cc | 54 | ||||
-rw-r--r-- | chrome/browser/autofill/personal_data_manager.h | 20 |
2 files changed, 37 insertions, 37 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc index fe4c2ea..80f3a8d 100644 --- a/chrome/browser/autofill/personal_data_manager.cc +++ b/chrome/browser/autofill/personal_data_manager.cc @@ -26,19 +26,17 @@ namespace { // before AutoFill will attempt to import the data into a profile. const int kMinImportSize = 3; -const char kUnlabeled[] = "Unlabeled"; - template<typename T> -class FormGroupIDMatchesFunctor { +class FormGroupGUIDMatchesFunctor { public: - explicit FormGroupIDMatchesFunctor(int id) : id_(id) {} + explicit FormGroupGUIDMatchesFunctor(const std::string& guid) : guid_(guid) {} bool operator()(const T& form_group) { - return form_group.unique_id() == id_; + return form_group.guid() == guid_; } private: - int id_; + std::string guid_; }; template<typename T> @@ -234,14 +232,7 @@ void PersonalDataManager::GetImportedFormData(AutoFillProfile** profile, DCHECK(profile); DCHECK(credit_card); - if (imported_profile_.get()) { - imported_profile_->set_label(ASCIIToUTF16(kUnlabeled)); - } *profile = imported_profile_.get(); - - if (imported_credit_card_.get()) { - imported_credit_card_->set_label(ASCIIToUTF16(kUnlabeled)); - } *credit_card = imported_credit_card_.get(); } @@ -467,7 +458,12 @@ void PersonalDataManager::UpdateProfile(const AutoFillProfile& profile) { // Update the cached profile. for (std::vector<AutoFillProfile*>::iterator iter = web_profiles_->begin(); iter != web_profiles_->end(); ++iter) { - if ((*iter)->unique_id() == profile.unique_id()) { + if ((*iter)->guid() == profile.guid()) { + // TODO(dhollowa): Remove |unique_id| once GUID migration work is + // complete. Until the |WebDataService::UpdateAutoFillProfile| is changed + // to use the GUID we need to preserve the unique ID association. + // http:://crbug.com/58813 + const_cast<AutoFillProfile&>(profile).set_unique_id((*iter)->unique_id()); delete *iter; *iter = new AutoFillProfile(profile); break; @@ -478,26 +474,27 @@ void PersonalDataManager::UpdateProfile(const AutoFillProfile& profile) { FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged()); } -void PersonalDataManager::RemoveProfile(int unique_id) { +void PersonalDataManager::RemoveProfile(const std::string& guid) { // TODO(jhawkins): Refactor SetProfiles so this isn't so hacky. std::vector<AutoFillProfile> profiles(web_profiles_.size()); std::transform(web_profiles_.begin(), web_profiles_.end(), profiles.begin(), DereferenceFunctor<AutoFillProfile>()); - // Remove the profile that matches |unique_id|. + // Remove the profile that matches |guid|. profiles.erase( std::remove_if(profiles.begin(), profiles.end(), - FormGroupIDMatchesFunctor<AutoFillProfile>(unique_id)), + FormGroupGUIDMatchesFunctor<AutoFillProfile>(guid)), profiles.end()); SetProfiles(&profiles); } -AutoFillProfile* PersonalDataManager::GetProfileById(int unique_id) { +AutoFillProfile* PersonalDataManager::GetProfileByGUID( + const std::string& guid) { for (std::vector<AutoFillProfile*>::iterator iter = web_profiles_->begin(); iter != web_profiles_->end(); ++iter) { - if ((*iter)->unique_id() == unique_id) + if ((*iter)->guid() == guid) return *iter; } return NULL; @@ -522,7 +519,12 @@ void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) { // Update the cached credit card. for (std::vector<CreditCard*>::iterator iter = credit_cards_->begin(); iter != credit_cards_->end(); ++iter) { - if ((*iter)->unique_id() == credit_card.unique_id()) { + if ((*iter)->guid() == credit_card.guid()) { + // TODO(dhollowa): Remove |unique_id| once GUID migration work is + // complete. Until the |WebDataService::UpdateCreditCard| is changed + // to use the GUID we need to preserve the unique ID association. + // http:://crbug.com/58813 + const_cast<CreditCard&>(credit_card).set_unique_id((*iter)->unique_id()); delete *iter; *iter = new CreditCard(credit_card); break; @@ -533,26 +535,26 @@ void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) { FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged()); } -void PersonalDataManager::RemoveCreditCard(int unique_id) { +void PersonalDataManager::RemoveCreditCard(const std::string& guid) { // TODO(jhawkins): Refactor SetCreditCards so this isn't so hacky. std::vector<CreditCard> credit_cards(credit_cards_.size()); std::transform(credit_cards_.begin(), credit_cards_.end(), credit_cards.begin(), DereferenceFunctor<CreditCard>()); - // Remove the credit card that matches |unique_id|. + // Remove the credit card that matches |guid|. credit_cards.erase( std::remove_if(credit_cards.begin(), credit_cards.end(), - FormGroupIDMatchesFunctor<CreditCard>(unique_id)), + FormGroupGUIDMatchesFunctor<CreditCard>(guid)), credit_cards.end()); SetCreditCards(&credit_cards); } -CreditCard* PersonalDataManager::GetCreditCardById(int unique_id) { +CreditCard* PersonalDataManager::GetCreditCardByGUID(const std::string& guid) { for (std::vector<CreditCard*>::iterator iter = credit_cards_.begin(); iter != credit_cards_.end(); ++iter) { - if ((*iter)->unique_id() == unique_id) + if ((*iter)->guid() == guid) return *iter; } return NULL; @@ -800,8 +802,6 @@ void PersonalDataManager::SaveImportedCreditCard() { // Set to true if |imported_credit_card_| is merged into the profile list. bool merged = false; - imported_credit_card_->set_label(ASCIIToUTF16(kUnlabeled)); - std::vector<CreditCard> creditcards; for (std::vector<CreditCard*>::const_iterator iter = credit_cards_.begin(); diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h index 9ba06a9..5499903 100644 --- a/chrome/browser/autofill/personal_data_manager.h +++ b/chrome/browser/autofill/personal_data_manager.h @@ -106,12 +106,12 @@ class PersonalDataManager // Updates |profile| which already exists in the web database. void UpdateProfile(const AutoFillProfile& profile); - // Removes the profile represented by |unique_id|. - void RemoveProfile(int unique_id); + // Removes the profile represented by |guid|. + void RemoveProfile(const std::string& guid); - // Returns the profile with the specified |unique_id|, or NULL if there is no - // profile with the specified |unique_id|. - AutoFillProfile* GetProfileById(int unique_id); + // Returns the profile with the specified |guid|, or NULL if there is no + // profile with the specified |guid|. + AutoFillProfile* GetProfileByGUID(const std::string& guid); // Adds |credit_card| to the web database. void AddCreditCard(const CreditCard& credit_card); @@ -119,12 +119,12 @@ class PersonalDataManager // Updates |credit_card| which already exists in the web database. void UpdateCreditCard(const CreditCard& credit_card); - // Removes the credit card represented by |unique_id|. - void RemoveCreditCard(int unique_id); + // Removes the credit card represented by |guid|. + void RemoveCreditCard(const std::string& guid); - // Returns the credit card with the specified |unique_id|, or NULL if there is - // no credit card with the specified |unique_id|. - CreditCard* GetCreditCardById(int unique_id); + // Returns the credit card with the specified |guid|, or NULL if there is + // no credit card with the specified |guid|. + CreditCard* GetCreditCardByGUID(const std::string& guid); // Gets the possible field types for the given text, determined by matching // the text with all known personal information and returning matching types. |