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

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: Temporarily keep textFieldDidiChange(const WebInputElement&) due to Blink roll delay 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::WebNodeCollection; 55 using blink::WebNodeCollection;
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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::InputElementClicked(const WebInputElement& element,
290 bool was_focused, 291 bool was_focused,
291 bool is_focused) { 292 bool is_focused) {
292 if (was_focused) 293 if (was_focused)
293 ShowSuggestions(element, true, false, true, false); 294 ShowSuggestions(element, true, false, true, false);
294 } 295 }
Ilya Sherman 2014/02/14 02:44:40 Is this method needed in addition to the TextAreaE
ziran.sun 2014/02/17 15:43:45 Done.
295 296
296 void AutofillAgent::InputElementLostFocus() { 297 void AutofillAgent::TextAreaElementClicked(const WebTextAreaElement& element,
298 bool was_focused,
299 bool is_focused) {
Ilya Sherman 2014/02/14 02:44:40 Is is_focused needed?
ziran.sun 2014/02/17 15:43:45 I'm not sure. It doesn't seem that it's called her
Ilya Sherman 2014/02/22 06:24:20 Let's go ahead and remove it if it's not used anym
300 if (was_focused)
301 ShowSuggestions(element, true, false, true, false);
302 }
303
304 // This applies to both input and textarea elements
305 void AutofillAgent::FormControlElementLostFocus() {
297 HideAutofillUI(); 306 HideAutofillUI();
298 } 307 }
299 308
300 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { 309 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) {
301 password_autofill_agent_->TextFieldDidEndEditing(element); 310 password_autofill_agent_->TextFieldDidEndEditing(element);
302 has_shown_autofill_popup_for_current_edit_ = false; 311 has_shown_autofill_popup_for_current_edit_ = false;
303 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); 312 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id()));
304 } 313 }
305 314
315 // This function is to be removed once next Blink roll is done
Ilya Sherman 2014/02/14 02:44:40 Please add a TODO.
ziran.sun 2014/02/17 15:43:45 Done.
306 void AutofillAgent::textFieldDidChange(const WebInputElement& element) { 316 void AutofillAgent::textFieldDidChange(const WebInputElement& element) {
307 if (ignore_text_changes_) 317 if (ignore_text_changes_)
308 return; 318 return;
309 319
310 if (did_set_node_text_) { 320 if (did_set_node_text_) {
311 did_set_node_text_ = false; 321 did_set_node_text_ = false;
312 return; 322 return;
313 } 323 }
314 324
315 // We post a task for doing the Autofill as the caret position is not set 325 // 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 326 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
317 // it is needed to trigger autofill. 327 // it is needed to trigger autofill.
318 weak_ptr_factory_.InvalidateWeakPtrs(); 328 weak_ptr_factory_.InvalidateWeakPtrs();
319 base::MessageLoop::current()->PostTask( 329 base::MessageLoop::current()->PostTask(
320 FROM_HERE, 330 FROM_HERE,
321 base::Bind(&AutofillAgent::TextFieldDidChangeImpl, 331 base::Bind(&AutofillAgent::TextFieldDidChangeImpl,
322 weak_ptr_factory_.GetWeakPtr(), 332 weak_ptr_factory_.GetWeakPtr(),
323 element)); 333 element));
Ilya Sherman 2014/02/14 02:44:40 Can you call into the other textFieldDidChange fun
ziran.sun 2014/02/17 15:43:45 Done.
324 } 334 }
325 335
326 void AutofillAgent::TextFieldDidChangeImpl(const WebInputElement& element) { 336 // Text changes in input text field or textarea field
337 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) {
338 if (ignore_text_changes_)
339 return;
340
341 if (did_set_node_text_) {
342 did_set_node_text_ = false;
343 return;
344 }
345
346 // We post a task for doing the Autofill as the caret position is not set
347 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and
348 // it is needed to trigger autofill.
349 weak_ptr_factory_.InvalidateWeakPtrs();
350 base::MessageLoop::current()->PostTask(
351 FROM_HERE,
352 base::Bind(&AutofillAgent::TextFieldDidChangeImpl,
353 weak_ptr_factory_.GetWeakPtr(),
354 element));
355 }
356
357 void AutofillAgent::TextFieldDidChangeImpl(const WebFormControlElement& element)
358 {
327 // If the element isn't focused then the changes don't matter. This check is 359 // If the element isn't focused then the changes don't matter. This check is
328 // required to properly handle IME interactions. 360 // required to properly handle IME interactions.
329 if (!element.focused()) 361 if (!element.focused())
330 return; 362 return;
331 363
332 if (password_generation_agent_ && 364 const WebInputElement* input_element = toWebInputElement(&element);
333 password_generation_agent_->TextDidChangeInTextField(element)) { 365 if (IsAutofillableInputElement(input_element)) {
334 return; 366 if (password_generation_agent_ &&
335 } 367 password_generation_agent_->TextDidChangeInTextField(*input_element)) {
Ilya Sherman 2014/02/14 02:44:40 nit: Indent this line by two more spaces.
ziran.sun 2014/02/17 15:43:45 Done.
368 return;
Ilya Sherman 2014/02/14 02:44:40 nit: Indent this line by two fewer spaces.
ziran.sun 2014/02/17 15:43:45 Done.
369 }
336 370
337 if (password_autofill_agent_->TextDidChangeInTextField(element)) { 371 if (password_autofill_agent_->TextDidChangeInTextField(*input_element)) {
338 element_ = element; 372 element_ = element;
339 return; 373 return;
374 }
340 } 375 }
341 376
342 ShowSuggestions(element, false, true, false, false); 377 ShowSuggestions(element, false, true, false, false);
343 378
344 FormData form; 379 FormData form;
345 FormFieldData field; 380 FormFieldData field;
346 if (FindFormAndFieldForInputElement(element, &form, &field, REQUIRE_NONE)) { 381 if ((IsAutofillableInputElement(input_element) ||
382 IsTextAreaElement(element)) &&
Ilya Sherman 2014/02/14 02:44:40 Please move the check for whether this is an autof
ziran.sun 2014/02/17 15:43:45 Done.
383 FindFormAndFieldForFormControlElement(element,
384 &form,
385 &field,
386 REQUIRE_NONE)) {
347 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field, 387 Send(new AutofillHostMsg_TextFieldDidChange(routing_id(), form, field,
348 base::TimeTicks::Now())); 388 base::TimeTicks::Now()));
349 } 389 }
350 } 390 }
351 391
352 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element, 392 void AutofillAgent::textFieldDidReceiveKeyDown(const WebInputElement& element,
353 const WebKeyboardEvent& event) { 393 const WebKeyboardEvent& event) {
354 if (password_autofill_agent_->TextFieldHandlingKeyDown(element, event)) { 394 if (password_autofill_agent_->TextFieldHandlingKeyDown(element, event)) {
355 element_ = element; 395 element_ = element;
356 return; 396 return;
357 } 397 }
358 398
359 if (event.windowsKeyCode == ui::VKEY_DOWN || 399 if (event.windowsKeyCode == ui::VKEY_DOWN ||
360 event.windowsKeyCode == ui::VKEY_UP) 400 event.windowsKeyCode == ui::VKEY_UP)
361 ShowSuggestions(element, true, true, true, false); 401 ShowSuggestions(element, true, true, true, false);
362 } 402 }
363 403
364 void AutofillAgent::openTextDataListChooser(const WebInputElement& element) { 404 void AutofillAgent::openTextDataListChooser(const WebInputElement& element) {
365 ShowSuggestions(element, true, false, false, true); 405 ShowSuggestions(element, true, false, false, true);
366 } 406 }
367 407
368 void AutofillAgent::AcceptDataListSuggestion( 408 void AutofillAgent::AcceptDataListSuggestion(
369 const base::string16& suggested_value) { 409 const base::string16& suggested_value) {
410 WebInputElement* input_element = toWebInputElement(&element_);
Ilya Sherman 2014/02/14 02:44:40 nit: Please add a DCHECK that this conversion succ
ziran.sun 2014/02/17 15:43:45 Done.
370 base::string16 new_value = suggested_value; 411 base::string16 new_value = suggested_value;
371 // If this element takes multiple values then replace the last part with 412 // If this element takes multiple values then replace the last part with
372 // the suggestion. 413 // the suggestion.
373 if (element_.isMultiple() && 414 if (input_element->isMultiple() &&
374 element_.formControlType() == WebString::fromUTF8("email")) { 415 input_element->formControlType() == WebString::fromUTF8("email")) {
375 std::vector<base::string16> parts; 416 std::vector<base::string16> parts;
376 417
377 base::SplitStringDontTrim(element_.editingValue(), ',', &parts); 418 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts);
378 if (parts.size() == 0) 419 if (parts.size() == 0)
379 parts.push_back(base::string16()); 420 parts.push_back(base::string16());
380 421
381 base::string16 last_part = parts.back(); 422 base::string16 last_part = parts.back();
382 // We want to keep just the leading whitespace. 423 // We want to keep just the leading whitespace.
383 for (size_t i = 0; i < last_part.size(); ++i) { 424 for (size_t i = 0; i < last_part.size(); ++i) {
384 if (!IsWhitespace(last_part[i])) { 425 if (!IsWhitespace(last_part[i])) {
385 last_part = last_part.substr(0, i); 426 last_part = last_part.substr(0, i);
386 break; 427 break;
387 } 428 }
388 } 429 }
389 last_part.append(suggested_value); 430 last_part.append(suggested_value);
390 parts[parts.size() - 1] = last_part; 431 parts[parts.size() - 1] = last_part;
391 432
392 new_value = JoinString(parts, ','); 433 new_value = JoinString(parts, ',');
393 } 434 }
394 SetNodeText(new_value, &element_); 435 SetNodeText(new_value, input_element);
395 } 436 }
396 437
397 void AutofillAgent::OnFormDataFilled(int query_id, 438 void AutofillAgent::OnFormDataFilled(int query_id,
398 const FormData& form) { 439 const FormData& form) {
399 if (!render_view()->GetWebView() || query_id != autofill_query_id_) 440 if (!render_view()->GetWebView() || query_id != autofill_query_id_)
400 return; 441 return;
401 442
402 was_query_node_autofilled_ = element_.isAutofilled(); 443 was_query_node_autofilled_ = element_.isAutofilled();
403 444
404 switch (autofill_action_) { 445 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* 487 // TODO(isherman): There seem to be rare cases where this code *is*
447 // reachable: see [ http://crbug.com/96321#c6 ]. Ideally we would 488 // 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 489 // 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 490 // have been unable to reproduce such a case locally. If you hit this
450 // NOTREACHED(), please file a bug against me. 491 // NOTREACHED(), please file a bug against me.
451 NOTREACHED(); 492 NOTREACHED();
452 } 493 }
453 } 494 }
454 495
455 void AutofillAgent::OnSetNodeText(const base::string16& value) { 496 void AutofillAgent::OnSetNodeText(const base::string16& value) {
456 SetNodeText(value, &element_); 497 WebInputElement* input_element = toWebInputElement(&element_);
Ilya Sherman 2014/02/14 02:44:40 Ditto.
ziran.sun 2014/02/17 15:43:45 Done.
498 SetNodeText(value, input_element);
457 } 499 }
458 500
459 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { 501 void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) {
460 AcceptDataListSuggestion(value); 502 AcceptDataListSuggestion(value);
461 } 503 }
462 504
463 void AutofillAgent::OnAcceptPasswordAutofillSuggestion( 505 void AutofillAgent::OnAcceptPasswordAutofillSuggestion(
464 const base::string16& username) { 506 const base::string16& username) {
465 // We need to make sure this is handled here because the browser process 507 // 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 508 // skipped it handling because it believed it would be handled here. If it
(...skipping 15 matching lines...) Expand all
482 result = WebFormElement::AutocompleteResultErrorInvalid; 524 result = WebFormElement::AutocompleteResultErrorInvalid;
483 } 525 }
484 526
485 in_flight_request_form_.finishRequestAutocomplete(result); 527 in_flight_request_form_.finishRequestAutocomplete(result);
486 in_flight_request_form_.reset(); 528 in_flight_request_form_.reset();
487 } 529 }
488 530
489 void AutofillAgent::OnPageShown() { 531 void AutofillAgent::OnPageShown() {
490 } 532 }
491 533
492 void AutofillAgent::ShowSuggestions(const WebInputElement& element, 534 void AutofillAgent::ShowSuggestions(const WebFormControlElement& element,
493 bool autofill_on_empty_values, 535 bool autofill_on_empty_values,
494 bool requires_caret_at_end, 536 bool requires_caret_at_end,
495 bool display_warning_if_disabled, 537 bool display_warning_if_disabled,
496 bool datalist_only) { 538 bool datalist_only) {
497 if (!element.isEnabled() || element.isReadOnly() || !element.isTextField() || 539 const WebInputElement* input_element = toWebInputElement(&element);
498 element.isPasswordField()) 540 if (!element.isEnabled() || element.isReadOnly())
499 return;
500 if (!datalist_only && !element.suggestedValue().isEmpty())
501 return; 541 return;
502 542
503 // Don't attempt to autofill with values that are too large or if filling 543 if (IsAutofillableInputElement(input_element)) {
504 // criteria are not met. 544 if (!input_element->isTextField() || input_element->isPasswordField())
505 WebString value = element.editingValue(); 545 return;
506 if (!datalist_only && 546 if (!datalist_only && !input_element->suggestedValue().isEmpty())
507 (value.length() > kMaxDataLength || 547 return;
508 (!autofill_on_empty_values && value.isEmpty()) || 548 // Don't attempt to autofill with values that are too large or if filling
509 (requires_caret_at_end && 549 // criteria are not met.
510 (element.selectionStart() != element.selectionEnd() || 550 WebString value = input_element->editingValue();
511 element.selectionEnd() != static_cast<int>(value.length()))))) { 551 if (!datalist_only &&
512 // Any popup currently showing is obsolete. 552 (value.length() > kMaxDataLength ||
513 HideAutofillUI(); 553 (!autofill_on_empty_values && value.isEmpty()) ||
554 (requires_caret_at_end &&
555 (input_element->selectionStart() != input_element->selectionEnd() ||
556 input_element->selectionEnd() !=
557 static_cast<int>(value.length()))))) {
558 // Any popup currently showing is obsolete.
559 HideAutofillUI();
560 return;
561 }
562
563 if (password_autofill_agent_->ShowSuggestions(*input_element))
564 return;
Ilya Sherman 2014/02/14 02:44:40 It's important that this follow the assignment of
ziran.sun 2014/02/17 15:43:45 Done.
565 } else if (IsTextAreaElement(element) &&
566 !element.toConst<WebTextAreaElement>().suggestedValue().isEmpty())
514 return; 567 return;
Ilya Sherman 2014/02/14 02:44:40 nit: Please include curly braces on the else, sinc
ziran.sun 2014/02/17 15:43:45 Done.
515 }
516 568
517 element_ = element; 569 element_ = element;
518 if (password_autofill_agent_->ShowSuggestions(element))
519 return;
520 570
521 // If autocomplete is disabled at the field level, ensure that the native 571 // 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 572 // 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() 573 // 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 574 // as it does not allow us to distinguish the case where autocomplete is
525 // disabled for *both* the element and for the form. 575 // disabled for *both* the element and for the form.
526 const base::string16 autocomplete_attribute = 576 const base::string16 autocomplete_attribute =
527 element.getAttribute("autocomplete"); 577 element.getAttribute("autocomplete");
528 if (LowerCaseEqualsASCII(autocomplete_attribute, "off")) 578 if (LowerCaseEqualsASCII(autocomplete_attribute, "off"))
529 display_warning_if_disabled = false; 579 display_warning_if_disabled = false;
530 580
531 QueryAutofillSuggestions(element, 581 QueryAutofillSuggestions(element,
532 display_warning_if_disabled, 582 display_warning_if_disabled,
533 datalist_only); 583 datalist_only);
534 } 584 }
535 585
536 void AutofillAgent::QueryAutofillSuggestions(const WebInputElement& element, 586 void AutofillAgent::QueryAutofillSuggestions(
537 bool display_warning_if_disabled, 587 const WebFormControlElement& element,
538 bool datalist_only) { 588 bool display_warning_if_disabled,
589 bool datalist_only) {
539 if (!element.document().frame()) 590 if (!element.document().frame())
540 return; 591 return;
541 592
542 static int query_counter = 0; 593 static int query_counter = 0;
543 autofill_query_id_ = query_counter++; 594 autofill_query_id_ = query_counter++;
544 display_warning_if_disabled_ = display_warning_if_disabled; 595 display_warning_if_disabled_ = display_warning_if_disabled;
596 const WebInputElement* input_element = toWebInputElement(&element);
545 597
546 // If autocomplete is disabled at the form level, we want to see if there 598 // 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 599 // 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 600 // warning. Otherwise, we want to ignore fields that disable autocomplete, so
549 // that the suggestions list does not include suggestions for these form 601 // that the suggestions list does not include suggestions for these form
550 // fields -- see comment 1 on http://crbug.com/69914 602 // fields -- see comment 1 on http://crbug.com/69914
551 const RequirementsMask requirements = 603 RequirementsMask requirements = REQUIRE_NONE;
552 element.autoComplete() ? REQUIRE_AUTOCOMPLETE : REQUIRE_NONE; 604 if (IsAutofillableInputElement(input_element))
605 requirements =
606 input_element->autoComplete() ? REQUIRE_AUTOCOMPLETE : REQUIRE_NONE;
Ilya Sherman 2014/02/14 02:44:40 nit: Please add curly braces, since this spans mul
ziran.sun 2014/02/17 15:43:45 Done.
553 607
554 FormData form; 608 FormData form;
555 FormFieldData field; 609 FormFieldData field;
556 if (!FindFormAndFieldForInputElement(element, &form, &field, requirements)) { 610 if (!FindFormAndFieldForFormControlElement(element, &form,
611 &field, requirements)) {
Ilya Sherman 2014/02/14 02:44:40 nit: This is a strange way to wrap the line. Prob
ziran.sun 2014/02/17 15:43:45 Done.
557 // If we didn't find the cached form, at least let autocomplete have a shot 612 // If we didn't find the cached form, at least let autocomplete have a shot
558 // at providing suggestions. 613 // at providing suggestions.
559 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field); 614 WebFormControlElementToFormField(element, EXTRACT_VALUE, &field);
560 } 615 }
561 if (datalist_only) 616 if (datalist_only)
562 field.should_autocomplete = false; 617 field.should_autocomplete = false;
563 618
564 gfx::RectF bounding_box_scaled = 619 gfx::RectF bounding_box_scaled =
565 GetScaledBoundingBox(web_view_->pageScaleFactor(), &element_); 620 GetScaledBoundingBox(web_view_->pageScaleFactor(), &element_);
566 621
567 // Find the datalist values and send them to the browser process. 622 if (IsAutofillableInputElement(input_element)) {
568 std::vector<base::string16> data_list_values; 623 // Find the datalist values and send them to the browser process.
569 std::vector<base::string16> data_list_labels; 624 std::vector<base::string16> data_list_values;
570 GetDataListSuggestions(element_, 625 std::vector<base::string16> data_list_labels;
626 GetDataListSuggestions(*input_element,
571 datalist_only, 627 datalist_only,
572 &data_list_values, 628 &data_list_values,
573 &data_list_labels); 629 &data_list_labels);
574 TrimStringVectorForIPC(&data_list_values); 630 TrimStringVectorForIPC(&data_list_values);
575 TrimStringVectorForIPC(&data_list_labels); 631 TrimStringVectorForIPC(&data_list_labels);
576 632
577 Send(new AutofillHostMsg_SetDataList(routing_id(), 633 Send(new AutofillHostMsg_SetDataList(routing_id(),
578 data_list_values, 634 data_list_values,
579 data_list_labels)); 635 data_list_labels));
580 636 }
581 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(), 637 Send(new AutofillHostMsg_QueryFormFieldAutofill(routing_id(),
582 autofill_query_id_, 638 autofill_query_id_,
583 form, 639 form,
584 field, 640 field,
585 bounding_box_scaled, 641 bounding_box_scaled,
586 display_warning_if_disabled)); 642 display_warning_if_disabled));
587 } 643 }
588 644
589 void AutofillAgent::FillAutofillFormData(const WebNode& node, 645 void AutofillAgent::FillAutofillFormData(const WebNode& node,
590 int unique_id, 646 int unique_id,
591 AutofillAction action) { 647 AutofillAction action) {
592 DCHECK_GT(unique_id, 0); 648 DCHECK_GT(unique_id, 0);
593 649
594 static int query_counter = 0; 650 static int query_counter = 0;
595 autofill_query_id_ = query_counter++; 651 autofill_query_id_ = query_counter++;
596 652
597 FormData form; 653 FormData form;
598 FormFieldData field; 654 FormFieldData field;
599 if (!FindFormAndFieldForInputElement(node.toConst<WebInputElement>(), &form, 655 if (!FindFormAndFieldForFormControlElement(
600 &field, REQUIRE_AUTOCOMPLETE)) { 656 node.toConst<WebFormControlElement>(),
Ilya Sherman 2014/02/14 02:44:40 nit: This should be indented four spaces from the
ziran.sun 2014/02/17 15:43:45 Done.
657 &form,
658 &field,
659 REQUIRE_AUTOCOMPLETE)) {
601 return; 660 return;
602 } 661 }
603 662
604 autofill_action_ = action; 663 autofill_action_ = action;
605 Send(new AutofillHostMsg_FillAutofillFormData( 664 Send(new AutofillHostMsg_FillAutofillFormData(
606 routing_id(), autofill_query_id_, form, field, unique_id)); 665 routing_id(), autofill_query_id_, form, field, unique_id));
607 } 666 }
608 667
609 void AutofillAgent::SetNodeText(const base::string16& value, 668 void AutofillAgent::SetNodeText(const base::string16& value,
610 blink::WebInputElement* node) { 669 blink::WebInputElement* node) {
(...skipping 19 matching lines...) Expand all
630 // Only monitors dynamic forms created in the top frame. Dynamic forms 689 // Only monitors dynamic forms created in the top frame. Dynamic forms
631 // inserted in iframes are not captured yet. 690 // inserted in iframes are not captured yet.
632 if (!frame->parent()) { 691 if (!frame->parent()) {
633 password_autofill_agent_->OnDynamicFormsSeen(frame); 692 password_autofill_agent_->OnDynamicFormsSeen(frame);
634 return; 693 return;
635 } 694 }
636 } 695 }
637 } 696 }
638 697
639 } // namespace autofill 698 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698