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

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

Issue 1671753004: [Autofill] Fill fields that have an autocomplete attributes even if not in a form. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/form_autofill_util.h" 5 #include "components/autofill/content/renderer/form_autofill_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 keyword, keyword + strlen(keyword)); 1520 keyword, keyword + strlen(keyword));
1521 if (title_pos != title.end() || 1521 if (title_pos != title.end() ||
1522 path.find(keyword) != std::string::npos) { 1522 path.find(keyword) != std::string::npos) {
1523 // Found a keyword: treat this as an unowned form. 1523 // Found a keyword: treat this as an unowned form.
1524 return UnownedFormElementsAndFieldSetsToFormData( 1524 return UnownedFormElementsAndFieldSetsToFormData(
1525 fieldsets, control_elements, element, document, extract_mask, form, 1525 fieldsets, control_elements, element, document, extract_mask, form,
1526 field); 1526 field);
1527 } 1527 }
1528 } 1528 }
1529 1529
1530 return false; 1530 // Since it's not a checkout flow, only add fields that have an autocomplete
Mathieu 2016/02/05 18:39:06 *a non-"off" autocomplete attribute
sebsg 2016/02/05 20:08:00 Done.
1531 // attribute to the formless autofill.
1532 std::vector<WebFormControlElement> elements_with_autocomplete;
1533 for (const WebFormControlElement& element : control_elements) {
1534 blink::WebString autocomplete = element.getAttribute("autocomplete");
1535 if (autocomplete.utf8() != "" && autocomplete.utf8() != "off")
Mathieu 2016/02/05 18:39:06 Other methods seem to define statics like so: CR_
Mathieu 2016/02/05 18:39:06 if (autocomplete.length() && ...
sebsg 2016/02/05 20:08:00 Done.
sebsg 2016/02/05 20:08:00 Done.
1536 elements_with_autocomplete.push_back(element);
1537 }
1538
1539 if (elements_with_autocomplete.empty())
1540 return false;
1541
1542 form->is_syntehtic_non_checkout_form = true;
Mathieu 2016/02/05 18:39:06 Could we do only with a |non_checkout| attribute i
sebsg 2016/02/05 20:08:00 Done.
1543
1544 return UnownedFormElementsAndFieldSetsToFormData(
1545 fieldsets, elements_with_autocomplete, element, document, extract_mask,
1546 form, field);
1531 } 1547 }
1532 1548
1533 bool UnownedPasswordFormElementsAndFieldSetsToFormData( 1549 bool UnownedPasswordFormElementsAndFieldSetsToFormData(
1534 const std::vector<blink::WebElement>& fieldsets, 1550 const std::vector<blink::WebElement>& fieldsets,
1535 const std::vector<blink::WebFormControlElement>& control_elements, 1551 const std::vector<blink::WebFormControlElement>& control_elements,
1536 const blink::WebFormControlElement* element, 1552 const blink::WebFormControlElement* element,
1537 const blink::WebDocument& document, 1553 const blink::WebDocument& document,
1538 ExtractMask extract_mask, 1554 ExtractMask extract_mask,
1539 FormData* form, 1555 FormData* form,
1540 FormFieldData* field) { 1556 FormFieldData* field) {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1735 // Zero selection start is for password manager, which can show usernames 1751 // Zero selection start is for password manager, which can show usernames
1736 // that do not begin with the user input value. 1752 // that do not begin with the user input value.
1737 selection_start = (offset == base::string16::npos) ? 0 : offset; 1753 selection_start = (offset == base::string16::npos) ? 0 : offset;
1738 } 1754 }
1739 1755
1740 input_element->setSelectionRange(selection_start, suggestion.length()); 1756 input_element->setSelectionRange(selection_start, suggestion.length());
1741 } 1757 }
1742 1758
1743 } // namespace form_util 1759 } // namespace form_util
1744 } // namespace autofill 1760 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698