| 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 blink::WebVector<blink::WebNode> temp_elements; | 74 blink::WebVector<blink::WebNode> temp_elements; |
| 75 fe->getNamedElements(data.fields[j].name, temp_elements); | 75 fe->getNamedElements(data.fields[j].name, temp_elements); |
| 76 | 76 |
| 77 // Match the first input element, if any. | 77 // Match the first input element, if any. |
| 78 // |getNamedElements| may return non-input elements where the names match, | 78 // |getNamedElements| may return non-input elements where the names match, |
| 79 // so the results are filtered for input elements. | 79 // so the results are filtered for input elements. |
| 80 // If more than one match is made, then we have ambiguity (due to misuse | 80 // If more than one match is made, then we have ambiguity (due to misuse |
| 81 // of "name" attribute) so is it considered not found. | 81 // of "name" attribute) so is it considered not found. |
| 82 bool found_input = false; | 82 bool found_input = false; |
| 83 for (size_t i = 0; i < temp_elements.size(); ++i) { | 83 for (size_t i = 0; i < temp_elements.size(); ++i) { |
| 84 if (temp_elements[i].to<blink::WebElement>().hasTagName("input")) { | 84 if (temp_elements[i].to<blink::WebElement>().hasHTMLTagName("input")) { |
| 85 // Check for a non-unique match. | 85 // Check for a non-unique match. |
| 86 if (found_input) { | 86 if (found_input) { |
| 87 found_input = false; | 87 found_input = false; |
| 88 break; | 88 break; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // Only fill saved passwords into password fields and usernames into | 91 // Only fill saved passwords into password fields and usernames into |
| 92 // text fields. | 92 // text fields. |
| 93 blink::WebInputElement input_element = | 93 blink::WebInputElement input_element = |
| 94 temp_elements[i].to<blink::WebInputElement>(); | 94 temp_elements[i].to<blink::WebInputElement>(); |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 } | 1006 } |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode& node, | 1009 bool PasswordAutofillAgent::FindLoginInfo(const blink::WebNode& node, |
| 1010 blink::WebInputElement* found_input, | 1010 blink::WebInputElement* found_input, |
| 1011 PasswordInfo* found_password) { | 1011 PasswordInfo* found_password) { |
| 1012 if (!node.isElementNode()) | 1012 if (!node.isElementNode()) |
| 1013 return false; | 1013 return false; |
| 1014 | 1014 |
| 1015 blink::WebElement element = node.toConst<blink::WebElement>(); | 1015 blink::WebElement element = node.toConst<blink::WebElement>(); |
| 1016 if (!element.hasTagName("input")) | 1016 if (!element.hasHTMLTagName("input")) |
| 1017 return false; | 1017 return false; |
| 1018 | 1018 |
| 1019 blink::WebInputElement input = element.to<blink::WebInputElement>(); | 1019 blink::WebInputElement input = element.to<blink::WebInputElement>(); |
| 1020 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); | 1020 LoginToPasswordInfoMap::iterator iter = login_to_password_info_.find(input); |
| 1021 if (iter == login_to_password_info_.end()) | 1021 if (iter == login_to_password_info_.end()) |
| 1022 return false; | 1022 return false; |
| 1023 | 1023 |
| 1024 *found_input = input; | 1024 *found_input = input; |
| 1025 *found_password = iter->second; | 1025 *found_password = iter->second; |
| 1026 return true; | 1026 return true; |
| 1027 } | 1027 } |
| 1028 | 1028 |
| 1029 } // namespace autofill | 1029 } // namespace autofill |
| OLD | NEW |