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

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

Issue 3140026: DOMUI: Implement the 'Remove...' button on the AutoFill page. (Closed)
Patch Set: DOMUI fixes. Created 10 years, 4 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/dom_ui/autofill_options_handler.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 a058b782f4e0d62ffa73fb848f188e0369b0de5c..9e42981839f96c6e90b7dd1df6a9f59f7fc5e1ba 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -28,6 +28,28 @@ const int kMinImportSize = 3;
const char kUnlabeled[] = "Unlabeled";
+template<typename T>
+class FormGroupIDMatchesFunctor {
+ public:
+ explicit FormGroupIDMatchesFunctor(int id) : id_(id) {}
+
+ bool operator()(const T& form_group) {
+ return form_group.unique_id() == id_;
+ }
+
+ private:
+ int id_;
+};
+
+template<typename T>
+class DereferenceFunctor {
+ public:
+ template<typename T_Iterator>
+ const T& operator()(const T_Iterator& iterator) {
+ return *iterator;
+ }
+};
+
} // namespace
PersonalDataManager::~PersonalDataManager() {
@@ -83,7 +105,7 @@ void PersonalDataManager::OnAutoFillDialogApply(
}
void PersonalDataManager::SetObserver(PersonalDataManager::Observer* observer) {
- // TODO: RemoveObserver is for compatability with old code, it should be
+ // TODO: RemoveObserver is for compatibility with old code, it should be
// nuked.
observers_.RemoveObserver(observer);
observers_.AddObserver(observer);
@@ -364,6 +386,38 @@ void PersonalDataManager::SetCreditCards(
FOR_EACH_OBSERVER(Observer, observers_, OnPersonalDataChanged());
}
+void PersonalDataManager::RemoveProfile(int unique_id) {
+ // 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|.
+ profiles.erase(
+ std::remove_if(profiles.begin(), profiles.end(),
+ FormGroupIDMatchesFunctor<AutoFillProfile>(unique_id)),
+ profiles.end());
+
+ SetProfiles(&profiles);
+}
+
+void PersonalDataManager::RemoveCreditCard(int unique_id) {
+ // 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|.
+ credit_cards.erase(
+ std::remove_if(credit_cards.begin(), credit_cards.end(),
+ FormGroupIDMatchesFunctor<CreditCard>(unique_id)),
+ credit_cards.end());
+
+ SetCreditCards(&credit_cards);
+}
+
void PersonalDataManager::GetPossibleFieldTypes(const string16& text,
FieldTypeSet* possible_types) {
string16 clean_info = StringToLowerASCII(CollapseWhitespace(text, false));
« no previous file with comments | « chrome/browser/autofill/personal_data_manager.h ('k') | chrome/browser/dom_ui/autofill_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698