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

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

Issue 2900713003: [Password Manager, merge to M-59] 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 // Helper to locate form elements identified by |data|. 247 // Helper to locate form elements identified by |data|.
248 void FindFormElements(content::RenderFrame* render_frame, 248 void FindFormElements(content::RenderFrame* render_frame,
249 const PasswordFormFillData& data, 249 const PasswordFormFillData& data,
250 bool ambiguous_or_empty_names, 250 bool ambiguous_or_empty_names,
251 FormElementsList* results) { 251 FormElementsList* results) {
252 DCHECK(results); 252 DCHECK(results);
253 253
254 blink::WebDocument doc = render_frame->GetWebFrame()->GetDocument(); 254 blink::WebDocument doc = render_frame->GetWebFrame()->GetDocument();
255 255
256 if (data.origin != form_util::GetCanonicalOriginForDocument(doc)) 256 if (GetSignOnRealm(data.origin) !=
257 GetSignOnRealm(form_util::GetCanonicalOriginForDocument(doc)))
257 return; 258 return;
258 259
259 blink::WebVector<blink::WebFormElement> forms; 260 blink::WebVector<blink::WebFormElement> forms;
260 doc.Forms(forms); 261 doc.Forms(forms);
261 262
262 for (size_t i = 0; i < forms.size(); ++i) { 263 for (size_t i = 0; i < forms.size(); ++i) {
263 blink::WebFormElement fe = forms[i]; 264 blink::WebFormElement fe = forms[i];
264 265
265 // Action URL must match. 266 // Action URL must match.
266 if (data.action != form_util::GetCanonicalActionForForm(fe)) 267 if (data.action != form_util::GetCanonicalActionForForm(fe))
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 // If there is a password field, but the list of password forms is empty for 1149 // If there is a password field, but the list of password forms is empty for
1149 // some reason, add a dummy form to the list. It will cause a request to the 1150 // some reason, add a dummy form to the list. It will cause a request to the
1150 // store. Therefore, saved passwords will be available for filling on click. 1151 // store. Therefore, saved passwords will be available for filling on click.
1151 if (!sent_request_to_store_ && password_forms.empty() && 1152 if (!sent_request_to_store_ && password_forms.empty() &&
1152 HasPasswordField(*frame)) { 1153 HasPasswordField(*frame)) {
1153 // Set everything that |FormDigest| needs. 1154 // Set everything that |FormDigest| needs.
1154 password_forms.push_back(PasswordForm()); 1155 password_forms.push_back(PasswordForm());
1155 password_forms.back().scheme = PasswordForm::SCHEME_HTML; 1156 password_forms.back().scheme = PasswordForm::SCHEME_HTML;
1156 password_forms.back().origin = 1157 password_forms.back().origin =
1157 form_util::GetCanonicalOriginForDocument(frame->GetDocument()); 1158 form_util::GetCanonicalOriginForDocument(frame->GetDocument());
1158 GURL::Replacements rep;
1159 rep.SetPathStr("");
1160 password_forms.back().signon_realm = 1159 password_forms.back().signon_realm =
1161 password_forms.back().origin.ReplaceComponents(rep).spec(); 1160 GetSignOnRealm(password_forms.back().origin);
1162 sent_request_to_store_ = true; 1161 sent_request_to_store_ = true;
1163 } 1162 }
1164 if (!password_forms.empty()) 1163 if (!password_forms.empty())
1165 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms); 1164 GetPasswordManagerDriver()->PasswordFormsParsed(password_forms);
1166 } 1165 }
1167 } 1166 }
1168 1167
1169 void PasswordAutofillAgent::DidFinishDocumentLoad() { 1168 void PasswordAutofillAgent::DidFinishDocumentLoad() {
1170 // The |frame| contents have been parsed, but not yet rendered. Let the 1169 // The |frame| contents have been parsed, but not yet rendered. Let the
1171 // PasswordManager know that forms are loaded, even though we can't yet tell 1170 // PasswordManager know that forms are loaded, even though we can't yet tell
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1637 PasswordAutofillAgent::GetPasswordManagerDriver() { 1636 PasswordAutofillAgent::GetPasswordManagerDriver() {
1638 if (!password_manager_driver_) { 1637 if (!password_manager_driver_) {
1639 render_frame()->GetRemoteInterfaces()->GetInterface( 1638 render_frame()->GetRemoteInterfaces()->GetInterface(
1640 mojo::MakeRequest(&password_manager_driver_)); 1639 mojo::MakeRequest(&password_manager_driver_));
1641 } 1640 }
1642 1641
1643 return password_manager_driver_; 1642 return password_manager_driver_;
1644 } 1643 }
1645 1644
1646 } // namespace autofill 1645 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698