1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/renderer/autofill/autofill_agent.h"
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "base/string_split.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "chrome/common/autofill_messages.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/renderer/autofill/form_autofill_util.h"
#include "chrome/renderer/autofill/password_autofill_manager.h"
#include "content/public/renderer/render_view.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeCollection.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebOptionElement.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/l10n/l10n_util.h"
#include "webkit/forms/form_data.h"
#include "webkit/forms/form_data_predictions.h"
#include "webkit/forms/form_field.h"
#include "webkit/forms/password_form.h"
using WebKit::WebAutofillClient;
using WebKit::WebFormControlElement;
using WebKit::WebFormElement;
using WebKit::WebFrame;
using WebKit::WebInputElement;
using WebKit::WebKeyboardEvent;
using WebKit::WebNode;
using WebKit::WebNodeCollection;
using WebKit::WebOptionElement;
using WebKit::WebString;
using webkit::forms::FormData;
using webkit::forms::FormDataPredictions;
namespace {
// The size above which we stop triggering autofill for an input text field
// (so to avoid sending long strings through IPC).
const size_t kMaximumTextSizeForAutofill = 1000;
void AppendDataListSuggestions(const WebKit::WebInputElement& element,
std::vector<string16>* values,
std::vector<string16>* labels,
std::vector<string16>* icons,
std::vector<int>* item_ids) {
WebNodeCollection options = element.dataListOptions();
if (options.isNull())
return;
string16 prefix = element.editingValue();
if (element.isMultiple() &&
element.formControlType() == WebString::fromUTF8("email")) {
std::vector<string16> parts;
base::SplitStringDontTrim(prefix, ',', &parts);
if (parts.size() > 0)
TrimWhitespace(parts[parts.size() - 1], TRIM_LEADING, &prefix);
}
for (WebOptionElement option = options.firstItem().to<WebOptionElement>();
!option.isNull(); option = options.nextItem().to<WebOptionElement>()) {
if (!StartsWith(option.value(), prefix, false) ||
option.value() == prefix ||
!element.isValidValue(option.value()))
continue;
values->push_back(option.value());
if (option.value() != option.label())
labels->push_back(option.label());
else
labels->push_back(string16());
icons->push_back(string16());
item_ids->push_back(WebAutofillClient::MenuItemIDDataListEntry);
}
}
} // namespace
namespace autofill {
AutofillAgent::AutofillAgent(
content::RenderView* render_view,
PasswordAutofillManager* password_autofill_manager)
: content::RenderViewObserver(render_view),
password_autofill_manager_(password_autofill_manager),
autofill_query_id_(0),
autofill_action_(AUTOFILL_NONE),
display_warning_if_disabled_(false),
was_query_node_autofilled_(false),
has_shown_autofill_popup_for_current_edit_(false),
did_set_node_text_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
render_view->GetWebView()->setAutofillClient(this);
}
AutofillAgent::~AutofillAgent() {}
bool AutofillAgent::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(AutofillAgent, message)
IPC_MESSAGE_HANDLER(AutofillMsg_SuggestionsReturned, OnSuggestionsReturned)
IPC_MESSAGE_HANDLER(AutofillMsg_FormDataFilled, OnFormDataFilled)
IPC_MESSAGE_HANDLER(AutofillMsg_FieldTypePredictionsAvailable,
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_HANDLER(AutofillMsg_AcceptPasswordAutofillSuggestion,
OnAcceptPasswordAutofillSuggestion)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void AutofillAgent::DidFinishDocumentLoad(WebFrame* frame) {
// The document has now been fully loaded. Scan for forms to be sent up to
// the browser.
std::vector<webkit::forms::FormData> forms;
form_cache_.ExtractForms(*frame, &forms);
if (!forms.empty()) {
Send(new AutofillHostMsg_FormsSeen(routing_id(), forms,
base::TimeTicks::Now()));
}
}
void AutofillAgent::FrameDetached(WebFrame* frame) {
form_cache_.ResetFrame(*frame);
}
void AutofillAgent::FrameWillClose(WebFrame* frame) {
form_cache_.ResetFrame(*frame);
}
void AutofillAgent::WillSubmitForm(WebFrame* frame,
const WebFormElement& form) {
FormData form_data;
if (WebFormElementToFormData(form,
WebFormControlElement(),
REQUIRE_AUTOCOMPLETE,
static_cast<ExtractMask>(
EXTRACT_VALUE | EXTRACT_OPTION_TEXT),
&form_data,
NULL)) {
Send(new AutofillHostMsg_FormSubmitted(routing_id(), form_data,
base::TimeTicks::Now()));
}
}
void AutofillAgent::ZoomLevelChanged() {
// Any time the zoom level changes, the page's content moves, so any Autofill
// popups should be hidden. This is only needed for the new Autofill UI
// because WebKit already knows to hide the old UI when this occurs.
Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
}
void AutofillAgent::DidChangeScrollOffset(WebKit::WebFrame*) {
// Any time the scroll offset changes, the page's content moves, so Autofill
// popups should be hidden. This is only needed for the new Autofill UI
// because WebKit already knows to hide the old UI when this occurs.
Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
}
bool AutofillAgent::InputElementClicked(const WebInputElement& element,
bool was_focused,
bool is_focused) {
if (was_focused)
ShowSuggestions(element, true, false, true);
return false;
}
bool AutofillAgent::InputElementLostFocus() {
Send(new AutofillHostMsg_HideAutofillPopup(routing_id()));
return false;
}
void AutofillAgent::didAcceptAutofillSuggestion(const WebNode& node,
const WebString& value,
const WebString& label,
int item_id,
unsigned index) {
if (password_autofill_manager_->DidAcceptAutofillSuggestion(node, value))
return;
DCHECK(node == element_);
switch (item_id) {
case WebAutofillClient::MenuItemIDWarningMessage:
case WebAutofillClient::MenuItemIDSeparator:
NOTREACHED();
break;
case WebAutofillClient::MenuItemIDAutofillOptions:
// User selected 'Autofill Options'.
Send(new AutofillHostMsg_ShowAutofillDialog(routing_id()));
break;
case WebAutofillClient::MenuItemIDClearForm:
// User selected 'Clear form'.
form_cache_.ClearFormWithElement(element_);
break;
case WebAutofillClient::MenuItemIDAutocompleteEntry:
case WebAutofillClient::MenuItemIDPasswordEntry:
// User selected an Autocomplete or password entry, so we fill directly.
SetNodeText(value, &element_);
break;
case WebAutofillClient::MenuItemIDDataListEntry:
AcceptDataListSuggestion(value);
break;
default:
// A positive item_id is a unique id for an autofill (vs. autocomplete)
// suggestion.
DCHECK_GT(item_id, 0);
// Fill the values for the whole form.
FillAutofillFormData(node, item_id, AUTOFILL_FILL);
}
}
void AutofillAgent::didSelectAutofillSuggestion(const WebNode& node,
const WebString& value,
const WebString& label,
int item_id) {
if (password_autofill_manager_->DidSelectAutofillSuggestion(node))
return;
didClearAutofillSelection(node);
if (item_id > 0)
FillAutofillFormData(node, item_id, AUTOFILL_PREVIEW);
}
void AutofillAgent::didClearAutofillSelection(const WebNode& node) {
if (password_autofill_manager_->DidClearAutofillSelection(node))
return;
if (!element_.isNull() && node == element_) {
ClearPreviewedFormWithElement(element_, was_query_node_autofilled_);
} else {
// TODO(isherman): There seem to be rare cases where this code *is*
// reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would
// understand those cases and fix the code to avoid them. However, so far I
// have been unable to reproduce such a case locally. If you hit this
// NOTREACHED(), please file a bug against me.
NOTREACHED();
}
}
void AutofillAgent::removeAutocompleteSuggestion(const WebString& name,
const WebString& value) {
Send(new AutofillHostMsg_RemoveAutocompleteEntry(routing_id(), name, value));
}
void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
password_autofill_manager_->TextFieldDidEndEditing(element);
has_shown_autofill_popup_for_current_edit_ = false;
Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id()));
}
void AutofillAgent::textFieldDidChange(const WebInputElement& element) {
if (did_set_node_text_) {
did_set_node_text_ = false;
return;
}
// We post a task for doing the Autofill as the caret position is not set
// properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
// it is needed to trigger autofill.
weak_ptr_factory_.InvalidateWeakPtrs();
MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&AutofillAgent::TextFieldDidChangeImpl,
weak_ptr_factory_.GetWeakPtr(), element));
}
void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) {
if (password_autofill_manager_->TextDidChangeInTextField(element)) {
element_ = element;
return;
}
ShowSuggestions(element, false, true, false);
webkit::forms::FormData form;
webkit::forms::FormField field;
if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) {
Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field,
base::TimeTicks::Now()));
}
}
void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element,
const WebKeyboardEvent& event) {
if (password_autofill_manager_->TextFieldHandlingKeyDown(element, event)) {
element_ = element;
return;
}
if (event.windowsKeyCode == ui::VKEY_DOWN ||
event.windowsKeyCode == ui::VKEY_UP)
ShowSuggestions(element, true, true, true);
}
void AutofillAgent::OnSuggestionsReturned(int query_id,
const std::vector<string16>& values,
const std::vector<string16>& labels,
const std::vector<string16>& icons,
const std::vector<int>& unique_ids) {
if (query_id != autofill_query_id_)
return;
if (element_.isNull() || !element_.isFocusable())
return;
std::vector<string16> v(values);
std::vector<string16> l(labels);
std::vector<string16> i(icons);
std::vector<int> ids(unique_ids);
if (!element_.autoComplete() && !v.empty()) {
// If autofill is disabled and we had suggestions, show a warning instead.
v.assign(1, l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED));
l.assign(1, string16());
i.assign(1, string16());
ids.assign(1, WebAutofillClient::MenuItemIDWarningMessage);
} else if (ids.size() > 1 &&
ids[0] == WebAutofillClient::MenuItemIDWarningMessage) {
// If we received an autofill warning plus some autocomplete suggestions,
// remove the autofill warning.
v.erase(v.begin());
l.erase(l.begin());
i.erase(i.begin());
ids.erase(ids.begin());
}
// If we were about to show a warning and we shouldn't, don't.
if (!display_warning_if_disabled_ && !v.empty() &&
ids[0] == WebAutofillClient::MenuItemIDWarningMessage) {
v.clear();
l.clear();
i.clear();
ids.clear();
}
// Only include "Autofill Options" special menu item if we have Autofill
// items, identified by |unique_ids| having at least one valid value.
bool has_autofill_item = false;
for (size_t i = 0; i < ids.size(); ++i) {
if (ids[i] > 0) {
has_autofill_item = true;
break;
}
}
if (has_autofill_item) {
v.push_back(string16());
l.push_back(string16());
i.push_back(string16());
ids.push_back(WebAutofillClient::MenuItemIDSeparator);
if (FormWithElementIsAutofilled(element_)) {
// The form has been auto-filled, so give the user the chance to clear the
// form. Append the 'Clear form' menu item.
v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_CLEAR_FORM_MENU_ITEM));
l.push_back(string16());
i.push_back(string16());
ids.push_back(WebAutofillClient::MenuItemIDClearForm);
}
// Append the 'Chrome Autofill options' menu item;
v.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_OPTIONS_POPUP));
l.push_back(string16());
i.push_back(string16());
ids.push_back(WebAutofillClient::MenuItemIDAutofillOptions);
}
CombineDataListEntriesAndShow(element_, v, l, i, ids, has_autofill_item);
}
void AutofillAgent::CombineDataListEntriesAndShow(
const WebKit::WebInputElement& element,
const std::vector<string16>& values,
const std::vector<string16>& labels,
const std::vector<string16>& icons,
const std::vector<int>& item_ids,
bool has_autofill_item) {
std::vector<string16> v;
std::vector<string16> l;
std::vector<string16> i;
std::vector<int> ids;
AppendDataListSuggestions(element, &v, &l, &i, &ids);
// If there are both <datalist> items and Autofill suggestions, add a
// separator between them.
if (!v.empty() && !values.empty()) {
v.push_back(string16());
l.push_back(string16());
i.push_back(string16());
ids.push_back(WebAutofillClient::MenuItemIDSeparator);
}
// Append the Autofill suggestions.
v.insert(v.end(), values.begin(), values.end());
l.insert(l.end(), labels.begin(), labels.end());
i.insert(i.end(), icons.begin(), icons.end());
ids.insert(ids.end(), item_ids.begin(), item_ids.end());
WebKit::WebView* web_view = render_view()->GetWebView();
if (!web_view)
return;
if (v.empty()) {
// No suggestions, any popup currently showing is obsolete.
web_view->hidePopups();
return;
}
// Send to WebKit for display.
web_view->applyAutofillSuggestions(element, v, l, i, ids);
Send(new AutofillHostMsg_DidShowAutofillSuggestions(
routing_id(),
has_autofill_item && !has_shown_autofill_popup_for_current_edit_));
has_shown_autofill_popup_for_current_edit_ |= has_autofill_item;
}
void AutofillAgent::AcceptDataListSuggestion(const string16& suggested_value) {
string16 new_value = suggested_value;
// If this element takes multiple values then replace the last part with
// the suggestion.
if (element_.isMultiple() &&
element_.formControlType() == WebString::fromUTF8("email")) {
std::vector<string16> parts;
base::SplitStringDontTrim(element_.editingValue(), ',', &parts);
if (parts.size() == 0)
parts.push_back(string16());
string16 last_part = parts.back();
// We want to keep just the leading whitespace.
for (size_t i = 0; i < last_part.size(); ++i) {
if (!IsWhitespace(last_part[i])) {
last_part = last_part.substr(0, i);
break;
}
}
last_part.append(suggested_value);
parts[parts.size() - 1] = last_part;
new_value = JoinString(parts, ',');
}
SetNodeText(new_value, &element_);
}
void AutofillAgent::OnFormDataFilled(int query_id,
const webkit::forms::FormData& form) {
if (!render_view()->GetWebView() || query_id != autofill_query_id_)
return;
was_query_node_autofilled_ = element_.isAutofilled();
switch (autofill_action_) {
case AUTOFILL_FILL:
FillForm(form, element_);
Send(new AutofillHostMsg_DidFillAutofillFormData(routing_id(),
base::TimeTicks::Now()));
break;
case AUTOFILL_PREVIEW:
PreviewForm(form, element_);
Send(new AutofillHostMsg_DidPreviewAutofillFormData(routing_id()));
break;
default:
NOTREACHED();
}
autofill_action_ = AUTOFILL_NONE;
}
void AutofillAgent::OnFieldTypePredictionsAvailable(
const std::vector<FormDataPredictions>& forms) {
for (size_t i = 0; i < forms.size(); ++i) {
form_cache_.ShowPredictions(forms[i]);
}
}
void AutofillAgent::OnSelectAutofillSuggestionAtIndex(int listIndex) {
NOTIMPLEMENTED();
// TODO(jrg): enable once changes land in WebKit
// render_view()->webview()->selectAutofillSuggestionAtIndex(listIndex);
}
void AutofillAgent::OnSetAutofillActionFill() {
autofill_action_ = AUTOFILL_FILL;
}
void AutofillAgent::OnClearForm() {
form_cache_.ClearFormWithElement(element_);
}
void AutofillAgent::OnSetAutofillActionPreview() {
autofill_action_ = AUTOFILL_PREVIEW;
}
void AutofillAgent::OnClearPreviewedForm() {
didClearAutofillSelection(element_);
}
void AutofillAgent::OnSetNodeText(const string16& value) {
SetNodeText(value, &element_);
}
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
// isn't handled here then the browser logic needs to be updated.
bool handled = password_autofill_manager_->DidAcceptAutofillSuggestion(
element_,
value);
DCHECK(handled);
}
void AutofillAgent::ShowSuggestions(const WebInputElement& element,
bool autofill_on_empty_values,
bool requires_caret_at_end,
bool display_warning_if_disabled) {
if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() ||
element.isPasswordField() || !element.suggestedValue().isEmpty())
return;
// Don't attempt to autofill with values that are too large or if filling
// criteria are not met.
WebString value = element.editingValue();
if (value.length() > kMaximumTextSizeForAutofill ||
(!autofill_on_empty_values && value.isEmpty()) ||
(requires_caret_at_end &&
(element.selectionStart() != element.selectionEnd() ||
element.selectionEnd() != static_cast<int>(value.length())))) {
// Any popup currently showing is obsolete.
WebKit::WebView* web_view = render_view()->GetWebView();
if (web_view)
web_view->hidePopups();
return;
}
element_ = element;
// If autocomplete is disabled at the form level, then we might want to show
// a warning in place of suggestions. However, if autocomplete is disabled
// specifically for this field, we never want to show a warning. Otherwise,
// we might interfere with custom popups (e.g. search suggestions) used by
// the website. Also, if the field has no name, then we won't have values.
const WebFormElement form = element.form();
if ((!element.autoComplete() && (form.isNull() || form.autoComplete())) ||
element.nameForAutofill().isEmpty()) {
CombineDataListEntriesAndShow(element, std::vector<string16>(),
std::vector<string16>(),
std::vector<string16>(),
std::vector<int>(), false);
return;
}
QueryAutofillSuggestions(element, display_warning_if_disabled);
}
void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element,
bool display_warning_if_disabled) {
static int query_counter = 0;
autofill_query_id_ = query_counter++;
display_warning_if_disabled_ = display_warning_if_disabled;
webkit::forms::FormData form;
webkit::forms::FormField field;
if (!FindFormAndFieldForInputElement(element, &form, &field,
REQUIRE_AUTOCOMPLETE)) {
// If we didn't find the cached form, at least let autocomplete have a shot
// at providing suggestions.
WebFormControlElementToFormField(element, EXTRACT_VALUE, &field);
}
gfx::Rect bounding_box(element_.boundsInViewportSpace());
Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(),
autofill_query_id_,
form,
field,
bounding_box,
display_warning_if_disabled));
}
void AutofillAgent::FillAutofillFormData(const WebNode& node,
int unique_id,
AutofillAction action) {
DCHECK_GT(unique_id, 0);
static int query_counter = 0;
autofill_query_id_ = query_counter++;
webkit::forms::FormData form;
webkit::forms::FormField field;
if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form,
&field, REQUIRE_AUTOCOMPLETE)) {
return;
}
autofill_action_ = action;
Send(new AutofillHostMsg_FillAutofillFormData(
routing_id(), autofill_query_id_, form, field, unique_id));
}
void AutofillAgent::SetNodeText(const string16& value,
WebKit::WebInputElement* node) {
did_set_node_text_ = true;
string16 substring = value;
substring = substring.substr(0, node->maxLength());
node->setEditingValue(substring);
}
} // namespace autofill
|