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/form_autofill_util.h" | 5 #include "components/autofill/content/renderer/form_autofill_util.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 bool IsNoScriptElement(const WebElement& element) { | 96 bool IsNoScriptElement(const WebElement& element) { |
97 CR_DEFINE_STATIC_LOCAL(WebString, kNoScript, ("noscript")); | 97 CR_DEFINE_STATIC_LOCAL(WebString, kNoScript, ("noscript")); |
98 return element.hasHTMLTagName(kNoScript); | 98 return element.hasHTMLTagName(kNoScript); |
99 } | 99 } |
100 | 100 |
101 bool HasTagName(const WebNode& node, const blink::WebString& tag) { | 101 bool HasTagName(const WebNode& node, const blink::WebString& tag) { |
102 return node.isElementNode() && node.toConst<WebElement>().hasHTMLTagName(tag); | 102 return node.isElementNode() && node.toConst<WebElement>().hasHTMLTagName(tag); |
103 } | 103 } |
104 | 104 |
105 bool IsAutofillableElement(const WebFormControlElement& element) { | |
106 const WebInputElement* input_element = toWebInputElement(&element); | |
107 return IsAutofillableInputElement(input_element) || | |
108 IsSelectElement(element) || | |
109 IsTextAreaElement(element); | |
110 } | |
111 | |
112 bool IsElementInControlElementSet( | 105 bool IsElementInControlElementSet( |
113 const WebElement& element, | 106 const WebElement& element, |
114 const std::vector<WebFormControlElement>& control_elements) { | 107 const std::vector<WebFormControlElement>& control_elements) { |
115 if (!element.isFormControlElement()) | 108 if (!element.isFormControlElement()) |
116 return false; | 109 return false; |
117 const WebFormControlElement form_control_element = | 110 const WebFormControlElement form_control_element = |
118 element.toConst<WebFormControlElement>(); | 111 element.toConst<WebFormControlElement>(); |
119 return std::find(control_elements.begin(), | 112 return std::find(control_elements.begin(), |
120 control_elements.end(), | 113 control_elements.end(), |
121 form_control_element) != control_elements.end(); | 114 form_control_element) != control_elements.end(); |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1312 | 1305 |
1313 return element->isCheckbox() || element->isRadioButton(); | 1306 return element->isCheckbox() || element->isRadioButton(); |
1314 } | 1307 } |
1315 | 1308 |
1316 bool IsAutofillableInputElement(const WebInputElement* element) { | 1309 bool IsAutofillableInputElement(const WebInputElement* element) { |
1317 return IsTextInput(element) || | 1310 return IsTextInput(element) || |
1318 IsMonthInput(element) || | 1311 IsMonthInput(element) || |
1319 IsCheckableElement(element); | 1312 IsCheckableElement(element); |
1320 } | 1313 } |
1321 | 1314 |
| 1315 bool IsAutofillableElement(const WebFormControlElement& element) { |
| 1316 const WebInputElement* input_element = toWebInputElement(&element); |
| 1317 return IsAutofillableInputElement(input_element) || |
| 1318 IsSelectElement(element) || IsTextAreaElement(element); |
| 1319 } |
| 1320 |
1322 const base::string16 GetFormIdentifier(const WebFormElement& form) { | 1321 const base::string16 GetFormIdentifier(const WebFormElement& form) { |
1323 base::string16 identifier = form.name().utf16(); | 1322 base::string16 identifier = form.name().utf16(); |
1324 CR_DEFINE_STATIC_LOCAL(WebString, kId, ("id")); | 1323 CR_DEFINE_STATIC_LOCAL(WebString, kId, ("id")); |
1325 if (identifier.empty()) | 1324 if (identifier.empty()) |
1326 identifier = form.getAttribute(kId).utf16(); | 1325 identifier = form.getAttribute(kId).utf16(); |
1327 | 1326 |
1328 return identifier; | 1327 return identifier; |
1329 } | 1328 } |
1330 | 1329 |
1331 bool IsWebNodeVisible(const blink::WebNode& node) { | 1330 bool IsWebNodeVisible(const blink::WebNode& node) { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 // Zero selection start is for password manager, which can show usernames | 1810 // Zero selection start is for password manager, which can show usernames |
1812 // that do not begin with the user input value. | 1811 // that do not begin with the user input value. |
1813 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1812 selection_start = (offset == base::string16::npos) ? 0 : offset; |
1814 } | 1813 } |
1815 | 1814 |
1816 input_element->setSelectionRange(selection_start, suggestion.length()); | 1815 input_element->setSelectionRange(selection_start, suggestion.length()); |
1817 } | 1816 } |
1818 | 1817 |
1819 } // namespace form_util | 1818 } // namespace form_util |
1820 } // namespace autofill | 1819 } // namespace autofill |
OLD | NEW |