| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 const blink::WebInputElement& element, | 879 const blink::WebInputElement& element, |
| 880 blink::WebInputElement* username_element, | 880 blink::WebInputElement* username_element, |
| 881 blink::WebInputElement* password_element, | 881 blink::WebInputElement* password_element, |
| 882 PasswordInfo** password_info) { | 882 PasswordInfo** password_info) { |
| 883 DCHECK(username_element && password_element && password_info); | 883 DCHECK(username_element && password_element && password_info); |
| 884 username_element->Reset(); | 884 username_element->Reset(); |
| 885 password_element->Reset(); | 885 password_element->Reset(); |
| 886 if (!element.IsPasswordField()) { | 886 if (!element.IsPasswordField()) { |
| 887 *username_element = element; | 887 *username_element = element; |
| 888 } else { | 888 } else { |
| 889 // If there is a password field, but a request to the store hasn't been sent |
| 890 // yet, then do fetch saved credentials now. |
| 891 if (!sent_request_to_store_) { |
| 892 SendPasswordForms(false); |
| 893 return false; |
| 894 } |
| 895 |
| 889 WebInputToPasswordInfoMap::iterator iter = | 896 WebInputToPasswordInfoMap::iterator iter = |
| 890 web_input_to_password_info_.find(element); | 897 web_input_to_password_info_.find(element); |
| 891 if (iter != web_input_to_password_info_.end()) { | 898 if (iter != web_input_to_password_info_.end()) { |
| 892 // It's a password field without corresponding username field. | 899 // It's a password field without corresponding username field. |
| 893 *password_element = element; | 900 *password_element = element; |
| 894 *password_info = &iter->second; | 901 *password_info = &iter->second; |
| 895 return true; | 902 return true; |
| 896 } | 903 } |
| 897 PasswordToLoginMap::const_iterator password_iter = | 904 PasswordToLoginMap::const_iterator password_iter = |
| 898 password_to_username_.find(element); | 905 password_to_username_.find(element); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 HasPasswordField(*frame)) { | 1224 HasPasswordField(*frame)) { |
| 1218 // Set everything that |FormDigest| needs. | 1225 // Set everything that |FormDigest| needs. |
| 1219 password_forms.push_back(PasswordForm()); | 1226 password_forms.push_back(PasswordForm()); |
| 1220 password_forms.back().scheme = PasswordForm::SCHEME_HTML; | 1227 password_forms.back().scheme = PasswordForm::SCHEME_HTML; |
| 1221 password_forms.back().origin = | 1228 password_forms.back().origin = |
| 1222 form_util::GetCanonicalOriginForDocument(frame->GetDocument()); | 1229 form_util::GetCanonicalOriginForDocument(frame->GetDocument()); |
| 1223 GURL::Replacements rep; | 1230 GURL::Replacements rep; |
| 1224 rep.SetPathStr(""); | 1231 rep.SetPathStr(""); |
| 1225 password_forms.back().signon_realm = | 1232 password_forms.back().signon_realm = |
| 1226 password_forms.back().origin.ReplaceComponents(rep).spec(); | 1233 password_forms.back().origin.ReplaceComponents(rep).spec(); |
| 1234 } |
| 1235 if (!password_forms.empty()) { |
| 1227 sent_request_to_store_ = true; | 1236 sent_request_to_store_ = true; |
| 1237 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms); |
| 1228 } | 1238 } |
| 1229 if (!password_forms.empty()) | |
| 1230 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms); | |
| 1231 } | 1239 } |
| 1232 } | 1240 } |
| 1233 | 1241 |
| 1234 void PasswordAutofillAgent::DidFinishDocumentLoad() { | 1242 void PasswordAutofillAgent::DidFinishDocumentLoad() { |
| 1235 // The |frame| contents have been parsed, but not yet rendered. Let the | 1243 // The |frame| contents have been parsed, but not yet rendered. Let the |
| 1236 // PasswordManager know that forms are loaded, even though we can't yet tell | 1244 // PasswordManager know that forms are loaded, even though we can't yet tell |
| 1237 // whether they're visible. | 1245 // whether they're visible. |
| 1238 form_util::ScopedLayoutPreventer layout_preventer; | 1246 form_util::ScopedLayoutPreventer layout_preventer; |
| 1239 SendPasswordForms(false); | 1247 SendPasswordForms(false); |
| 1240 } | 1248 } |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 PasswordAutofillAgent::GetPasswordManagerDriver() { | 1732 PasswordAutofillAgent::GetPasswordManagerDriver() { |
| 1725 if (!password_manager_driver_) { | 1733 if (!password_manager_driver_) { |
| 1726 render_frame()->GetRemoteInterfaces()->GetInterface( | 1734 render_frame()->GetRemoteInterfaces()->GetInterface( |
| 1727 mojo::MakeRequest(&password_manager_driver_)); | 1735 mojo::MakeRequest(&password_manager_driver_)); |
| 1728 } | 1736 } |
| 1729 | 1737 |
| 1730 return password_manager_driver_; | 1738 return password_manager_driver_; |
| 1731 } | 1739 } |
| 1732 | 1740 |
| 1733 } // namespace autofill | 1741 } // namespace autofill |
| OLD | NEW |