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

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 140093005: Add supports that allow Autofill to be initiated from textarea field (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update code as per review comments Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/autofill_agent.h" 5 #include "components/autofill/content/renderer/autofill_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
46 #include "ui/events/keycodes/keyboard_codes.h" 46 #include "ui/events/keycodes/keyboard_codes.h"
47 47
48 using blink::WebAutofillClient; 48 using blink::WebAutofillClient;
49 using blink::WebFormControlElement; 49 using blink::WebFormControlElement;
50 using blink::WebFormElement; 50 using blink::WebFormElement;
51 using blink::WebFrame; 51 using blink::WebFrame;
52 using blink::WebInputElement; 52 using blink::WebInputElement;
53 using blink::WebKeyboardEvent; 53 using blink::WebKeyboardEvent;
54 using blink::WebNode; 54 using blink::WebNode;
55 using blink::WebElementCollection; 55 using blink::WebElementCollection;
Ilya Sherman 2014/02/22 06:24:20 nit: While you're here, mind alpha-sorting this li
56 using blink::WebOptionElement; 56 using blink::WebOptionElement;
57 using blink::WebString; 57 using blink::WebString;
58 using blink::WebTextAreaElement;
58 59
59 namespace autofill { 60 namespace autofill {
60 61
61 namespace { 62 namespace {
62 63
63 // Gets all the data list values (with corresponding label) for the given 64 // Gets all the data list values (with corresponding label) for the given
64 // element. 65 // element.
65 void GetDataListSuggestions(const blink::WebInputElement& element, 66 void GetDataListSuggestions(const blink::WebInputElement& element,
66 bool ignore_current_value, 67 bool ignore_current_value,
67 std::vector<base::string16>* values, 68 std::vector<base::string16>* values,
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 HideAutofillUI(); 280 HideAutofillUI();
280 281
281 in_flight_request_form_ = form; 282 in_flight_request_form_ = form;
282 Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data, url)); 283 Send(new AutofillHostMsg_RequestAutocomplete(routing_id(), form_data, url));
283 } 284 }
284 285
285 void AutofillAgent::setIgnoreTextChanges(bool ignore) { 286 void AutofillAgent::setIgnoreTextChanges(bool ignore) {
286 ignore_text_changes_ = ignore; 287 ignore_text_changes_ = ignore;
287 } 288 }
288 289
289 void AutofillAgent::InputElementClicked(const WebInputElement& element, 290 void AutofillAgent::FormControlElementClicked(
290 bool was_focused, 291 const WebFormControlElement& element,
291 bool is_focused) { 292 bool was_focused,
293 bool is_focused) {
294 const WebInputElement* input_element = toWebInputElement(&element);
295 if (!IsAutofillableInputElement(input_element) &&
296 !IsTextAreaElement(element))
297 return;
Ilya Sherman 2014/02/22 06:24:20 nit: Please leave a blank line after this one.
292 if (was_focused) 298 if (was_focused)
293 ShowSuggestions(element, true, false, true, false); 299 ShowSuggestions(element, true, false, true, false);
294 } 300 }
295 301
296 void AutofillAgent::InputElementLostFocus() { 302 // This applies to both input and textarea elements
Ilya Sherman 2014/02/22 06:24:20 nit: This comment doesn't seem very useful to anyo
303 void AutofillAgent::FormControlElementLostFocus() {
297 HideAutofillUI(); 304 HideAutofillUI();
298 } 305 }
299 306
300 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { 307 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
301 password_autofill_agent_->TextFieldDidEndEditing(element); 308 password_autofill_agent_->TextFieldDidEndEditing(element);
302 has_shown_autofill_popup_for_current_edit_ = false; 309 has_shown_autofill_popup_for_current_edit_ = false;
303 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); 310 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id()));
304 } 311 }
305 312
313 // TODO: This function is to be removed once next Blink roll is done
306 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { 314 void AutofillAgent::textFieldDidChange(const WebInputElement& element) {
315 const WebFormControlElement control_element =
316 element.toConst<WebFormControlElement>();
317 textFieldDidChange(control_element);
318 }
319
320 // Text changes in input text field or textarea field
Ilya Sherman 2014/02/22 06:24:20 Ditto.
321 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) {
307 if (ignore_text_changes_) 322 if (ignore_text_changes_)
308 return; 323 return;
309 324
310 if (did_set_node_text_) { 325 if (did_set_node_text_) {
311 did_set_node_text_ = false; 326 did_set_node_text_ = false;
312 return; 327 return;
313 } 328 }
314 329
315 // We post a task for doing the Autofill as the caret position is not set 330 // We post a task for doing the Autofill as the caret position is not set
316 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and 331 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
317 // it is needed to trigger autofill. 332 // it is needed to trigger autofill.
318 weak_ptr_factory_.InvalidateWeakPtrs(); 333 weak_ptr_factory_.InvalidateWeakPtrs();
319 base::MessageLoop::current()->PostTask( 334 base::MessageLoop::current()->PostTask(
320 FROM_HERE, 335 FROM_HERE,
321 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, 336 base::Bind(&AutofillAgent::TextFieldDidChangeImpl,
322 weak_ptr_factory_.GetWeakPtr(), 337 weak_ptr_factory_.GetWeakPtr(),
323 element)); 338 element));
324 } 339 }
325 340
326 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { 341 void AutofillAgent::TextFieldDidChangeImpl(const WebFormControlElement& element)
342 {
Ilya Sherman 2014/02/22 06:24:20 nit: In the Chromium repository, curly braces shou
327 // If the element isn't focused then the changes don't matter. This check is 343 // If the element isn't focused then the changes don't matter. This check is
328 // required to properly handle IME interactions. 344 // required to properly handle IME interactions.
329 if (!element.focused()) 345 if (!element.focused())
330 return; 346 return;
331 347
332 if (password_generation_agent_ && 348 const WebInputElement* input_element = toWebInputElement(&element);
333 password_generation_agent_->TextDidChangeInTextField(element)) { 349 if (!IsAutofillableInputElement(input_element) &&
350 !IsTextAreaElement(element))
334 return; 351 return;
335 }
336 352
337 if (password_autofill_agent_->TextDidChangeInTextField(element)) { 353 if (IsAutofillableInputElement(input_element)) {
338 element_ = element; 354 if (password_generation_agent_ &&
339 return; 355 password_generation_agent_->TextDidChangeInTextField(*input_element)) {
356 return;
357 }
358
359 if (password_autofill_agent_->TextDidChangeInTextField(*input_element)) {
360 element_ = element;
361 return;
362 }
340 } 363 }
341 364
342 ShowSuggestions(element, false, true, false, false); 365 ShowSuggestions(element, false, true, false, false);
343 366
344 FormData form; 367 FormData form;
345 FormFieldData field; 368 FormFieldData field;
346 if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) { 369 if (FindFormAndFieldForFormControlElement(element,
370 &form,
371 &field,
372 REQUIRE_NONE)) {
347 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, 373 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field,
348 base::TimeTicks::Now())); 374 base::TimeTicks::Now()));
349 } 375 }
350 } 376 }
351 377
352 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, 378 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element,
353 const WebKeyboardEvent& event) { 379 const WebKeyboardEvent& event) {
354 if (password_autofill_agent_->TextFieldHandlingKeyDown(element, event)) { 380 if (password_autofill_agent_->TextFieldHandlingKeyDown(element, event)) {
355 element_ = element; 381 element_ = element;
356 return; 382 return;
357 } 383 }
358 384
359 if (event.windowsKeyCode == ui::VKEY_DOWN || 385 if (event.windowsKeyCode == ui::VKEY_DOWN ||
360 event.windowsKeyCode == ui::VKEY_UP) 386 event.windowsKeyCode == ui::VKEY_UP)
361 ShowSuggestions(element, true, true, true, false); 387 ShowSuggestions(element, true, true, true, false);
362 } 388 }
363 389
364 void AutofillAgent::openTextDataListChooser(const WebInputElement& element) { 390 void AutofillAgent::openTextDataListChooser(const WebInputElement& element) {
365 ShowSuggestions(element, true, false, false, true); 391 ShowSuggestions(element, true, false, false, true);
366 } 392 }
367 393
368 void AutofillAgent::AcceptDataListSuggestion( 394 void AutofillAgent::AcceptDataListSuggestion(
369 const base::string16& suggested_value) { 395 const base::string16& suggested_value) {
396 WebInputElement* input_element = toWebInputElement(&element_);
397 if (!input_element)
398 return;
Ilya Sherman 2014/02/22 06:24:20 nit: Please leave a blank line after this one.
370 base::string16 new_value = suggested_value; 399 base::string16 new_value = suggested_value;
371 // If this element takes multiple values then replace the last part with 400 // If this element takes multiple values then replace the last part with
372 // the suggestion. 401 // the suggestion.
373 if (element_.isMultiple() && 402 if (input_element->isMultiple() &&
374 element_.formControlType() == WebString::fromUTF8("email")) { 403 input_element->formControlType() == WebString::fromUTF8("email")) {
375 std::vector<base::string16> parts; 404 std::vector<base::string16> parts;
376 405
377 base::SplitStringDontTrim(element_.editingValue(), ',', &parts); 406 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts);
378 if (parts.size() == 0) 407 if (parts.size() == 0)
379 parts.push_back(base::string16()); 408 parts.push_back(base::string16());
380 409
381 base::string16 last_part = parts.back(); 410 base::string16 last_part = parts.back();
382 // We want to keep just the leading whitespace. 411 // We want to keep just the leading whitespace.
383 for (size_t i = 0; i < last_part.size(); ++i) { 412 for (size_t i = 0; i < last_part.size(); ++i) {
384 if (!IsWhitespace(last_part[i])) { 413 if (!IsWhitespace(last_part[i])) {
385 last_part = last_part.substr(0, i); 414 last_part = last_part.substr(0, i);
386 break; 415 break;
387 } 416 }
388 } 417 }
389 last_part.append(suggested_value); 418 last_part.append(suggested_value);
390 parts[parts.size() - 1] = last_part; 419 parts[parts.size() - 1] = last_part;
391 420
392 new_value = JoinString(parts, ','); 421 new_value = JoinString(parts, ',');
393 } 422 }
394 SetNodeText(new_value, &element_); 423 SetNodeText(new_value, input_element);
395 } 424 }
396 425
397 void AutofillAgent::OnFormDataFilled(int query_id, 426 void AutofillAgent::OnFormDataFilled(int query_id,
398 const FormData& form) { 427 const FormData& form) {
399 if (!render_view()->GetWebView() || query_id != autofill_query_id_) 428 if (!render_view()->GetWebView() || query_id != autofill_query_id_)
400 return; 429 return;
401 430
402 was_query_node_autofilled_ = element_.isAutofilled(); 431 was_query_node_autofilled_ = element_.isAutofilled();
403 432
404 switch (autofill_action_) { 433 switch (autofill_action_) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // TODO(isherman): There seem to be rare cases where this code *is* 475 // TODO(isherman): There seem to be rare cases where this code *is*
447 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would 476 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would
448 // understand those cases and fix the code to avoid them. However, so far I 477 // understand those cases and fix the code to avoid them. However, so far I
449 // have been unable to reproduce such a case locally. If you hit this 478 // have been unable to reproduce such a case locally. If you hit this
450 // NOTREACHED(), please file a bug against me. 479 // NOTREACHED(), please file a bug against me.
451 NOTREACHED(); 480 NOTREACHED();
452 } 481 }
453 } 482 }
454 483
455 void AutofillAgent::OnSetNodeText(const base::string16& value) { 484 void AutofillAgent::OnSetNodeText(const base::string16& value) {
456 SetNodeText(value, &element_); 485 WebInputElement* input_element = toWebInputElement(&element_);
486 if (!input_element)
487 return;
Ilya Sherman 2014/02/22 06:24:20 nit: Please leave a blank line after this one.
488 SetNodeText(value, input_element);
457 } 489 }
458 490
459 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { 491 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) {
460 AcceptDataListSuggestion(value); 492 AcceptDataListSuggestion(value);
461 } 493 }
462 494
463 void AutofillAgent::OnAcceptPasswordAutofillSuggestion( 495 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(
464 const base::string16& username) { 496 const base::string16& username) {
465 // We need to make sure this is handled here because the browser process 497 // We need to make sure this is handled here because the browser process
466 // skipped it handling because it believed it would be handled here. If it 498 // skipped it handling because it believed it would be handled here. If it
(...skipping 15 matching lines...) Expand all
482 result = WebFormElement::AutocompleteResultErrorInvalid; 514 result = WebFormElement::AutocompleteResultErrorInvalid;
483 } 515 }
484 516
485 in_flight_request_form_.finishRequestAutocomplete(result); 517 in_flight_request_form_.finishRequestAutocomplete(result);
486 in_flight_request_form_.reset(); 518 in_flight_request_form_.reset();
487 } 519 }
488 520
489 void AutofillAgent::OnPageShown() { 521 void AutofillAgent::OnPageShown() {
490 } 522 }
491 523
492 void AutofillAgent::ShowSuggestions(const WebInputElement& element, 524 void AutofillAgent::ShowSuggestions(const WebFormControlElement& element,
493 bool autofill_on_empty_values, 525 bool autofill_on_empty_values,
494 bool requires_caret_at_end, 526 bool requires_caret_at_end,
495 bool display_warning_if_disabled, 527 bool display_warning_if_disabled,
496 bool datalist_only) { 528 bool datalist_only) {
497 if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() || 529 const WebInputElement* input_element = toWebInputElement(&element);
Ilya Sherman 2014/02/22 06:24:20 nit: Please move this down to where it is used.
498 element.isPasswordField()) 530 if (!element.isEnabled() || element.isReadOnly())
499 return;
500 if (!datalist_only && !element.suggestedValue().isEmpty())
501 return; 531 return;
502 532
503 // Don't attempt to autofill with values that are too large or if filling 533 if (IsAutofillableInputElement(input_element)) {
504 // criteria are not met. 534 if (!input_element->isTextField() || input_element->isPasswordField())
505 WebString value = element.editingValue(); 535 return;
506 if (!datalist_only && 536 if (!datalist_only && !input_element->suggestedValue().isEmpty())
507 (value.length() > kMaxDataLength || 537 return;
508 (!autofill_on_empty_values && value.isEmpty()) || 538 // Don't attempt to autofill with values that are too large or if filling
509 (requires_caret_at_end && 539 // criteria are not met.
510 (element.selectionStart() != element.selectionEnd() || 540 WebString value = input_element->editingValue();
511 element.selectionEnd() != static_cast<int>(value.length()))))) { 541 if (!datalist_only &&
512 // Any popup currently showing is obsolete. 542 (value.length() > kMaxDataLength ||
513 HideAutofillUI(); 543 (!autofill_on_empty_values && value.isEmpty()) ||
514 return; 544 (requires_caret_at_end &&
545 (input_element->selectionStart() != input_element->selectionEnd() ||
546 input_element->selectionEnd() !=
547 static_cast<int>(value.length()))))) {
Ilya Sherman 2014/02/22 06:24:20 All of these criteria should apply to text areas a
548 // Any popup currently showing is obsolete.
549 HideAutofillUI();
550 return;
551 }
552
553 element_ = element;
554 if (password_autofill_agent_->ShowSuggestions(*input_element))
555 return;
556 } else if (IsTextAreaElement(element)) {
557 if (!element.toConst<WebTextAreaElement>().suggestedValue().isEmpty())
558 return;
559 element_ = element;
515 } 560 }
516 561
517 element_ = element;
518 if (password_autofill_agent_->ShowSuggestions(element))
519 return;
520
521 // If autocomplete is disabled at the field level, ensure that the native 562 // If autocomplete is disabled at the field level, ensure that the native
522 // UI won't try to show a warning, since that may conflict with a custom 563 // UI won't try to show a warning, since that may conflict with a custom
523 // popup. Note that we cannot use the WebKit method element.autoComplete() 564 // popup. Note that we cannot use the WebKit method element.autoComplete()
524 // as it does not allow us to distinguish the case where autocomplete is 565 // as it does not allow us to distinguish the case where autocomplete is
525 // disabled for *both* the element and for the form. 566 // disabled for *both* the element and for the form.
526 const base::string16 autocomplete_attribute = 567 const base::string16 autocomplete_attribute =
527 element.getAttribute("autocomplete"); 568 element.getAttribute("autocomplete");
528 if (LowerCaseEqualsASCII(autocomplete_attribute, "off")) 569 if (LowerCaseEqualsASCII(autocomplete_attribute, "off"))
529 display_warning_if_disabled = false; 570 display_warning_if_disabled = false;
530 571
531 QueryAutofillSuggestions(element, 572 QueryAutofillSuggestions(element,
532 display_warning_if_disabled, 573 display_warning_if_disabled,
533 datalist_only); 574 datalist_only);
534 } 575 }
535 576
536 void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element, 577 void AutofillAgent::QueryAutofillSuggestions(
537 bool display_warning_if_disabled, 578 const WebFormControlElement& element,
538 bool datalist_only) { 579 bool display_warning_if_disabled,
580 bool datalist_only) {
539 if (!element.document().frame()) 581 if (!element.document().frame())
540 return; 582 return;
541 583
542 static int query_counter = 0; 584 static int query_counter = 0;
543 autofill_query_id_ = query_counter++; 585 autofill_query_id_ = query_counter++;
544 display_warning_if_disabled_ = display_warning_if_disabled; 586 display_warning_if_disabled_ = display_warning_if_disabled;
587 const WebInputElement* input_element = toWebInputElement(&element);
545 588
546 // If autocomplete is disabled at the form level, we want to see if there 589 // If autocomplete is disabled at the form level, we want to see if there
547 // would have been any suggestions were it enabled, so that we can show a 590 // would have been any suggestions were it enabled, so that we can show a
548 // warning. Otherwise, we want to ignore fields that disable autocomplete, so 591 // warning. Otherwise, we want to ignore fields that disable autocomplete, so
549 // that the suggestions list does not include suggestions for these form 592 // that the suggestions list does not include suggestions for these form
550 // fields -- see comment 1 on http://crbug.com/69914 593 // fields -- see comment 1 on http://crbug.com/69914
551 const RequirementsMask requirements = 594 RequirementsMask requirements = REQUIRE_NONE;
552 element.autoComplete() ? REQUIRE_AUTOCOMPLETE : REQUIRE_NONE; 595 if (IsAutofillableInputElement(input_element)) {
596 requirements =
597 input_element->autoComplete() ? REQUIRE_AUTOCOMPLETE : REQUIRE_NONE;
598 }
Ilya Sherman 2014/02/22 06:24:20 Equivalent logic should apply to textarea fields a
553 599
554 FormData form; 600 FormData form;
555 FormFieldData field; 601 FormFieldData field;
556 if (!FindFormAndFieldForInputElement(element, &form, &field, requirements)) { 602 if (!FindFormAndFieldForFormControlElement(element, &form, &field,
603 requirements)) {
557 // If we didn't find the cached form, at least let autocomplete have a shot 604 // If we didn't find the cached form, at least let autocomplete have a shot
558 // at providing suggestions. 605 // at providing suggestions.
559 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); 606 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field);
560 } 607 }
561 if (datalist_only) 608 if (datalist_only)
562 field.should_autocomplete = false; 609 field.should_autocomplete = false;
563 610
564 gfx::RectF bounding_box_scaled = 611 gfx::RectF bounding_box_scaled =
565 GetScaledBoundingBox(web_view_->pageScaleFactor(), &element_); 612 GetScaledBoundingBox(web_view_->pageScaleFactor(), &element_);
566 613
567 // Find the datalist values and send them to the browser process. 614 if (IsAutofillableInputElement(input_element)) {
568 std::vector<base::string16> data_list_values; 615 // Find the datalist values and send them to the browser process.
569 std::vector<base::string16> data_list_labels; 616 std::vector<base::string16> data_list_values;
570 GetDataListSuggestions(element_, 617 std::vector<base::string16> data_list_labels;
618 GetDataListSuggestions(*input_element,
571 datalist_only, 619 datalist_only,
572 &data_list_values, 620 &data_list_values,
573 &data_list_labels); 621 &data_list_labels);
Ilya Sherman 2014/02/22 06:24:20 nit: Please fix alignment for these three lines.
574 TrimStringVectorForIPC(&data_list_values); 622 TrimStringVectorForIPC(&data_list_values);
575 TrimStringVectorForIPC(&data_list_labels); 623 TrimStringVectorForIPC(&data_list_labels);
576 624
577 Send(new AutofillHostMsg_SetDataList(routing_id(), 625 Send(new AutofillHostMsg_SetDataList(routing_id(),
578 data_list_values, 626 data_list_values,
579 data_list_labels)); 627 data_list_labels));
580 628 }
581 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(), 629 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(),
582 autofill_query_id_, 630 autofill_query_id_,
583 form, 631 form,
584 field, 632 field,
585 bounding_box_scaled, 633 bounding_box_scaled,
586 display_warning_if_disabled)); 634 display_warning_if_disabled));
587 } 635 }
588 636
589 void AutofillAgent::FillAutofillFormData(const WebNode& node, 637 void AutofillAgent::FillAutofillFormData(const WebNode& node,
590 int unique_id, 638 int unique_id,
591 AutofillAction action) { 639 AutofillAction action) {
592 DCHECK_GT(unique_id, 0); 640 DCHECK_GT(unique_id, 0);
593 641
594 static int query_counter = 0; 642 static int query_counter = 0;
595 autofill_query_id_ = query_counter++; 643 autofill_query_id_ = query_counter++;
596 644
597 FormData form; 645 FormData form;
598 FormFieldData field; 646 FormFieldData field;
599 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, 647 if (!FindFormAndFieldForFormControlElement(
600 &field, REQUIRE_AUTOCOMPLETE)) { 648 node.toConst<WebFormControlElement>(),
649 &form,
650 &field,
651 REQUIRE_AUTOCOMPLETE)) {
601 return; 652 return;
602 } 653 }
603 654
604 autofill_action_ = action; 655 autofill_action_ = action;
605 Send(new AutofillHostMsg_FillAutofillFormData( 656 Send(new AutofillHostMsg_FillAutofillFormData(
606 routing_id(), autofill_query_id_, form, field, unique_id)); 657 routing_id(), autofill_query_id_, form, field, unique_id));
607 } 658 }
608 659
609 void AutofillAgent::SetNodeText(const base::string16& value, 660 void AutofillAgent::SetNodeText(const base::string16& value,
610 blink::WebInputElement* node) { 661 blink::WebInputElement* node) {
(...skipping 19 matching lines...) Expand all
630 // Only monitors dynamic forms created in the top frame. Dynamic forms 681 // Only monitors dynamic forms created in the top frame. Dynamic forms
631 // inserted in iframes are not captured yet. 682 // inserted in iframes are not captured yet.
632 if (!frame->parent()) { 683 if (!frame->parent()) {
633 password_autofill_agent_->OnDynamicFormsSeen(frame); 684 password_autofill_agent_->OnDynamicFormsSeen(frame);
634 return; 685 return;
635 } 686 }
636 } 687 }
637 } 688 }
638 689
639 } // namespace autofill 690 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698