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

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

Issue 309063006: Do not autofill element when there is no autofill suggestion from profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update code as per further review comments. Created 6 years, 6 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 530
531 // Sets the |field|'s value to the value in |data|. 531 // Sets the |field|'s value to the value in |data|.
532 // Also sets the "autofilled" attribute, causing the background to be yellow. 532 // Also sets the "autofilled" attribute, causing the background to be yellow.
533 void FillFormField(const FormFieldData& data, 533 void FillFormField(const FormFieldData& data,
534 bool is_initiating_node, 534 bool is_initiating_node,
535 blink::WebFormControlElement* field) { 535 blink::WebFormControlElement* field) {
536 // Nothing to fill. 536 // Nothing to fill.
537 if (data.value.empty()) 537 if (data.value.empty())
538 return; 538 return;
539 539
540 if (!data.is_autofilled)
541 return;
542
540 field->setAutofilled(true); 543 field->setAutofilled(true);
541 544
542 WebInputElement* input_element = toWebInputElement(field); 545 WebInputElement* input_element = toWebInputElement(field);
543 if (IsCheckableElement(input_element)) { 546 if (IsCheckableElement(input_element)) {
544 input_element->setChecked(data.is_checked, true); 547 input_element->setChecked(data.is_checked, true);
545 } else { 548 } else {
546 base::string16 value = data.value; 549 base::string16 value = data.value;
547 if (IsTextInput(input_element) || IsMonthInput(input_element)) { 550 if (IsTextInput(input_element) || IsMonthInput(input_element)) {
548 // If the maxlength attribute contains a negative value, maxLength() 551 // If the maxlength attribute contains a negative value, maxLength()
549 // returns the default maxlength value. 552 // returns the default maxlength value.
(...skipping 14 matching lines...) Expand all
564 567
565 // Sets the |field|'s "suggested" (non JS visible) value to the value in |data|. 568 // Sets the |field|'s "suggested" (non JS visible) value to the value in |data|.
566 // Also sets the "autofilled" attribute, causing the background to be yellow. 569 // Also sets the "autofilled" attribute, causing the background to be yellow.
567 void PreviewFormField(const FormFieldData& data, 570 void PreviewFormField(const FormFieldData& data,
568 bool is_initiating_node, 571 bool is_initiating_node,
569 blink::WebFormControlElement* field) { 572 blink::WebFormControlElement* field) {
570 // Nothing to preview. 573 // Nothing to preview.
571 if (data.value.empty()) 574 if (data.value.empty())
572 return; 575 return;
573 576
577 if (!data.is_autofilled)
578 return;
579
574 // Preview input, textarea and select fields. For input fields, excludes 580 // Preview input, textarea and select fields. For input fields, excludes
575 // checkboxes and radio buttons, as there is no provision for 581 // checkboxes and radio buttons, as there is no provision for
576 // setSuggestedCheckedValue in WebInputElement. 582 // setSuggestedCheckedValue in WebInputElement.
577 WebInputElement* input_element = toWebInputElement(field); 583 WebInputElement* input_element = toWebInputElement(field);
578 if (IsTextInput(input_element) || IsMonthInput(input_element)) { 584 if (IsTextInput(input_element) || IsMonthInput(input_element)) {
579 // If the maxlength attribute contains a negative value, maxLength() 585 // If the maxlength attribute contains a negative value, maxLength()
580 // returns the default maxlength value. 586 // returns the default maxlength value.
581 input_element->setSuggestedValue( 587 input_element->setSuggestedValue(
582 data.value.substr(0, input_element->maxLength())); 588 data.value.substr(0, input_element->maxLength()));
583 input_element->setAutofilled(true); 589 input_element->setAutofilled(true);
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 1184
1179 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) { 1185 gfx::RectF GetScaledBoundingBox(float scale, WebFormControlElement* element) {
1180 gfx::Rect bounding_box(element->boundsInViewportSpace()); 1186 gfx::Rect bounding_box(element->boundsInViewportSpace());
1181 return gfx::RectF(bounding_box.x() * scale, 1187 return gfx::RectF(bounding_box.x() * scale,
1182 bounding_box.y() * scale, 1188 bounding_box.y() * scale,
1183 bounding_box.width() * scale, 1189 bounding_box.width() * scale,
1184 bounding_box.height() * scale); 1190 bounding_box.height() * scale);
1185 } 1191 }
1186 1192
1187 } // namespace autofill 1193 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698