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

Unified Diff: components/autofill/content/renderer/password_form_conversion_utils.cc

Issue 1039833002: [Password Manager] Unify action and origin detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/content/renderer/password_form_conversion_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/renderer/password_form_conversion_utils.cc
diff --git a/components/autofill/content/renderer/password_form_conversion_utils.cc b/components/autofill/content/renderer/password_form_conversion_utils.cc
index be13e1b92b88072f2a0ff4bc9d8d435da006e40f..556ea1bddf8ba0aa498273c4c11e63801c0166c9 100644
--- a/components/autofill/content/renderer/password_form_conversion_utils.cc
+++ b/components/autofill/content/renderer/password_form_conversion_utils.cc
@@ -294,35 +294,20 @@ void GetPasswordForm(
password_form->username_value = username_value;
}
- // Get the document URL
- GURL full_origin(form.document().url());
-
- // Calculate the canonical action URL
- WebString action = form.action();
- if (action.isNull())
- action = WebString(""); // missing 'action' attribute implies current URL
- GURL full_action(form.document().completeURL(action));
- if (!full_action.is_valid())
- return;
-
WebInputElement password;
WebInputElement new_password;
if (!LocateSpecificPasswords(passwords, &password, &new_password))
return;
- // We want to keep the path but strip any authentication data, as well as
- // query and ref portions of URL, for the form action and form origin.
- GURL::Replacements rep;
- rep.ClearUsername();
- rep.ClearPassword();
- rep.ClearQuery();
- rep.ClearRef();
- password_form->action = full_action.ReplaceComponents(rep);
- password_form->origin = full_origin.ReplaceComponents(rep);
+ password_form->action = GetCanonicalActionForForm(form);
+ if (!password_form->action.is_valid())
+ return;
+ password_form->origin = GetCanonicalOriginForDocument(form.document());
+ GURL::Replacements rep;
rep.SetPathStr("");
- password_form->signon_realm = full_origin.ReplaceComponents(rep).spec();
-
+ password_form->signon_realm =
+ password_form->origin.ReplaceComponents(rep).spec();
password_form->other_possible_usernames.swap(other_possible_usernames);
if (!password.isNull()) {
@@ -348,8 +333,32 @@ void GetPasswordForm(
password_form->type = PasswordForm::TYPE_MANUAL;
}
+GURL StripAuthAndParams(const GURL& gurl) {
+ // We want to keep the path but strip any authentication data, as well as
+ // query and ref portions of URL, for the form action and form origin.
+ GURL::Replacements rep;
+ rep.ClearUsername();
+ rep.ClearPassword();
+ rep.ClearQuery();
+ rep.ClearRef();
+ return gurl.ReplaceComponents(rep);
+}
+
} // namespace
+GURL GetCanonicalActionForForm(const WebFormElement& form) {
+ WebString action = form.action();
+ if (action.isNull())
+ action = WebString(""); // missing 'action' attribute implies current URL
+ GURL full_action(form.document().completeURL(action));
+ return StripAuthAndParams(full_action);
+}
+
+GURL GetCanonicalOriginForDocument(const WebDocument& document) {
+ GURL full_origin(document.url());
+ return StripAuthAndParams(full_origin);
+}
+
scoped_ptr<PasswordForm> CreatePasswordForm(
const WebFormElement& web_form,
const std::map<const blink::WebInputElement, blink::WebString>*
« no previous file with comments | « components/autofill/content/renderer/password_form_conversion_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698