summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_view.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-02 19:05:18 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-02 19:05:18 +0000
commit18ca9a6b5204d915324ea5a8903593e06e81562b (patch)
treedec993bd8ca4c5138b3c1cf8c737512bb341863e /chrome/renderer/render_view.cc
parent286e660b3175cf308d0c76e38392aa05b9b21c9a (diff)
downloadchromium_src-18ca9a6b5204d915324ea5a8903593e06e81562b.zip
chromium_src-18ca9a6b5204d915324ea5a8903593e06e81562b.tar.gz
chromium_src-18ca9a6b5204d915324ea5a8903593e06e81562b.tar.bz2
AutoFill: Preview form field values when the user changes the AutoFill dropdown
selection. Refactor form field enumeration into ForEachMatchingFormField(). BUG=38582 TEST=FormManagerTest.PreviewForm Review URL: http://codereview.chromium.org/2138005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view.cc')
-rwxr-xr-xchrome/renderer/render_view.cc57
1 files changed, 44 insertions, 13 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index d00d948..a37872e 100755
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -402,7 +402,8 @@ RenderView::RenderView(RenderThreadBase* render_thread,
ALLOW_THIS_IN_INITIALIZER_LIST(translate_helper_(this)),
cross_origin_access_count_(0),
same_origin_access_count_(0),
- ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) {
+ ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
+ autofill_action_(AUTOFILL_NONE) {
ClearBlockedContentSettings();
}
@@ -1505,10 +1506,17 @@ void RenderView::OnAutocompleteSuggestionsReturned(
void RenderView::OnAutoFillFormDataFilled(int query_id,
const webkit_glue::FormData& form) {
- if (query_id != autofill_query_id_)
+ if (!webview() || query_id != autofill_query_id_)
return;
- form_manager_.FillForm(form);
+ DCHECK_NE(AUTOFILL_NONE, autofill_action_);
+
+ if (autofill_action_ == AUTOFILL_FILL)
+ form_manager_.FillForm(form);
+ else if (autofill_action_ == AUTOFILL_PREVIEW)
+ form_manager_.PreviewForm(form);
+
+ autofill_action_ = AUTOFILL_NONE;
}
void RenderView::OnAllowScriptToClose(bool script_can_close) {
@@ -2030,21 +2038,26 @@ void RenderView::removeAutofillSuggestions(const WebString& name,
Send(new ViewHostMsg_RemoveAutofillEntry(routing_id_, name, value));
}
-void RenderView::didAcceptAutoFillSuggestion(
- const WebKit::WebNode& node,
- const WebKit::WebString& value,
- const WebKit::WebString& label) {
- static int query_counter = 0;
- autofill_query_id_ = query_counter++;
+void RenderView::didAcceptAutoFillSuggestion(const WebKit::WebNode& node,
+ const WebKit::WebString& value,
+ const WebKit::WebString& label) {
+ QueryAutoFillFormData(node, value, label, AUTOFILL_FILL);
+}
+
+void RenderView::didSelectAutoFillSuggestion(const WebKit::WebNode& node,
+ const WebKit::WebString& value,
+ const WebKit::WebString& label) {
+ didClearAutoFillSelection(node);
+ QueryAutoFillFormData(node, value, label, AUTOFILL_PREVIEW);
+}
+void RenderView::didClearAutoFillSelection(const WebKit::WebNode& node) {
webkit_glue::FormData form;
- const WebInputElement element = node.toConst<WebInputElement>();
+ const WebFormControlElement element = node.toConst<WebFormControlElement>();
if (!form_manager_.FindFormWithFormControlElement(
element, FormManager::REQUIRE_NONE, &form))
return;
-
- Send(new ViewHostMsg_FillAutoFillFormData(
- routing_id_, autofill_query_id_, form, value, label));
+ form_manager_.ClearPreviewedForm(form);
}
// WebKit::WebWidgetClient ----------------------------------------------------
@@ -5044,3 +5057,21 @@ bool RenderView::IsNonLocalTopLevelNavigation(
}
return false;
}
+
+void RenderView::QueryAutoFillFormData(const WebKit::WebNode& node,
+ const WebKit::WebString& value,
+ const WebKit::WebString& label,
+ AutoFillAction action) {
+ static int query_counter = 0;
+ autofill_query_id_ = query_counter++;
+
+ webkit_glue::FormData form;
+ const WebInputElement element = node.toConst<WebInputElement>();
+ if (!form_manager_.FindFormWithFormControlElement(
+ element, FormManager::REQUIRE_NONE, &form))
+ return;
+
+ autofill_action_ = action;
+ Send(new ViewHostMsg_FillAutoFillFormData(
+ routing_id_, autofill_query_id_, form, value, label));
+}