| Index: chrome/browser/autocomplete_history_manager.cc
|
| diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc
|
| index b7202d147e97d329111a509108ea48fb5272fce3..b287c89c403a4691591d47a539af0cf7ae4e6d84 100644
|
| --- a/chrome/browser/autocomplete_history_manager.cc
|
| +++ b/chrome/browser/autocomplete_history_manager.cc
|
| @@ -134,44 +134,31 @@ bool AutocompleteHistoryManager::OnMessageReceived(
|
| return handled;
|
| }
|
|
|
| -void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) {
|
| - if (!*autofill_enabled_)
|
| - return;
|
| +void AutocompleteHistoryManager::OnWebDataServiceRequestDone(
|
| + WebDataService::Handle h,
|
| + const WDTypedResult* result) {
|
| + DCHECK(pending_query_handle_);
|
| + pending_query_handle_ = 0;
|
|
|
| - if (profile_->IsOffTheRecord())
|
| + if (!*autofill_enabled_) {
|
| + SendSuggestions(NULL);
|
| return;
|
| + }
|
|
|
| - // Don't save data that was submitted through JavaScript.
|
| - if (!form.user_submitted)
|
| + DCHECK(result);
|
| + // Returning early here if |result| is NULL. We've seen this happen on
|
| + // Linux due to NFS dismounting and causing sql failures.
|
| + // See http://crbug.com/68783.
|
| + if (!result) {
|
| + SendSuggestions(NULL);
|
| return;
|
| -
|
| - // We put the following restriction on stored FormFields:
|
| - // - non-empty name
|
| - // - non-empty value
|
| - // - text field
|
| - // - value is not a credit card number
|
| - // - value is not a SSN
|
| - std::vector<FormField> values;
|
| - for (std::vector<FormField>::const_iterator iter =
|
| - form.fields.begin();
|
| - iter != form.fields.end(); ++iter) {
|
| - if (!iter->value.empty() &&
|
| - !iter->name.empty() &&
|
| - IsTextField(*iter) &&
|
| - !CreditCard::IsValidCreditCardNumber(iter->value) &&
|
| - !IsSSN(iter->value)) {
|
| - values.push_back(*iter);
|
| - }
|
| }
|
|
|
| - if (!values.empty() && web_data_service_.get())
|
| - web_data_service_->AddFormFields(values);
|
| -}
|
| -
|
| -void AutocompleteHistoryManager::OnRemoveAutocompleteEntry(
|
| - const string16& name, const string16& value) {
|
| - if (web_data_service_.get())
|
| - web_data_service_->RemoveFormValueForElementName(name, value);
|
| + DCHECK_EQ(AUTOFILL_VALUE_RESULT, result->GetType());
|
| + const WDResult<std::vector<string16> >* autofill_result =
|
| + static_cast<const WDResult<std::vector<string16> >*>(result);
|
| + std::vector<string16> suggestions = autofill_result->GetValue();
|
| + SendSuggestions(&suggestions);
|
| }
|
|
|
| void AutocompleteHistoryManager::OnGetAutocompleteSuggestions(
|
| @@ -200,31 +187,44 @@ void AutocompleteHistoryManager::OnGetAutocompleteSuggestions(
|
| }
|
| }
|
|
|
| -void AutocompleteHistoryManager::OnWebDataServiceRequestDone(
|
| - WebDataService::Handle h,
|
| - const WDTypedResult* result) {
|
| - DCHECK(pending_query_handle_);
|
| - pending_query_handle_ = 0;
|
| +void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) {
|
| + if (!*autofill_enabled_)
|
| + return;
|
|
|
| - if (!*autofill_enabled_) {
|
| - SendSuggestions(NULL);
|
| + if (profile_->IsOffTheRecord())
|
| return;
|
| - }
|
|
|
| - DCHECK(result);
|
| - // Returning early here if |result| is NULL. We've seen this happen on
|
| - // Linux due to NFS dismounting and causing sql failures.
|
| - // See http://crbug.com/68783.
|
| - if (!result) {
|
| - SendSuggestions(NULL);
|
| + // Don't save data that was submitted through JavaScript.
|
| + if (!form.user_submitted)
|
| return;
|
| +
|
| + // We put the following restriction on stored FormFields:
|
| + // - non-empty name
|
| + // - non-empty value
|
| + // - text field
|
| + // - value is not a credit card number
|
| + // - value is not a SSN
|
| + std::vector<FormField> values;
|
| + for (std::vector<FormField>::const_iterator iter =
|
| + form.fields.begin();
|
| + iter != form.fields.end(); ++iter) {
|
| + if (!iter->value.empty() &&
|
| + !iter->name.empty() &&
|
| + IsTextField(*iter) &&
|
| + !CreditCard::IsValidCreditCardNumber(iter->value) &&
|
| + !IsSSN(iter->value)) {
|
| + values.push_back(*iter);
|
| + }
|
| }
|
|
|
| - DCHECK_EQ(AUTOFILL_VALUE_RESULT, result->GetType());
|
| - const WDResult<std::vector<string16> >* autofill_result =
|
| - static_cast<const WDResult<std::vector<string16> >*>(result);
|
| - std::vector<string16> suggestions = autofill_result->GetValue();
|
| - SendSuggestions(&suggestions);
|
| + if (!values.empty() && web_data_service_.get())
|
| + web_data_service_->AddFormFields(values);
|
| +}
|
| +
|
| +void AutocompleteHistoryManager::OnRemoveAutocompleteEntry(
|
| + const string16& name, const string16& value) {
|
| + if (web_data_service_.get())
|
| + web_data_service_->RemoveFormValueForElementName(name, value);
|
| }
|
|
|
| void AutocompleteHistoryManager::SetExternalDelegate(
|
|
|