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

Unified Diff: chrome/browser/autofill/personal_data_manager.cc

Issue 2975003: Makes the auto fill dialogs match the mocks. (Closed)
Patch Set: Moves function declarations out of autofill_dialog.h Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/autofill/personal_data_manager.h ('k') | chrome/browser/gtk/keyword_editor_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/personal_data_manager.cc
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index c138e5c8f67e9e158f54ff5017618c878a621635..3253bf7e7bf07dcc0baedf87cb9ab493148b860d 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -59,16 +59,7 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
// If both requests have responded, then all personal data is loaded.
if (pending_profiles_query_ == 0 && pending_creditcards_query_ == 0) {
is_data_loaded_ = true;
- // Copy is needed as observer can unsubscribe itself when notified.
- std::vector<PersonalDataManager::Observer*> temporary_copy;
- temporary_copy.resize(observers_.size());
- std::copy(observers_.begin(), observers_.end(), temporary_copy.begin());
- for (std::vector<PersonalDataManager::Observer*>::iterator
- iter = temporary_copy.begin();
- iter != temporary_copy.end();
- ++iter) {
- (*iter)->OnPersonalDataLoaded();
- }
+ FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataLoaded());
}
}
@@ -91,29 +82,15 @@ void PersonalDataManager::OnAutoFillDialogApply(
}
void PersonalDataManager::SetObserver(PersonalDataManager::Observer* observer) {
- for (std::vector<PersonalDataManager::Observer*>::iterator
- iter = observers_.begin();
- iter != observers_.end();
- ++iter) {
- if (*iter == observer) {
- // Already have this observer.
- return;
- }
- }
- observers_.push_back(observer);
+ // TODO: RemoveObserver is for compatability with old code, it should be
+ // nuked.
+ observers_.RemoveObserver(observer);
+ observers_.AddObserver(observer);
}
void PersonalDataManager::RemoveObserver(
PersonalDataManager::Observer* observer) {
- for (std::vector<PersonalDataManager::Observer*>::iterator
- iter = observers_.begin();
- iter != observers_.end();
- ++iter) {
- if (*iter == observer) {
- observers_.erase(iter);
- return;
- }
- }
+ observers_.RemoveObserver(observer);
}
bool PersonalDataManager::ImportFormData(
@@ -298,6 +275,8 @@ void PersonalDataManager::SetProfiles(std::vector<AutoFillProfile>* profiles) {
// Read our writes to ensure consistency with the database.
Refresh();
+
+ FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged());
}
void PersonalDataManager::SetCreditCards(
@@ -361,6 +340,8 @@ void PersonalDataManager::SetCreditCards(
iter != credit_cards->end(); ++iter) {
credit_cards_.push_back(new CreditCard(*iter));
}
+
+ FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged());
}
void PersonalDataManager::GetPossibleFieldTypes(const string16& text,
« no previous file with comments | « chrome/browser/autofill/personal_data_manager.h ('k') | chrome/browser/gtk/keyword_editor_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698