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

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

Issue 208453002: Add "previewing on hover" support for password field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update code as per Ilya's comment. Created 6 years, 9 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/form_autofill_util.h" 5 #include "components/autofill/content/renderer/form_autofill_util.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1040
1041 ForEachMatchingFormField(form_element, 1041 ForEachMatchingFormField(form_element,
1042 element, 1042 element,
1043 form, 1043 form,
1044 FILTER_ALL_NON_EDITIABLE_ELEMENTS, 1044 FILTER_ALL_NON_EDITIABLE_ELEMENTS,
1045 false, /* dont force override */ 1045 false, /* dont force override */
1046 &PreviewFormField); 1046 &PreviewFormField);
1047 } 1047 }
1048 1048
1049 bool ClearPreviewedFormWithElement(const WebInputElement& element, 1049 bool ClearPreviewedFormWithElement(const WebInputElement& element,
1050 bool was_autofilled) { 1050 RequirementsMask requirements,
1051 bool was_autofilled,
1052 bool was_password_autofilled) {
1051 WebFormElement form_element = element.form(); 1053 WebFormElement form_element = element.form();
1052 if (form_element.isNull()) 1054 if (form_element.isNull())
1053 return false; 1055 return false;
1054 1056
1055 std::vector<WebFormControlElement> control_elements; 1057 std::vector<WebFormControlElement> control_elements;
1056 ExtractAutofillableElements(form_element, REQUIRE_AUTOCOMPLETE, 1058 //ExtractAutofillableElements(form_element, requirements, &control_elements);
1057 &control_elements); 1059 ExtractAutofillableElements(form_element, REQUIRE_NONE, &control_elements);
1058 for (size_t i = 0; i < control_elements.size(); ++i) { 1060 for (size_t i = 0; i < control_elements.size(); ++i) {
1059 // There might be unrelated elements in this form which have already been 1061 // There might be unrelated elements in this form which have already been
1060 // auto-filled. For example, the user might have already filled the address 1062 // auto-filled. For example, the user might have already filled the address
1061 // part of a form and now be dealing with the credit card section. We only 1063 // part of a form and now be dealing with the credit card section. We only
1062 // want to reset the auto-filled status for fields that were previewed. 1064 // want to reset the auto-filled status for fields that were previewed.
1063 WebFormControlElement control_element = control_elements[i]; 1065 WebFormControlElement control_element = control_elements[i];
1064 1066
1065 // Only text input and textarea elements can be previewed. 1067 // Only text input and textarea elements can be previewed.
1066 WebInputElement* input_element = toWebInputElement(&control_element); 1068 WebInputElement* input_element = toWebInputElement(&control_element);
1067 if (!IsTextInput(input_element) && 1069 if (!IsTextInput(input_element) &&
(...skipping 14 matching lines...) Expand all
1082 control_element.to<WebTextAreaElement>().suggestedValue().isEmpty())) 1084 control_element.to<WebTextAreaElement>().suggestedValue().isEmpty()))
1083 continue; 1085 continue;
1084 1086
1085 // Clear the suggested value. For the initiating node, also restore the 1087 // Clear the suggested value. For the initiating node, also restore the
1086 // original value. 1088 // original value.
1087 if (IsTextInput(input_element) || IsMonthInput(input_element)) { 1089 if (IsTextInput(input_element) || IsMonthInput(input_element)) {
1088 input_element->setSuggestedValue(WebString()); 1090 input_element->setSuggestedValue(WebString());
1089 bool is_initiating_node = (element == *input_element); 1091 bool is_initiating_node = (element == *input_element);
1090 if (is_initiating_node) 1092 if (is_initiating_node)
1091 input_element->setAutofilled(was_autofilled); 1093 input_element->setAutofilled(was_autofilled);
1094 else if (input_element->isPasswordField())
1095 input_element->setAutofilled(was_password_autofilled);
1092 else 1096 else
1093 input_element->setAutofilled(false); 1097 input_element->setAutofilled(false);
1094 1098
1095 // Clearing the suggested value in the focused node (above) can cause 1099 // Clearing the suggested value in the focused node (above) can cause
1096 // selection to be lost. We force selection range to restore the text 1100 // selection to be lost. We force selection range to restore the text
1097 // cursor. 1101 // cursor.
1098 if (is_initiating_node) { 1102 if (is_initiating_node) {
1099 int length = input_element->value().length(); 1103 int length = input_element->value().length();
1100 input_element->setSelectionRange(length, length); 1104 input_element->setSelectionRange(length, length);
1101 } 1105 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 1190
1187 gfx::RectF GetScaledBoundingBox(float scale, WebInputElement* element) { 1191 gfx::RectF GetScaledBoundingBox(float scale, WebInputElement* element) {
1188 gfx::Rect bounding_box(element->boundsInViewportSpace()); 1192 gfx::Rect bounding_box(element->boundsInViewportSpace());
1189 return gfx::RectF(bounding_box.x() * scale, 1193 return gfx::RectF(bounding_box.x() * scale,
1190 bounding_box.y() * scale, 1194 bounding_box.y() * scale,
1191 bounding_box.width() * scale, 1195 bounding_box.width() * scale,
1192 bounding_box.height() * scale); 1196 bounding_box.height() * scale);
1193 } 1197 }
1194 1198
1195 } // namespace autofill 1199 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698