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

Unified Diff: chrome/browser/renderer_host/render_view_host.cc

Issue 4591001: Display a warning when autofill is disabled for a website. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile on ChromeOS... Created 10 years, 1 month 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/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?
// 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_,
« no previous file with comments | « chrome/browser/renderer_host/render_view_host.h ('k') | chrome/browser/renderer_host/render_view_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698