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

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

Issue 545175: Add the ability to save and remove AutoFill profiles from the AutoFillDialog.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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/autofill_manager.h ('k') | chrome/browser/autofill/autofill_profile.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autofill/autofill_manager.cc
===================================================================
--- chrome/browser/autofill/autofill_manager.cc (revision 36779)
+++ chrome/browser/autofill/autofill_manager.cc (working copy)
@@ -10,7 +10,6 @@
#include "chrome/browser/autofill/autofill_dialog.h"
#include "chrome/browser/autofill/autofill_infobar_delegate.h"
#include "chrome/browser/autofill/form_structure.h"
-#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
@@ -61,11 +60,26 @@
}
void AutoFillManager::OnAutoFillDialogApply(
- const std::vector<AutoFillProfile>& profiles,
- const std::vector<CreditCard>& credit_cards) {
- // TODO(jhawkins): Pass the profile data onto the PersonalDataManager.
+ std::vector<AutoFillProfile>* profiles,
+ std::vector<CreditCard>* credit_cards) {
+ // Save the personal data.
+ personal_data_->SetProfiles(profiles);
+ // TODO(jhawkins): Set the credit cards.
+
+ HandleSubmit();
}
+void AutoFillManager::OnPersonalDataLoaded() {
+ // We might have been alerted that the PersonalDataManager has loaded, so
+ // remove ourselves as observer.
+ personal_data_->RemoveObserver(this);
+
+ // TODO(jhawkins): Actually send in the real credit cards from the personal
+ // data manager.
+ std::vector<CreditCard*> credit_cards;
+ ShowAutoFillDialog(this, personal_data_->profiles(), credit_cards);
+}
+
void AutoFillManager::DeterminePossibleFieldTypes(
FormStructure* form_structure) {
// TODO(jhawkins): Update field text.
@@ -93,13 +107,12 @@
PrefService* prefs = tab_contents_->profile()->GetPrefs();
prefs->SetBoolean(prefs::kAutoFillEnabled, true);
- // TODO(jhawkins): Actually send in the real profiles and credit cards from
- // the personal data manager.
- std::vector<AutoFillProfile> profiles;
- std::vector<CreditCard> credit_cards;
- ShowAutoFillDialog(this, profiles, credit_cards);
-
- HandleSubmit();
+ // If the personal data manager has not loaded the data yet, set ourselves as
+ // its observer so that we can listen for the OnPersonalDataLoaded signal.
+ if (!personal_data_->IsDataLoaded())
+ personal_data_->SetObserver(this);
+ else
+ OnPersonalDataLoaded();
}
void AutoFillManager::SaveFormData() {
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/autofill_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698