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

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

Issue 2893633002: [Password Manager] Make filling robust against changing url by JavaScript (Closed)
Patch Set: fix merge Created 3 years, 7 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/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
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))
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 // If there is a password field, but the list of password forms is empty for 1221 // If there is a password field, but the list of password forms is empty for
1221 // some reason, add a dummy form to the list. It will cause a request to the 1222 // some reason, add a dummy form to the list. It will cause a request to the
1222 // store. Therefore, saved passwords will be available for filling on click. 1223 // store. Therefore, saved passwords will be available for filling on click.
1223 if (!sent_request_to_store_ && password_forms.empty() && 1224 if (!sent_request_to_store_ && password_forms.empty() &&
1224 HasPasswordField(*frame)) { 1225 HasPasswordField(*frame)) {
1225 // Set everything that |FormDigest| needs. 1226 // Set everything that |FormDigest| needs.
1226 password_forms.push_back(PasswordForm()); 1227 password_forms.push_back(PasswordForm());
1227 password_forms.back().scheme = PasswordForm::SCHEME_HTML; 1228 password_forms.back().scheme = PasswordForm::SCHEME_HTML;
1228 password_forms.back().origin = 1229 password_forms.back().origin =
1229 form_util::GetCanonicalOriginForDocument(frame->GetDocument()); 1230 form_util::GetCanonicalOriginForDocument(frame->GetDocument());
1230 GURL::Replacements rep;
1231 rep.SetPathStr("");
1232 password_forms.back().signon_realm = 1231 password_forms.back().signon_realm =
1233 password_forms.back().origin.ReplaceComponents(rep).spec(); 1232 GetSignOnRealm(password_forms.back().origin);
1234 } 1233 }
1235 if (!password_forms.empty()) { 1234 if (!password_forms.empty()) {
1236 sent_request_to_store_ = true; 1235 sent_request_to_store_ = true;
1237 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms); 1236 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms);
1238 } 1237 }
1239 } 1238 }
1240 } 1239 }
1241 1240
1242 void PasswordAutofillAgent::DidFinishDocumentLoad() { 1241 void PasswordAutofillAgent::DidFinishDocumentLoad() {
1243 // The |frame| contents have been parsed, but not yet rendered. Let the 1242 // The |frame| contents have been parsed, but not yet rendered. Let the
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 PasswordAutofillAgent::GetPasswordManagerDriver() { 1731 PasswordAutofillAgent::GetPasswordManagerDriver() {
1733 if (!password_manager_driver_) { 1732 if (!password_manager_driver_) {
1734 render_frame()->GetRemoteInterfaces()->GetInterface( 1733 render_frame()->GetRemoteInterfaces()->GetInterface(
1735 mojo::MakeRequest(&password_manager_driver_)); 1734 mojo::MakeRequest(&password_manager_driver_));
1736 } 1735 }
1737 1736
1738 return password_manager_driver_; 1737 return password_manager_driver_;
1739 } 1738 }
1740 1739
1741 } // namespace autofill 1740 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698