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

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

Issue 10443084: Add Datalist Support to New Autofill UI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Better Data List Tests Created 8 years, 6 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 2442899cf2c42695a5bb97b7a5923975623cdc23..d5e7256d52bec847fa31a2da786d59620d05171a 100644
--- a/chrome/renderer/autofill/autofill_agent.cc
+++ b/chrome/renderer/autofill/autofill_agent.cc
@@ -52,6 +52,10 @@ namespace {
// (so to avoid sending long strings through IPC).
const size_t kMaximumTextSizeForAutofill = 1000;
+// The maximum number of data list elements to send to the browser process
+// via IPC (to prevent long IPC messages).
+const size_t kMaximumDataListSizeForAutofill = 30;
+
void AppendDataListSuggestions(const WebKit::WebInputElement& element,
std::vector<string16>* values,
std::vector<string16>* labels,
@@ -126,6 +130,8 @@ bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
OnClearPreviewedForm)
IPC_MESSAGE_HANDLER(AutofillMsg_SetNodeText,
OnSetNodeText)
+ IPC_MESSAGE_HANDLER(AutofillMsg_AcceptDataListSuggestion,
+ OnAcceptDataListSuggestion)
IPC_MESSAGE_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
OnAcceptPasswordAutofillSuggestion)
IPC_MESSAGE_UNHANDLED(handled = false)
@@ -529,6 +535,10 @@ void AutofillAgent::OnSetNodeText(const string16& value) {
SetNodeText(value, &element_);
}
+void AutofillAgent::OnAcceptDataListSuggestion(const string16& value) {
+ AcceptDataListSuggestion(value);
+}
+
void AutofillAgent::OnAcceptPasswordAutofillSuggestion(const string16& value) {
// We need to make sure this is handled here because the browser process
// skipped it handling because it believed it would be handled here. If it
@@ -600,6 +610,31 @@ void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element,
gfx::Rect bounding_box(element_.boundsInViewportSpace());
+ // Find the datalist values and send them to the browser process.
+ std::vector<string16> data_list_values;
+ std::vector<string16> data_list_labels;
+ std::vector<string16> data_list_icons;
+ std::vector<int> data_list_unique_ids;
+ AppendDataListSuggestions(element_,
+ &data_list_values,
+ &data_list_labels,
+ &data_list_icons,
+ &data_list_unique_ids);
+
+ if (data_list_values.size() > kMaximumDataListSizeForAutofill) {
+ data_list_values.resize(kMaximumDataListSizeForAutofill);
+ data_list_labels.resize(kMaximumDataListSizeForAutofill);
+ data_list_icons.resize(kMaximumDataListSizeForAutofill);
+ data_list_unique_ids.resize(kMaximumDataListSizeForAutofill);
+ }
Ilya Sherman 2012/06/07 22:56:05 nit: You should probably also trim each entry of t
csharp 2012/06/08 14:44:54 Done.
+
+
Ilya Sherman 2012/06/07 22:56:05 nit: Extra blank line
csharp 2012/06/08 14:44:54 Done.
+ Send(new AutofillHostMsg_SetDataList(routing_id(),
+ data_list_values,
+ data_list_labels,
+ data_list_icons,
+ data_list_unique_ids));
+
Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(),
autofill_query_id_,
form,

Powered by Google App Engine
This is Rietveld 408576698