summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 00:01:26 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 00:01:26 +0000
commit3b12395d378c0740947438ddeb770de52ad3162a (patch)
treea3573b925e0039ab60a6ad110a47b05d0ffc3cef
parente8c82c8fc20170b52ca31b1315bd78009c481373 (diff)
downloadchromium_src-3b12395d378c0740947438ddeb770de52ad3162a.zip
chromium_src-3b12395d378c0740947438ddeb770de52ad3162a.tar.gz
chromium_src-3b12395d378c0740947438ddeb770de52ad3162a.tar.bz2
autofill: Add GetProfileById function to PersonalDataManager.
BUG=None TEST=crl --enable-tabbed-options. The AutoFill options should works as before. Review URL: http://codereview.chromium.org/4015003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63450 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc9
-rw-r--r--chrome/browser/autofill/personal_data_manager.h4
-rw-r--r--chrome/browser/dom_ui/options/autofill_options_handler.cc12
3 files changed, 14 insertions, 11 deletions
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index 1833253..9b4f146 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -490,6 +490,15 @@ void PersonalDataManager::RemoveProfile(int unique_id) {
SetProfiles(&profiles);
}
+AutoFillProfile* PersonalDataManager::GetProfileById(int unique_id) {
+ for (std::vector<AutoFillProfile*>::iterator iter = web_profiles_->begin();
+ iter != web_profiles_->end(); ++iter) {
+ if ((*iter)->unique_id() == unique_id)
+ return *iter;
+ }
+ return NULL;
+}
+
// TODO(jhawkins): Refactor SetCreditCards so this isn't so hacky.
void PersonalDataManager::AddCreditCard(const CreditCard& credit_card) {
std::vector<CreditCard> credit_cards(credit_cards_.size());
diff --git a/chrome/browser/autofill/personal_data_manager.h b/chrome/browser/autofill/personal_data_manager.h
index 194c1f7..26f5b6f 100644
--- a/chrome/browser/autofill/personal_data_manager.h
+++ b/chrome/browser/autofill/personal_data_manager.h
@@ -109,6 +109,10 @@ class PersonalDataManager
// Removes the profile represented by |unique_id|.
void RemoveProfile(int unique_id);
+ // 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);
+
// Adds |credit_card| to the web database.
void AddCreditCard(const CreditCard& credit_card);
diff --git a/chrome/browser/dom_ui/options/autofill_options_handler.cc b/chrome/browser/dom_ui/options/autofill_options_handler.cc
index 68177ef..808353b 100644
--- a/chrome/browser/dom_ui/options/autofill_options_handler.cc
+++ b/chrome/browser/dom_ui/options/autofill_options_handler.cc
@@ -236,17 +236,7 @@ void AutoFillOptionsHandler::EditAddress(const ListValue* args) {
return;
}
- // TODO(jhawkins): Refactor and move this into PersonalDataManager.
- AutoFillProfile* profile = NULL;
- for (std::vector<AutoFillProfile*>::const_iterator iter =
- personal_data_->web_profiles().begin();
- iter != personal_data_->web_profiles().end(); ++iter) {
- if ((*iter)->unique_id() == unique_id) {
- profile = *iter;
- break;
- }
- }
-
+ AutoFillProfile* profile = personal_data_->GetProfileById(unique_id);
if (!profile) {
NOTREACHED();
return;