Chromium Code Reviews| Index: chrome/browser/renderer_host/render_view_host.cc |
| diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc |
| index aaebf9f9caebe95028732e3080970b7e2c848b45..f2bffa7a55e33219c49440d45e727be6edc78201 100644 |
| --- a/chrome/browser/renderer_host/render_view_host.cc |
| +++ b/chrome/browser/renderer_host/render_view_host.cc |
| @@ -1690,33 +1690,27 @@ void RenderViewHost::OnMsgShouldCloseACK(bool proceed) { |
| } |
| void RenderViewHost::OnQueryFormFieldAutoFill( |
| - int query_id, bool form_autofilled, const webkit_glue::FormField& field) { |
| + int query_id, bool field_autofilled, const webkit_glue::FormField& field) { |
| + ResetAutoFillState(query_id); |
| + |
| + // We first query the autofill delegate for suggestions. We keep track of the |
| + // results it gives us, which we will later combine with the autocomplete |
| + // suggestions. |
| RenderViewHostDelegate::AutoFill* autofill_delegate = |
| delegate_->GetAutoFillDelegate(); |
| - // We first save the AutoFill delegate's suggestions. Then we fetch the |
| - // Autocomplete delegate's suggestions and send the combined results back to |
| - // the render view. |
| - if (autofill_delegate && |
| - autofill_delegate->GetAutoFillSuggestions(query_id, |
| - form_autofilled, |
| - field)) { |
| - } else { |
| - // No suggestions provided, so supply an empty vector as the results. |
| - AutoFillSuggestionsReturned(query_id, |
| - std::vector<string16>(), |
| - std::vector<string16>(), |
| - std::vector<string16>(), |
| - std::vector<int>()); |
| + if (autofill_delegate) { |
| + autofill_delegate->GetAutoFillSuggestions(field_autofilled, field); |
| } |
| + // Now query the Autocomplete delegate for suggestions. These will be combined |
| + // with the saved autofill suggestions in |AutocompleteSuggestionsReturned()|. |
| RenderViewHostDelegate::Autocomplete* autocomplete_delegate = |
| delegate_->GetAutocompleteDelegate(); |
| - if (autocomplete_delegate && |
| - autocomplete_delegate->GetAutocompleteSuggestions( |
| - query_id, field.name(), field.value())) { |
| + if (autocomplete_delegate) { |
| + autocomplete_delegate->GetAutocompleteSuggestions(field.name(), |
| + field.value()); |
| } else { |
| - // No suggestions provided, so send an empty vector as the results. |
| - AutocompleteSuggestionsReturned(query_id, std::vector<string16>()); |
| + AutocompleteSuggestionsReturned(std::vector<string16>()); |
| } |
| } |
| @@ -1770,24 +1764,33 @@ void RenderViewHost::OnDidFillAutoFillFormData() { |
| NotificationService::NoDetails()); |
| } |
| +void RenderViewHost::ResetAutoFillState(int query_id) { |
| + autofill_query_id_ = query_id; |
| + |
| + autofill_values_.clear(); |
| + autofill_labels_.clear(); |
| + autofill_icons_.clear(); |
| + autofill_unique_ids_.clear(); |
| +} |
| + |
| void RenderViewHost::AutoFillSuggestionsReturned( |
| - int query_id, |
| - const std::vector<string16>& names, |
| + const std::vector<string16>& values, |
| const std::vector<string16>& labels, |
| const std::vector<string16>& icons, |
| const std::vector<int>& unique_ids) { |
| - autofill_values_.assign(names.begin(), names.end()); |
| + autofill_values_.assign(values.begin(), values.end()); |
| autofill_labels_.assign(labels.begin(), labels.end()); |
| autofill_icons_.assign(icons.begin(), icons.end()); |
| autofill_unique_ids_.assign(unique_ids.begin(), unique_ids.end()); |
| } |
| void RenderViewHost::AutocompleteSuggestionsReturned( |
| - int query_id, const std::vector<string16>& suggestions) { |
| + const std::vector<string16>& suggestions) { |
| // Combine AutoFill and Autocomplete values into values and labels. |
| for (size_t i = 0; i < suggestions.size(); ++i) { |
| bool unique = true; |
| for (size_t j = 0; j < autofill_values_.size(); ++j) { |
| + // TODO(isherman): Why just when the label is empty? |
|
dhollowa
2010/11/15 18:47:57
An non-empty label is sufficient to distinguish an
Ilya Sherman
2010/11/15 22:53:32
This TODO is not related to warnings, but I think
|
| // If the AutoFill label is empty, we need to make sure we don't add a |
| // duplicate value. |
| if (autofill_labels_[j].empty() && |
| @@ -1806,7 +1809,7 @@ void RenderViewHost::AutocompleteSuggestionsReturned( |
| } |
| Send(new ViewMsg_AutoFillSuggestionsReturned(routing_id(), |
| - query_id, |
| + autofill_query_id_, |
| autofill_values_, |
| autofill_labels_, |
| autofill_icons_, |