OLD | NEW |
---|---|
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/password_autofill_agent.h" | 5 #include "components/autofill/content/renderer/password_autofill_agent.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "components/autofill/content/common/autofill_messages.h" | 13 #include "components/autofill/content/common/autofill_messages.h" |
13 #include "components/autofill/content/renderer/form_autofill_util.h" | 14 #include "components/autofill/content/renderer/form_autofill_util.h" |
14 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 15 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
15 #include "components/autofill/content/renderer/renderer_save_password_progress_l ogger.h" | 16 #include "components/autofill/content/renderer/renderer_save_password_progress_l ogger.h" |
16 #include "components/autofill/core/common/autofill_constants.h" | 17 #include "components/autofill/core/common/autofill_constants.h" |
18 #include "components/autofill/core/common/autofill_switches.h" | |
17 #include "components/autofill/core/common/form_field_data.h" | 19 #include "components/autofill/core/common/form_field_data.h" |
18 #include "components/autofill/core/common/password_form.h" | 20 #include "components/autofill/core/common/password_form.h" |
19 #include "components/autofill/core/common/password_form_fill_data.h" | 21 #include "components/autofill/core/common/password_form_fill_data.h" |
20 #include "content/public/renderer/document_state.h" | 22 #include "content/public/renderer/document_state.h" |
21 #include "content/public/renderer/navigation_state.h" | 23 #include "content/public/renderer/navigation_state.h" |
22 #include "content/public/renderer/render_frame.h" | 24 #include "content/public/renderer/render_frame.h" |
23 #include "content/public/renderer/render_view.h" | 25 #include "content/public/renderer/render_view.h" |
24 #include "third_party/WebKit/public/platform/WebVector.h" | 26 #include "third_party/WebKit/public/platform/WebVector.h" |
25 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 27 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
26 #include "third_party/WebKit/public/web/WebDocument.h" | 28 #include "third_party/WebKit/public/web/WebDocument.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 // iteration remain in the result set. | 116 // iteration remain in the result set. |
115 // Note: clear will remove a reference from each InputElement. | 117 // Note: clear will remove a reference from each InputElement. |
116 if (!found_input) { | 118 if (!found_input) { |
117 result->input_elements.clear(); | 119 result->input_elements.clear(); |
118 return false; | 120 return false; |
119 } | 121 } |
120 | 122 |
121 return true; | 123 return true; |
122 } | 124 } |
123 | 125 |
126 bool ShouldFillOnAccountSelect() { | |
127 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
128 switches::kEnableFillOnAccountSelect)) { | |
129 return true; | |
130 } | |
131 | |
132 // This is made explicit in anticiption of experimental groups being added. | |
133 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
134 switches::kDisableFillOnAccountSelect)) { | |
135 return false; | |
136 } | |
137 | |
138 // TODO(jww): Add experimental groups check here. | |
Garrett Casto
2014/12/10 06:26:59
You can add this check now. It should just be one
jww
2014/12/10 22:56:03
Done.
| |
139 | |
140 return false; | |
141 } | |
142 | |
124 // Helper to search the given form element for the specified input elements in | 143 // Helper to search the given form element for the specified input elements in |
125 // |data|, and add results to |result|. | 144 // |data|, and add results to |result|. |
126 bool FindFormInputElements(blink::WebFormElement* form_element, | 145 bool FindFormInputElements(blink::WebFormElement* form_element, |
127 const PasswordFormFillData& data, | 146 const PasswordFormFillData& data, |
128 FormElements* result) { | 147 FormElements* result) { |
129 return FindFormInputElement(form_element, data.password_field, result) && | 148 return FindFormInputElement(form_element, data.password_field, result) && |
130 (!FillDataContainsUsername(data) || | 149 (!FillDataContainsUsername(data) || |
131 FindFormInputElement(form_element, data.username_field, result)); | 150 FindFormInputElement(form_element, data.username_field, result)); |
132 } | 151 } |
133 | 152 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 } | 287 } |
269 } | 288 } |
270 | 289 |
271 return false; | 290 return false; |
272 } | 291 } |
273 | 292 |
274 // This function attempts to fill |username_element| and |password_element| | 293 // This function attempts to fill |username_element| and |password_element| |
275 // with values from |fill_data|. The |password_element| will only have the | 294 // with values from |fill_data|. The |password_element| will only have the |
276 // |suggestedValue| set, and will be registered for copying that to the real | 295 // |suggestedValue| set, and will be registered for copying that to the real |
277 // value through |registration_callback|. The function returns true when | 296 // value through |registration_callback|. The function returns true when |
278 // selected username comes from |fill_data.other_possible_usernames|. | 297 // selected username comes from |fill_data.other_possible_usernames|. |options| |
298 // should be a bitwise mask of FillUserNameAndPasswordOptions values. | |
279 bool FillUserNameAndPassword( | 299 bool FillUserNameAndPassword( |
280 blink::WebInputElement* username_element, | 300 blink::WebInputElement* username_element, |
281 blink::WebInputElement* password_element, | 301 blink::WebInputElement* password_element, |
282 const PasswordFormFillData& fill_data, | 302 const PasswordFormFillData& fill_data, |
283 bool exact_username_match, | 303 bool exact_username_match, |
284 bool set_selection, | 304 bool set_selection, |
285 base::Callback<void(blink::WebInputElement*)> registration_callback) { | 305 base::Callback<void(blink::WebInputElement*)> registration_callback) { |
286 bool other_possible_username_selected = false; | 306 bool other_possible_username_selected = false; |
287 // Don't fill username if password can't be set. | 307 // Don't fill username if password can't be set. |
288 if (!IsElementAutocompletable(*password_element)) | 308 if (!IsElementAutocompletable(*password_element)) |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 // Do not fill if the password field is in an iframe. | 404 // Do not fill if the password field is in an iframe. |
385 DCHECK(password_element.document().frame()); | 405 DCHECK(password_element.document().frame()); |
386 if (password_element.document().frame()->parent()) | 406 if (password_element.document().frame()->parent()) |
387 return false; | 407 return false; |
388 | 408 |
389 // If we can't modify the password, don't try to set the username | 409 // If we can't modify the password, don't try to set the username |
390 if (!IsElementAutocompletable(password_element)) | 410 if (!IsElementAutocompletable(password_element)) |
391 return false; | 411 return false; |
392 | 412 |
393 bool form_contains_username_field = FillDataContainsUsername(fill_data); | 413 bool form_contains_username_field = FillDataContainsUsername(fill_data); |
394 // Try to set the username to the preferred name, but only if the field | 414 // If the form contains a username field, try to set the username to the |
395 // can be set and isn't prefilled. | 415 // preferred name, but only if: |
396 if (form_contains_username_field && | 416 // (a) The username element is autocompletable, and |
397 IsElementAutocompletable(username_element) && | 417 // (b) The fill-on-account-select flag is not set, and |
398 username_element.value().isEmpty()) { | 418 // (c) The username element isn't prefilled |
399 // TODO(tkent): Check maxlength and pattern. | 419 // |
400 username_element.setValue(fill_data.username_field.value, true); | 420 // If (a) is true but (b) is false, then just mark the username element as |
421 // autofilled and return so the fill step is skipped. | |
422 // | |
423 // If (a) is false but (b) is true, then the username element should not be | |
424 // autofilled, but the user should still be able to select to fill the | |
425 // password element, so the password element must be marked as autofilled and | |
426 // the fill step should also be skipped. | |
427 // | |
428 // In all other cases, do nothing. | |
429 if (form_contains_username_field) { | |
430 if (IsElementAutocompletable(username_element)) { | |
431 if (ShouldFillOnAccountSelect()) { | |
432 username_element.setAutofilled(true); | |
433 return false; | |
434 } else if (username_element.value().isEmpty()) { | |
435 // TODO(tkent): Check maxlength and pattern. | |
436 username_element.setValue(fill_data.username_field.value, true); | |
437 } | |
438 } else if (ShouldFillOnAccountSelect()) { | |
439 password_element.setAutofilled(true); | |
440 return false; | |
441 } | |
401 } | 442 } |
402 | 443 |
403 // Fill if we have an exact match for the username. Note that this sets | 444 // Fill if we have an exact match for the username. Note that this sets |
404 // username to autofilled. | 445 // username to autofilled. |
405 return FillUserNameAndPassword(&username_element, | 446 return FillUserNameAndPassword(&username_element, |
406 &password_element, | 447 &password_element, |
407 fill_data, | 448 fill_data, |
408 true /* exact_username_match */, | 449 true /* exact_username_match */, |
409 false /* set_selection */, | 450 false /* set_selection */, |
410 registration_callback); | 451 registration_callback); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
502 | 543 |
503 blink::WebInputElement password = password_info.password_field; | 544 blink::WebInputElement password = password_info.password_field; |
504 if (!IsElementEditable(password)) | 545 if (!IsElementEditable(password)) |
505 return false; | 546 return false; |
506 | 547 |
507 blink::WebInputElement username = element; // We need a non-const. | 548 blink::WebInputElement username = element; // We need a non-const. |
508 | 549 |
509 // Do not set selection when ending an editing session, otherwise it can | 550 // Do not set selection when ending an editing session, otherwise it can |
510 // mess with focus. | 551 // mess with focus. |
511 if (FillUserNameAndPassword( | 552 if (FillUserNameAndPassword( |
512 &username, | 553 &username, &password, fill_data, true, false, |
513 &password, | |
514 fill_data, | |
515 true /* exact_username_match */, | |
516 false /* set_selection */, | |
517 base::Bind(&PasswordValueGatekeeper::RegisterElement, | 554 base::Bind(&PasswordValueGatekeeper::RegisterElement, |
518 base::Unretained(&gatekeeper_)))) { | 555 base::Unretained(&gatekeeper_)))) { |
519 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SELECTED; | 556 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SELECTED; |
520 } | 557 } |
521 return true; | 558 return true; |
522 } | 559 } |
523 | 560 |
524 bool PasswordAutofillAgent::TextDidChangeInTextField( | 561 bool PasswordAutofillAgent::TextDidChangeInTextField( |
525 const blink::WebInputElement& element) { | 562 const blink::WebInputElement& element) { |
526 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083 | 563 // TODO(vabr): Get a mutable argument instead. http://crbug.com/397083 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 | 605 |
569 if (!element.isText() || !IsElementAutocompletable(element) || | 606 if (!element.isText() || !IsElementAutocompletable(element) || |
570 !IsElementAutocompletable(password)) { | 607 !IsElementAutocompletable(password)) { |
571 return false; | 608 return false; |
572 } | 609 } |
573 | 610 |
574 // Don't inline autocomplete if the user is deleting, that would be confusing. | 611 // Don't inline autocomplete if the user is deleting, that would be confusing. |
575 // But refresh the popup. Note, since this is ours, return true to signal | 612 // But refresh the popup. Note, since this is ours, return true to signal |
576 // no further processing is required. | 613 // no further processing is required. |
577 if (iter->second.backspace_pressed_last) { | 614 if (iter->second.backspace_pressed_last) { |
578 ShowSuggestionPopup(iter->second.fill_data, element, false); | 615 ShowSuggestionPopup(iter->second.fill_data, element, false, false); |
579 return true; | 616 return true; |
580 } | 617 } |
581 | 618 |
582 blink::WebString name = element.nameForAutofill(); | 619 blink::WebString name = element.nameForAutofill(); |
583 if (name.isEmpty()) | 620 if (name.isEmpty()) |
584 return false; // If the field has no name, then we won't have values. | 621 return false; // If the field has no name, then we won't have values. |
585 | 622 |
586 // Don't attempt to autofill with values that are too large. | 623 // Don't attempt to autofill with values that are too large. |
587 if (element.value().length() > kMaximumTextSizeForAutocomplete) | 624 if (element.value().length() > kMaximumTextSizeForAutocomplete) |
588 return false; | 625 return false; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
665 const blink::WebNode& node) { | 702 const blink::WebNode& node) { |
666 blink::WebInputElement username_element; | 703 blink::WebInputElement username_element; |
667 PasswordInfo* password_info; | 704 PasswordInfo* password_info; |
668 if (!FindLoginInfo(node, &username_element, &password_info)) | 705 if (!FindLoginInfo(node, &username_element, &password_info)) |
669 return false; | 706 return false; |
670 | 707 |
671 ClearPreview(&username_element, &password_info->password_field); | 708 ClearPreview(&username_element, &password_info->password_field); |
672 return true; | 709 return true; |
673 } | 710 } |
674 | 711 |
712 PasswordAutofillAgent::LoginToPasswordInfoMap::iterator | |
Garrett Casto
2014/12/10 06:26:59
Given that we never actually need the bare iterato
jww
2014/12/10 22:56:03
Done.
| |
713 PasswordAutofillAgent::FindPasswordInfoForElement( | |
714 const blink::WebInputElement& element) { | |
715 const blink::WebInputElement* username_element; | |
716 if (!element.isPasswordField()) { | |
717 username_element = &element; | |
718 } else { | |
719 PasswordToLoginMap::const_iterator password_iter = | |
720 password_to_username_.find(element); | |
721 if (password_iter == password_to_username_.end()) | |
722 return login_to_password_info_.end(); | |
723 username_element = &password_iter->second; | |
724 } | |
725 | |
726 return login_to_password_info_.find(*username_element); | |
727 } | |
728 | |
675 bool PasswordAutofillAgent::ShowSuggestions( | 729 bool PasswordAutofillAgent::ShowSuggestions( |
676 const blink::WebInputElement& element, | 730 const blink::WebInputElement& element, |
677 bool show_all) { | 731 bool show_all) { |
678 LoginToPasswordInfoMap::const_iterator iter = | 732 LoginToPasswordInfoMap::const_iterator iter = |
679 login_to_password_info_.find(element); | 733 FindPasswordInfoForElement(element); |
680 if (iter == login_to_password_info_.end()) | 734 if (iter == login_to_password_info_.end()) |
681 return false; | 735 return false; |
682 | 736 |
683 // If autocomplete='off' is set on the form elements, no suggestion dialog | 737 // If autocomplete='off' is set on the form elements, no suggestion dialog |
684 // should be shown. However, return |true| to indicate that this is a known | 738 // should be shown. However, return |true| to indicate that this is a known |
685 // password form and that the request to show suggestions has been handled (as | 739 // password form and that the request to show suggestions has been handled (as |
686 // a no-op). | 740 // a no-op). |
687 if (!IsElementAutocompletable(element) || | 741 if (!IsElementAutocompletable(element) || |
688 !IsElementAutocompletable(iter->second.password_field)) | 742 !IsElementAutocompletable(iter->second.password_field)) |
689 return true; | 743 return true; |
690 | 744 |
691 return ShowSuggestionPopup(iter->second.fill_data, element, show_all); | 745 // If the element is a password field, a popup should only be shown if the |
746 // corresponding username element is not editable since it is only in that | |
747 // case that the username element does not have a suggestions popup. | |
748 if (element.isPasswordField() && IsElementEditable(iter->first)) | |
749 return true; | |
750 | |
751 // Chrome should never show more than one account for a password element since | |
752 // this implies that the username element cannot be modified. Thus even if | |
753 // |show_all| is true, check if the element in question is a password element | |
754 // for the call to ShowSuggestionPopup. | |
755 return ShowSuggestionPopup(iter->second.fill_data, iter->first, | |
756 show_all && !element.isPasswordField(), | |
757 element.isPasswordField()); | |
692 } | 758 } |
693 | 759 |
694 bool PasswordAutofillAgent::OriginCanAccessPasswordManager( | 760 bool PasswordAutofillAgent::OriginCanAccessPasswordManager( |
695 const blink::WebSecurityOrigin& origin) { | 761 const blink::WebSecurityOrigin& origin) { |
696 return origin.canAccessPasswordManager(); | 762 return origin.canAccessPasswordManager(); |
697 } | 763 } |
698 | 764 |
699 void PasswordAutofillAgent::OnDynamicFormsSeen() { | 765 void PasswordAutofillAgent::OnDynamicFormsSeen() { |
700 SendPasswordForms(false /* only_visible */); | 766 SendPasswordForms(false /* only_visible */); |
701 } | 767 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 //////////////////////////////////////////////////////////////////////////////// | 1101 //////////////////////////////////////////////////////////////////////////////// |
1036 // PasswordAutofillAgent, private: | 1102 // PasswordAutofillAgent, private: |
1037 | 1103 |
1038 PasswordAutofillAgent::PasswordInfo::PasswordInfo() | 1104 PasswordAutofillAgent::PasswordInfo::PasswordInfo() |
1039 : backspace_pressed_last(false), password_was_edited_last(false) { | 1105 : backspace_pressed_last(false), password_was_edited_last(false) { |
1040 } | 1106 } |
1041 | 1107 |
1042 bool PasswordAutofillAgent::ShowSuggestionPopup( | 1108 bool PasswordAutofillAgent::ShowSuggestionPopup( |
1043 const PasswordFormFillData& fill_data, | 1109 const PasswordFormFillData& fill_data, |
1044 const blink::WebInputElement& user_input, | 1110 const blink::WebInputElement& user_input, |
1045 bool show_all) { | 1111 bool show_all, |
1112 bool show_on_password_field) { | |
1046 blink::WebFrame* frame = user_input.document().frame(); | 1113 blink::WebFrame* frame = user_input.document().frame(); |
1047 if (!frame) | 1114 if (!frame) |
1048 return false; | 1115 return false; |
1049 | 1116 |
1050 blink::WebView* webview = frame->view(); | 1117 blink::WebView* webview = frame->view(); |
1051 if (!webview) | 1118 if (!webview) |
1052 return false; | 1119 return false; |
1053 | 1120 |
1054 FormData form; | 1121 FormData form; |
1055 FormFieldData field; | 1122 FormFieldData field; |
1056 FindFormAndFieldForFormControlElement( | 1123 FindFormAndFieldForFormControlElement( |
1057 user_input, &form, &field, REQUIRE_NONE); | 1124 user_input, &form, &field, REQUIRE_NONE); |
1058 | 1125 |
1059 blink::WebInputElement selected_element = user_input; | 1126 blink::WebInputElement selected_element = user_input; |
1127 if (show_on_password_field) { | |
1128 LoginToPasswordInfoMap::const_iterator iter = | |
1129 login_to_password_info_.find(user_input); | |
1130 DCHECK(iter != login_to_password_info_.end()); | |
1131 selected_element = iter->second.password_field; | |
1132 } | |
1060 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); | 1133 gfx::Rect bounding_box(selected_element.boundsInViewportSpace()); |
1061 | 1134 |
1062 LoginToPasswordInfoKeyMap::const_iterator key_it = | 1135 LoginToPasswordInfoKeyMap::const_iterator key_it = |
1063 login_to_password_info_key_.find(user_input); | 1136 login_to_password_info_key_.find(user_input); |
1064 DCHECK(key_it != login_to_password_info_key_.end()); | 1137 DCHECK(key_it != login_to_password_info_key_.end()); |
1065 | 1138 |
1066 float scale = | 1139 float scale = |
1067 render_frame()->GetRenderView()->GetWebView()->pageScaleFactor(); | 1140 render_frame()->GetRenderView()->GetWebView()->pageScaleFactor(); |
1068 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, | 1141 gfx::RectF bounding_box_scaled(bounding_box.x() * scale, |
1069 bounding_box.y() * scale, | 1142 bounding_box.y() * scale, |
1070 bounding_box.width() * scale, | 1143 bounding_box.width() * scale, |
1071 bounding_box.height() * scale); | 1144 bounding_box.height() * scale); |
1072 int options = 0; | 1145 int options = 0; |
1073 if (show_all) | 1146 if (show_all) |
1074 options |= SHOW_ALL; | 1147 options |= SHOW_ALL; |
1148 if (show_on_password_field) | |
1149 options |= IS_PASSWORD_FIELD; | |
1075 Send(new AutofillHostMsg_ShowPasswordSuggestions( | 1150 Send(new AutofillHostMsg_ShowPasswordSuggestions( |
1076 routing_id(), key_it->second, field.text_direction, user_input.value(), | 1151 routing_id(), key_it->second, field.text_direction, user_input.value(), |
1077 options, bounding_box_scaled)); | 1152 options, bounding_box_scaled)); |
1078 | 1153 |
1079 bool suggestions_present = false; | 1154 bool suggestions_present = false; |
1080 if (GetSuggestionsStats(fill_data, user_input.value(), show_all, | 1155 if (GetSuggestionsStats(fill_data, user_input.value(), show_all, |
1081 &suggestions_present)) { | 1156 &suggestions_present)) { |
1082 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN; | 1157 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SHOWN; |
1083 } | 1158 } |
1084 return suggestions_present; | 1159 return suggestions_present; |
(...skipping 10 matching lines...) Expand all Loading... | |
1095 blink::WebInputElement password = password_input; | 1170 blink::WebInputElement password = password_input; |
1096 | 1171 |
1097 // Don't inline autocomplete if the caret is not at the end. | 1172 // Don't inline autocomplete if the caret is not at the end. |
1098 // TODO(jcivelli): is there a better way to test the caret location? | 1173 // TODO(jcivelli): is there a better way to test the caret location? |
1099 if (username.selectionStart() != username.selectionEnd() || | 1174 if (username.selectionStart() != username.selectionEnd() || |
1100 username.selectionEnd() != static_cast<int>(username.value().length())) { | 1175 username.selectionEnd() != static_cast<int>(username.value().length())) { |
1101 return; | 1176 return; |
1102 } | 1177 } |
1103 | 1178 |
1104 // Show the popup with the list of available usernames. | 1179 // Show the popup with the list of available usernames. |
1105 ShowSuggestionPopup(fill_data, username, false); | 1180 ShowSuggestionPopup(fill_data, username, false, false); |
1106 | 1181 |
1107 #if !defined(OS_ANDROID) | 1182 #if !defined(OS_ANDROID) |
1108 // Fill the user and password field with the most relevant match. Android | 1183 // Fill the user and password field with the most relevant match. Android |
1109 // only fills in the fields after the user clicks on the suggestion popup. | 1184 // only fills in the fields after the user clicks on the suggestion popup. |
1110 if (FillUserNameAndPassword( | 1185 if (FillUserNameAndPassword( |
1111 &username, | 1186 &username, &password, fill_data, false, true, |
Garrett Casto
2014/12/10 06:26:59
Nit: This shouldn't need to be changed.
jww
2014/12/10 22:56:03
Done.
| |
1112 &password, | |
1113 fill_data, | |
1114 false /* exact_username_match */, | |
1115 true /* set_selection */, | |
1116 base::Bind(&PasswordValueGatekeeper::RegisterElement, | 1187 base::Bind(&PasswordValueGatekeeper::RegisterElement, |
1117 base::Unretained(&gatekeeper_)))) { | 1188 base::Unretained(&gatekeeper_)))) { |
1118 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SELECTED; | 1189 usernames_usage_ = OTHER_POSSIBLE_USERNAME_SELECTED; |
1119 } | 1190 } |
1120 #endif | 1191 #endif |
1121 } | 1192 } |
1122 | 1193 |
1123 void PasswordAutofillAgent::FrameClosing() { | 1194 void PasswordAutofillAgent::FrameClosing() { |
1124 for (auto const& iter : login_to_password_info_) { | 1195 for (auto const& iter : login_to_password_info_) { |
1125 login_to_password_info_key_.erase(iter.first); | 1196 login_to_password_info_key_.erase(iter.first); |
1126 password_to_username_.erase(iter.second.password_field); | 1197 password_to_username_.erase(iter.second.password_field); |
1127 } | 1198 } |
1128 login_to_password_info_.clear(); | 1199 login_to_password_info_.clear(); |
1129 provisionally_saved_form_.reset(); | 1200 provisionally_saved_form_.reset(); |
1130 } | 1201 } |
1131 | 1202 |
1132 bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode& node, | 1203 bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode& node, |
1133 blink::WebInputElement* found_input, | 1204 blink::WebInputElement* found_input, |
1134 PasswordInfo** found_password) { | 1205 PasswordInfo** found_password) { |
1135 if (!node.isElementNode()) | 1206 if (!node.isElementNode()) |
1136 return false; | 1207 return false; |
1137 | 1208 |
1138 blink::WebElement element = node.toConst<blink::WebElement>(); | 1209 blink::WebElement element = node.toConst<blink::WebElement>(); |
1139 if (!element.hasHTMLTagName("input")) | 1210 if (!element.hasHTMLTagName("input")) |
1140 return false; | 1211 return false; |
1141 | 1212 |
1142 blink::WebInputElement input = element.to<blink::WebInputElement>(); | 1213 blink::WebInputElement input = element.to<blink::WebInputElement>(); |
1143 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 1214 LoginToPasswordInfoMap::iterator iter = FindPasswordInfoForElement(input); |
1144 if (iter == login_to_password_info_.end()) | 1215 if (iter == login_to_password_info_.end()) |
1145 return false; | 1216 return false; |
1146 | 1217 |
1147 *found_input = input; | 1218 *found_input = input; |
1148 *found_password = &iter->second; | 1219 *found_password = &iter->second; |
1149 return true; | 1220 return true; |
1150 } | 1221 } |
1151 | 1222 |
1152 void PasswordAutofillAgent::ClearPreview( | 1223 void PasswordAutofillAgent::ClearPreview( |
1153 blink::WebInputElement* username, | 1224 blink::WebInputElement* username, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1216 agent_->WillSendSubmitEvent(frame, form); | 1287 agent_->WillSendSubmitEvent(frame, form); |
1217 } | 1288 } |
1218 | 1289 |
1219 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::WillSubmitForm( | 1290 void PasswordAutofillAgent::LegacyPasswordAutofillAgent::WillSubmitForm( |
1220 blink::WebLocalFrame* frame, | 1291 blink::WebLocalFrame* frame, |
1221 const blink::WebFormElement& form) { | 1292 const blink::WebFormElement& form) { |
1222 agent_->WillSubmitForm(frame, form); | 1293 agent_->WillSubmitForm(frame, form); |
1223 } | 1294 } |
1224 | 1295 |
1225 } // namespace autofill | 1296 } // namespace autofill |
OLD | NEW |