diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-01 21:45:06 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-01 21:45:06 +0000 |
commit | 769d30f2e45c65cc8755c107c94e8419525595a1 (patch) | |
tree | c4da11e847cc0b9e34c1d61d76335d96eee1e164 | |
parent | 037944b02f2f135782fe1f4dfbf5d8a232a88c09 (diff) | |
download | chromium_src-769d30f2e45c65cc8755c107c94e8419525595a1.zip chromium_src-769d30f2e45c65cc8755c107c94e8419525595a1.tar.gz chromium_src-769d30f2e45c65cc8755c107c94e8419525595a1.tar.bz2 |
Check for a non-NULL PersonalDataManager when determining if AutoFill is enabled. The PersonalDataManager is NULL when OTR.
BUG=36938
TEST=New incognito window. gmail.com logged in. Compose mail. Type in subject line. No crash.
Review URL: http://codereview.chromium.org/661297
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40302 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/autofill_manager.cc | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 0d005aa..b83c9b4 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -44,6 +44,9 @@ void AutoFillManager::RegisterUserPrefs(PrefService* prefs) { void AutoFillManager::FormFieldValuesSubmitted( const webkit_glue::FormFieldValues& form) { + if (!IsAutoFillEnabled()) + return; + // Grab a copy of the form data. upload_form_structure_.reset(new FormStructure(form)); @@ -54,18 +57,20 @@ void AutoFillManager::FormFieldValuesSubmitted( DeterminePossibleFieldTypes(upload_form_structure_.get()); PrefService* prefs = tab_contents_->profile()->GetPrefs(); - bool autofill_enabled = prefs->GetBoolean(prefs::kAutoFillEnabled); bool infobar_shown = prefs->GetBoolean(prefs::kAutoFillInfoBarShown); - if (!infobar_shown && personal_data_) { + if (!infobar_shown) { // Ask the user for permission to save form information. infobar_.reset(new AutoFillInfoBarDelegate(tab_contents_, this)); - } else if (autofill_enabled) { + } else { HandleSubmit(); } } void AutoFillManager::FormsSeen( const std::vector<webkit_glue::FormFieldValues>& forms) { + if (!IsAutoFillEnabled()) + return; + form_structures_.reset(); for (std::vector<webkit_glue::FormFieldValues>::const_iterator iter = forms.begin(); @@ -206,6 +211,8 @@ bool AutoFillManager::FillAutoFillFormData(int query_id, void AutoFillManager::OnAutoFillDialogApply( std::vector<AutoFillProfile>* profiles, std::vector<CreditCard>* credit_cards) { + DCHECK(personal_data_); + // Save the personal data. personal_data_->SetProfiles(profiles); personal_data_->SetCreditCards(credit_cards); @@ -214,6 +221,8 @@ void AutoFillManager::OnAutoFillDialogApply( } void AutoFillManager::OnPersonalDataLoaded() { + DCHECK(personal_data_); + // We might have been alerted that the PersonalDataManager has loaded, so // remove ourselves as observer. personal_data_->RemoveObserver(this); @@ -228,10 +237,6 @@ void AutoFillManager::DeterminePossibleFieldTypes( form_structure->GetHeuristicAutoFillTypes(); - // OTR: We can't use the PersonalDataManager to help determine field types. - if (!personal_data_) - return; - for (size_t i = 0; i < form_structure->field_count(); i++) { const AutoFillField* field = form_structure->field(i); FieldTypeSet field_types; @@ -243,14 +248,15 @@ void AutoFillManager::DeterminePossibleFieldTypes( void AutoFillManager::HandleSubmit() { // If there wasn't enough data to import then we don't want to send an upload // to the server. - if (personal_data_ && - !personal_data_->ImportFormData(form_structures_.get(), this)) + if (!personal_data_->ImportFormData(form_structures_.get(), this)) return; UploadFormData(); } void AutoFillManager::OnInfoBarAccepted() { + DCHECK(personal_data_); + PrefService* prefs = tab_contents_->profile()->GetPrefs(); prefs->SetBoolean(prefs::kAutoFillEnabled, true); @@ -275,6 +281,10 @@ void AutoFillManager::Reset() { } bool AutoFillManager::IsAutoFillEnabled() { + // The PersonalDataManager is NULL in OTR. + if (!personal_data_) + return false; + PrefService* prefs = tab_contents_->profile()->GetPrefs(); // Migrate obsolete autofill pref. |