summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 02:18:28 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-16 02:18:28 +0000
commitdc9144fed7238ba56fa3f39158ef6d7267bd0a23 (patch)
treeff5adb0ff4c44ddeb3f92a8740a84aca1e38385b /chrome/browser/renderer_host
parent48dbfb25992081e5c4c35bea85bf04ff13c6d042 (diff)
downloadchromium_src-dc9144fed7238ba56fa3f39158ef6d7267bd0a23.zip
chromium_src-dc9144fed7238ba56fa3f39158ef6d7267bd0a23.tar.gz
chromium_src-dc9144fed7238ba56fa3f39158ef6d7267bd0a23.tar.bz2
Revert 66214 - Display a warning when autofill is disabled for a website.
This depends on a WebKit change being tracked at https://bugs.webkit.org/show_bug.cgi?id=49291 BUG=58509 TEST=unit_tests --gtest_filter=AutoFillManagerTest.*:AutoFillHelperTest.* Review URL: http://codereview.chromium.org/4591001 TBR=isherman@chromium.org Review URL: http://codereview.chromium.org/4985003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66220 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc53
-rw-r--r--chrome/browser/renderer_host/render_view_host.h16
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h17
3 files changed, 42 insertions, 44 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index f2bffa7..aaebf9f 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1690,27 +1690,33 @@ void RenderViewHost::OnMsgShouldCloseACK(bool proceed) {
}
void RenderViewHost::OnQueryFormFieldAutoFill(
- 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.
+ int query_id, bool form_autofilled, const webkit_glue::FormField& field) {
RenderViewHostDelegate::AutoFill* autofill_delegate =
delegate_->GetAutoFillDelegate();
- if (autofill_delegate) {
- autofill_delegate->GetAutoFillSuggestions(field_autofilled, field);
+ // 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>());
}
- // 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(field.name(),
- field.value());
+ if (autocomplete_delegate &&
+ autocomplete_delegate->GetAutocompleteSuggestions(
+ query_id, field.name(), field.value())) {
} else {
- AutocompleteSuggestionsReturned(std::vector<string16>());
+ // No suggestions provided, so send an empty vector as the results.
+ AutocompleteSuggestionsReturned(query_id, std::vector<string16>());
}
}
@@ -1764,33 +1770,24 @@ 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(
- const std::vector<string16>& values,
+ int query_id,
+ const std::vector<string16>& names,
const std::vector<string16>& labels,
const std::vector<string16>& icons,
const std::vector<int>& unique_ids) {
- autofill_values_.assign(values.begin(), values.end());
+ autofill_values_.assign(names.begin(), names.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(
- const std::vector<string16>& suggestions) {
+ int query_id, 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() &&
@@ -1809,7 +1806,7 @@ void RenderViewHost::AutocompleteSuggestionsReturned(
}
Send(new ViewMsg_AutoFillSuggestionsReturned(routing_id(),
- autofill_query_id_,
+ query_id,
autofill_values_,
autofill_labels_,
autofill_icons_,
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index ba7f552..97d1f5b 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -411,18 +411,18 @@ class RenderViewHost : public RenderWidgetHost {
// set to false when creating a renderer-initiated window via window.open.
void AllowScriptToClose(bool visible);
- // Resets the stored AutoFill state.
- void ResetAutoFillState(int query_id);
-
// Called by the AutoFillManager when the list of suggestions is ready.
- void AutoFillSuggestionsReturned(const std::vector<string16>& values,
- const std::vector<string16>& labels,
- const std::vector<string16>& icons,
- const std::vector<int>& unique_ids);
+ void AutoFillSuggestionsReturned(
+ int query_id,
+ const std::vector<string16>& values,
+ const std::vector<string16>& labels,
+ const std::vector<string16>& icons,
+ const std::vector<int>& unique_ids);
// Called by the AutocompleteHistoryManager when the list of suggestions is
// ready.
void AutocompleteSuggestionsReturned(
+ int query_id,
const std::vector<string16>& suggestions);
// Called by the AutoFillManager when the FormData has been filled out.
@@ -802,14 +802,12 @@ class RenderViewHost : public RenderWidgetHost {
// what process type we use.
bool is_extension_process_;
- // TODO(isherman): Consider splitting these off into a helper class.
// AutoFill and Autocomplete suggestions. We accumulate these separately and
// send them back to the renderer together.
std::vector<string16> autofill_values_;
std::vector<string16> autofill_labels_;
std::vector<string16> autofill_icons_;
std::vector<int> autofill_unique_ids_;
- int autofill_query_id_;
// Whether the accessibility tree should be saved, for unit testing.
bool save_accessibility_tree_for_testing_;
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index c3049e1..020fadc 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -521,7 +521,10 @@ class RenderViewHostDelegate {
// query. When the database thread is finished, the AutocompleteHistory
// manager retrieves the calling RenderViewHost and then passes the vector
// of suggestions to RenderViewHost::AutocompleteSuggestionsReturned.
- virtual void GetAutocompleteSuggestions(const string16& field_name,
+ // Returns true to indicate that FormFieldHistorySuggestionsReturned will be
+ // called.
+ virtual bool GetAutocompleteSuggestions(int query_id,
+ const string16& field_name,
const string16& user_text) = 0;
// Called when the user has indicated that she wants to remove the specified
@@ -546,13 +549,13 @@ class RenderViewHostDelegate {
virtual void FormsSeen(const std::vector<webkit_glue::FormData>& forms) = 0;
// Called to retrieve a list of AutoFill suggestions from the web database
- // given the name of the field, whether it is auto-filled, and what the user
- // has already typed in it. If there is a warning to be returned to the
- // user, it is stored into |values|, with corresponding unique id -1.
- // Returns true to indicate that RenderViewHost::AutoFillSuggestionsReturned
- // has been called.
+ // given the name of the field and what the user has already typed in the
+ // field. |form_autofilled| is true if the form containing |field| has any
+ // auto-filled fields. Returns true to indicate that
+ // RenderViewHost::AutoFillSuggestionsReturned has been called.
virtual bool GetAutoFillSuggestions(
- bool field_autofilled,
+ int query_id,
+ bool form_autofilled,
const webkit_glue::FormField& field) = 0;
// Called to fill the FormData object with AutoFill profile information that