Chromium Code Reviews| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 248 |
| 249 // Helper to locate form elements identified by |data|. | 249 // Helper to locate form elements identified by |data|. |
| 250 void FindFormElements(content::RenderFrame* render_frame, | 250 void FindFormElements(content::RenderFrame* render_frame, |
| 251 const PasswordFormFillData& data, | 251 const PasswordFormFillData& data, |
| 252 bool ambiguous_or_empty_names, | 252 bool ambiguous_or_empty_names, |
| 253 FormElementsList* results) { | 253 FormElementsList* results) { |
| 254 DCHECK(results); | 254 DCHECK(results); |
| 255 | 255 |
| 256 blink::WebDocument doc = render_frame->GetWebFrame()->GetDocument(); | 256 blink::WebDocument doc = render_frame->GetWebFrame()->GetDocument(); |
| 257 | 257 |
| 258 if (data.origin != form_util::GetCanonicalOriginForDocument(doc)) | 258 if (GetSignOnRealm(data.origin) != |
| 259 GetSignOnRealm(form_util::GetCanonicalOriginForDocument(doc))) | |
| 259 return; | 260 return; |
| 260 | 261 |
| 261 blink::WebVector<blink::WebFormElement> forms; | 262 blink::WebVector<blink::WebFormElement> forms; |
| 262 doc.Forms(forms); | 263 doc.Forms(forms); |
| 263 | 264 |
| 264 for (size_t i = 0; i < forms.size(); ++i) { | 265 for (size_t i = 0; i < forms.size(); ++i) { |
| 265 blink::WebFormElement fe = forms[i]; | 266 blink::WebFormElement fe = forms[i]; |
| 266 | 267 |
| 267 // Action URL must match. | 268 // Action URL must match. |
| 268 if (data.action != form_util::GetCanonicalActionForForm(fe)) | 269 if (data.action != form_util::GetCanonicalActionForForm(fe)) |
| 269 continue; | 270 continue; |
| 270 | 271 |
| 271 std::vector<blink::WebFormControlElement> control_elements = | 272 std::vector<blink::WebFormControlElement> control_elements = |
| 272 form_util::ExtractAutofillableElementsInForm(fe); | 273 form_util::ExtractAutofillableElementsInForm(fe); |
| 273 FormInputElementMap cur_map; | 274 FormInputElementMap cur_map; |
| 274 if (FindFormInputElements(control_elements, data, ambiguous_or_empty_names, | 275 if (FindFormInputElements(control_elements, data, ambiguous_or_empty_names, |
| 275 &cur_map)) | 276 &cur_map)) |
| 276 results->push_back(cur_map); | 277 results->push_back(cur_map); |
| 277 } | 278 } |
| 278 // If the element to be filled are not in a <form> element, the "action" and | 279 // If the element to be filled are not in a <form> element, the "action" and |
| 279 // origin should be the same. | 280 // origin should be the same. |
| 280 if (data.action != data.origin) | 281 if (data.action != data.origin) |
|
kolos1
2017/05/18 09:52:52
Shall we do similar change here?
dvadym
2017/05/18 11:08:52
This is a different case. This condition has nothi
kolos1
2017/05/18 11:11:50
Acknowledged.
| |
| 281 return; | 282 return; |
| 282 | 283 |
| 283 std::vector<blink::WebFormControlElement> control_elements = | 284 std::vector<blink::WebFormControlElement> control_elements = |
| 284 form_util::GetUnownedAutofillableFormFieldElements(doc.All(), nullptr); | 285 form_util::GetUnownedAutofillableFormFieldElements(doc.All(), nullptr); |
| 285 FormInputElementMap unowned_elements_map; | 286 FormInputElementMap unowned_elements_map; |
| 286 if (FindFormInputElements(control_elements, data, ambiguous_or_empty_names, | 287 if (FindFormInputElements(control_elements, data, ambiguous_or_empty_names, |
| 287 &unowned_elements_map)) | 288 &unowned_elements_map)) |
| 288 results->push_back(unowned_elements_map); | 289 results->push_back(unowned_elements_map); |
| 289 } | 290 } |
| 290 | 291 |
| (...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1213 // If there is a password field, but the list of password forms is empty for | 1214 // If there is a password field, but the list of password forms is empty for |
| 1214 // some reason, add a dummy form to the list. It will cause a request to the | 1215 // some reason, add a dummy form to the list. It will cause a request to the |
| 1215 // store. Therefore, saved passwords will be available for filling on click. | 1216 // store. Therefore, saved passwords will be available for filling on click. |
| 1216 if (!sent_request_to_store_ && password_forms.empty() && | 1217 if (!sent_request_to_store_ && password_forms.empty() && |
| 1217 HasPasswordField(*frame)) { | 1218 HasPasswordField(*frame)) { |
| 1218 // Set everything that |FormDigest| needs. | 1219 // Set everything that |FormDigest| needs. |
| 1219 password_forms.push_back(PasswordForm()); | 1220 password_forms.push_back(PasswordForm()); |
| 1220 password_forms.back().scheme = PasswordForm::SCHEME_HTML; | 1221 password_forms.back().scheme = PasswordForm::SCHEME_HTML; |
| 1221 password_forms.back().origin = | 1222 password_forms.back().origin = |
| 1222 form_util::GetCanonicalOriginForDocument(frame->GetDocument()); | 1223 form_util::GetCanonicalOriginForDocument(frame->GetDocument()); |
| 1223 GURL::Replacements rep; | |
| 1224 rep.SetPathStr(""); | |
| 1225 password_forms.back().signon_realm = | 1224 password_forms.back().signon_realm = |
| 1226 password_forms.back().origin.ReplaceComponents(rep).spec(); | 1225 GetSignOnRealm(password_forms.back().origin); |
| 1227 sent_request_to_store_ = true; | 1226 sent_request_to_store_ = true; |
| 1228 } | 1227 } |
| 1229 if (!password_forms.empty()) | 1228 if (!password_forms.empty()) |
| 1230 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms); | 1229 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms); |
| 1231 } | 1230 } |
| 1232 } | 1231 } |
| 1233 | 1232 |
| 1234 void PasswordAutofillAgent::DidFinishDocumentLoad() { | 1233 void PasswordAutofillAgent::DidFinishDocumentLoad() { |
| 1235 // The |frame| contents have been parsed, but not yet rendered. Let the | 1234 // 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 | 1235 // PasswordManager know that forms are loaded, even though we can't yet tell |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1724 PasswordAutofillAgent::GetPasswordManagerDriver() { | 1723 PasswordAutofillAgent::GetPasswordManagerDriver() { |
| 1725 if (!password_manager_driver_) { | 1724 if (!password_manager_driver_) { |
| 1726 render_frame()->GetRemoteInterfaces()->GetInterface( | 1725 render_frame()->GetRemoteInterfaces()->GetInterface( |
| 1727 mojo::MakeRequest(&password_manager_driver_)); | 1726 mojo::MakeRequest(&password_manager_driver_)); |
| 1728 } | 1727 } |
| 1729 | 1728 |
| 1730 return password_manager_driver_; | 1729 return password_manager_driver_; |
| 1731 } | 1730 } |
| 1732 | 1731 |
| 1733 } // namespace autofill | 1732 } // namespace autofill |
| OLD | NEW |