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

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

Issue 1902003: Revert 46424 - AutoFill profile shouldn't be saved when cancelled during init... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 8 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/personal_data_manager.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 46425)
+++ chrome/browser/autofill/autofill_manager.cc (working copy)
@@ -48,6 +48,9 @@
}
AutoFillManager::~AutoFillManager() {
+ // This is NULL in the MockAutoFillManager.
+ if (personal_data_)
+ personal_data_->RemoveObserver(this);
download_manager_.SetObserver(NULL);
}
@@ -261,6 +264,24 @@
return true;
}
+void AutoFillManager::OnPersonalDataLoaded() {
+ // We might have been alerted that the PersonalDataManager has loaded, so
+ // remove ourselves as observer.
+ personal_data_->RemoveObserver(this);
+
+#if !defined(OS_WIN)
+#if defined(OS_MACOSX)
+ ShowAutoFillDialog(personal_data_,
+ personal_data_->web_profiles(),
+ personal_data_->credit_cards(),
+ tab_contents_->profile()->GetOriginalProfile());
+#else // defined(OS_MACOSX)
+ ShowAutoFillDialog(NULL, personal_data_,
+ tab_contents_->profile()->GetOriginalProfile());
+#endif // defined(OS_MACOSX)
+#endif // !defined(OS_WIN)
+}
+
void AutoFillManager::OnInfoBarClosed() {
PrefService* prefs = tab_contents_->profile()->GetPrefs();
prefs->SetBoolean(prefs::kAutoFillEnabled, true);
@@ -274,18 +295,20 @@
prefs->SetBoolean(prefs::kAutoFillEnabled, true);
// This is the first time the user is interacting with AutoFill, so set the
- // uploaded form structure as the initial profile and credit card in the
- // AutoFillDialog.
- AutoFillProfile* profile = NULL;
- CreditCard* credit_card = NULL;
- // TODO(dhollowa) Now that we aren't immediately saving the imported form
- // data, we should store the profile and CC in the AFM instead of the PDM.
- personal_data_->GetImportedFormData(&profile, &credit_card);
- ShowAutoFillDialog(tab_contents_->GetContentNativeView(),
- personal_data_,
- tab_contents_->profile()->GetOriginalProfile(),
- profile,
- credit_card);
+ // uploaded form structure as the initial profile in the AutoFillDialog.
+ personal_data_->SaveImportedFormData();
+
+#if defined(OS_WIN)
+ ShowAutoFillDialog(tab_contents_->GetContentNativeView(), personal_data_,
+ tab_contents_->profile()->GetOriginalProfile());
+#else
+ // 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();
+#endif
}
void AutoFillManager::OnInfoBarCancelled() {
« no previous file with comments | « chrome/browser/autofill/autofill_manager.h ('k') | chrome/browser/autofill/personal_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698