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

Unified Diff: chrome/renderer/autofill/autofill_agent.cc

Issue 9235072: Adding Mouse Support for new GTK Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Responding to comments Created 8 years, 10 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/renderer/autofill/autofill_agent.cc
diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc
index 9130b105e71eaf0f2a001d4e6d92bdea6c459e2d..20282f1b05714fbfc4b6bdf4646f9e43a7d8ca72 100644
--- a/chrome/renderer/autofill/autofill_agent.cc
+++ b/chrome/renderer/autofill/autofill_agent.cc
@@ -76,6 +76,16 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
OnFieldTypePredictionsAvailable)
IPC_MESSAGE_HANDLER(AutofillMsg_SelectAutofillSuggestionAtIndex,
OnSelectAutofillSuggestionAtIndex)
+ IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionFill,
+ OnSetAutofillActionFill)
+ IPC_MESSAGE_HANDLER(AutofillMsg_ClearForm,
+ OnClearForm)
+ IPC_MESSAGE_HANDLER(AutofillMsg_SetAutofillActionPreview,
+ OnSetAutofillActionPreview)
+ IPC_MESSAGE_HANDLER(AutofillMsg_ClearPreviewedForm,
+ OnClearPreviewedForm)
+ IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText,
+ OnSetNodeText)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -139,6 +149,8 @@ void AutofillAgent::didAcceptAutofillSuggestion(const WebNode& node,
if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value))
return;
+ DCHECK(node == autofill_query_element_);
+
if (suggestions_options_index_ != -1 &&
index == static_cast<unsigned>(suggestions_options_index_)) {
// User selected 'Autofill Options'.
@@ -146,15 +158,10 @@ void AutofillAgent::didAcceptAutofillSuggestion(const WebNode& node,
} else if (suggestions_clear_index_ != -1 &&
index == static_cast<unsigned>(suggestions_clear_index_)) {
// User selected 'Clear form'.
- DCHECK(node == autofill_query_element_);
form_cache_.ClearFormWithElement(autofill_query_element_);
} else if (!unique_id) {
// User selected an Autocomplete entry, so we fill directly.
- WebInputElement element = node.toConst<WebInputElement>();
-
- string16 substring = value;
- substring = substring.substr(0, element.maxLength());
- element.setValue(substring, true);
+ SetNodeText(node.toConst<WebInputElement>(), value);
} else {
// Fill the values for the whole form.
FillAutofillFormData(node, unique_id, AUTOFILL_FILL);
@@ -337,6 +344,8 @@ void AutofillAgent::OnFormDataFilled(int query_id,
if (!render_view()->GetWebView() || query_id != autofill_query_id_)
return;
+ was_query_node_autofilled_ = autofill_query_element_.isAutofilled();
+
switch (autofill_action_) {
case AUTOFILL_FILL:
FillForm(form, autofill_query_element_);
@@ -344,6 +353,8 @@ void AutofillAgent::OnFormDataFilled(int query_id,
base::TimeTicks::Now()));
break;
case AUTOFILL_PREVIEW:
+ didClearAutofillSelection(autofill_query_element_);
+
PreviewForm(form, autofill_query_element_);
Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id()));
break;
@@ -366,6 +377,26 @@ void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) {
// render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex);
}
+void AutofillAgent::OnSetAutofillActionFill() {
+ autofill_action_ = AUTOFILL_FILL;
+}
+
+void AutofillAgent::OnClearForm() {
+ form_cache_.ClearFormWithElement(autofill_query_element_);
+}
+
+void AutofillAgent::OnSetAutofillActionPreview() {
+ autofill_action_ = AUTOFILL_PREVIEW;
+}
+
+void AutofillAgent::OnClearPreviewedForm() {
+ didClearAutofillSelection(autofill_query_element_);
+}
+
+void AutofillAgent::OnSetNodeText(string16 value) {
Ilya Sherman 2012/02/08 17:01:57 nit: Might as well pass the |value| by const-refer
csharp 2012/02/08 19:05:43 Done.
+ SetNodeText(autofill_query_element_, value);
+}
+
void AutofillAgent::ShowSuggestions(const WebInputElement& element,
bool autofill_on_empty_values,
bool requires_caret_at_end,
@@ -442,9 +473,15 @@ void AutofillAgent::FillAutofillFormData(const WebNode& node,
}
autofill_action_ = action;
- was_query_node_autofilled_ = field.is_autofilled;
Send(new AutofillHostMsg_FillAutofillFormData(
routing_id(), autofill_query_id_, form, field, unique_id));
}
+void AutofillAgent::SetNodeText(WebKit::WebInputElement node, string16 value) {
+ string16 substring = value;
+ substring = substring.substr(0, node.maxLength());
+
+ node.setValue(substring, true);
+}
+
} // namespace autofill
« chrome/renderer/autofill/autofill_agent.h ('K') | « chrome/renderer/autofill/autofill_agent.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698