diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 23:33:51 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-03 23:33:51 +0000 |
commit | 10248566acdddeba7bb2c5d31646e0b8db335be9 (patch) | |
tree | c03407ff7fca8c84176222ff148180a1ad9c89e6 /chrome | |
parent | e3b44865e6c604327e2117c0143ea0f109fb0395 (diff) | |
download | chromium_src-10248566acdddeba7bb2c5d31646e0b8db335be9.zip chromium_src-10248566acdddeba7bb2c5d31646e0b8db335be9.tar.gz chromium_src-10248566acdddeba7bb2c5d31646e0b8db335be9.tar.bz2 |
Fix a bug that was causing the AutoFill infobar to not show. Initially the AutoFillEnabled preference is false, so we were bailing out before giving the chance to enable AutoFill. This changes to guard to |personal_data_|, which is necessary for DeterminePossibleFieldTypes.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/667018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 40 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_manager.h | 11 |
2 files changed, 26 insertions, 25 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index e95b1c6..d308ec1 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -46,7 +46,7 @@ void AutoFillManager::RegisterUserPrefs(PrefService* prefs) { void AutoFillManager::FormFieldValuesSubmitted( const webkit_glue::FormFieldValues& form) { - if (!IsAutoFillEnabled()) + if (!personal_data_) return; // Grab a copy of the form data. @@ -63,7 +63,7 @@ void AutoFillManager::FormFieldValuesSubmitted( if (!infobar_shown) { // Ask the user for permission to save form information. infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this)); - } else { + } else if (IsAutoFillEnabled()) { HandleSubmit(); } } @@ -233,6 +233,24 @@ void AutoFillManager::OnPersonalDataLoaded() { this, personal_data_->profiles(), personal_data_->credit_cards()); } +void AutoFillManager::OnInfoBarAccepted() { + DCHECK(personal_data_); + + PrefService* prefs = tab_contents_->profile()->GetPrefs(); + prefs->SetBoolean(prefs::kAutoFillEnabled, true); + + // 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::Reset() { + upload_form_structure_.reset(); +} + void AutoFillManager::DeterminePossibleFieldTypes( FormStructure* form_structure) { DCHECK(personal_data_); @@ -260,20 +278,6 @@ void AutoFillManager::HandleSubmit() { UploadFormData(); } -void AutoFillManager::OnInfoBarAccepted() { - DCHECK(personal_data_); - - PrefService* prefs = tab_contents_->profile()->GetPrefs(); - prefs->SetBoolean(prefs::kAutoFillEnabled, true); - - // 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::UploadFormData() { std::string xml; bool ok = upload_form_structure_->EncodeUploadRequest(false, &xml); @@ -282,10 +286,6 @@ void AutoFillManager::UploadFormData() { // TODO(jhawkins): Initiate the upload request thread. } -void AutoFillManager::Reset() { - upload_form_structure_.reset(); -} - bool AutoFillManager::IsAutoFillEnabled() { // The PersonalDataManager is NULL in OTR. if (!personal_data_) diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index 9263e08..ecc72d9 100644 --- a/chrome/browser/autofill/autofill_manager.h +++ b/chrome/browser/autofill/autofill_manager.h @@ -60,6 +60,12 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill, // PersonalDataManager::Observer implementation: virtual void OnPersonalDataLoaded(); + // Called by the AutoFillInfoBarDelegate when the user accepts the infobar. + virtual void OnInfoBarAccepted(); + + // Resets the stored form data. + virtual void Reset(); + // Uses heuristics and existing personal data to determine the possible field // types. void DeterminePossibleFieldTypes(FormStructure* form_structure); @@ -67,15 +73,10 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill, // Handles the form data submitted by the user. void HandleSubmit(); - // Called by the AutoFillInfoBarDelegate when the user accepts the infobar. - void OnInfoBarAccepted(); // Uploads the form data to the autofill server. void UploadFormData(); - // Resets the stored form data. - void Reset(); - // Returns the value of the AutoFillEnabled pref. bool IsAutoFillEnabled(); |