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

Unified Diff: chrome/browser/autocomplete_history_manager.cc

Issue 10073018: Add Delete Support to New Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
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(

Powered by Google App Engine
This is Rietveld 408576698