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

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

Issue 2320563002: [Password Generation] Use canonical version of action in for form matching in PasswordGenerationAgen (Closed)
Patch Set: Changes addressed to reviewer comments Created 4 years, 3 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/form_autofill_util.cc ('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_generation_agent.cc
diff --git a/components/autofill/content/renderer/password_generation_agent.cc b/components/autofill/content/renderer/password_generation_agent.cc
index 71d45b6756910c9ef6b048542a112159fd3901de..0776b0ebf355bc83112ad59d2f78f5f804ab8522 100644
--- a/components/autofill/content/renderer/password_generation_agent.cc
+++ b/components/autofill/content/renderer/password_generation_agent.cc
@@ -33,6 +33,8 @@
namespace autofill {
+using form_util::StripAuthAndParams;
+
namespace {
// Returns true if we think that this form is for account creation. |passwords|
@@ -55,11 +57,19 @@ bool ContainsURL(const std::vector<GURL>& urls, const GURL& url) {
return std::find(urls.begin(), urls.end(), url) != urls.end();
}
+// Finds a form in |forms| that has the same action and name as |form|.
+// If the action of a form in |forms| is empty, it uses |base_url| as action. It
+// also strips parameters of the action.
const PasswordFormGenerationData* FindFormGenerationData(
const std::vector<PasswordFormGenerationData>& forms,
- const PasswordForm& form) {
+ const PasswordForm& form,
+ const GURL& base_url) {
for (const auto& form_it : forms) {
- if (form_it.name == form.form_data.name && form_it.action == form.action)
+ GURL action = form_it.action;
+ if (action.is_empty())
+ action = base_url;
+ action = form_util::StripAuthAndParams(action);
+ if (form_it.name == form.form_data.name && action == form.action)
return &form_it;
}
return nullptr;
@@ -380,8 +390,9 @@ void PasswordGenerationAgent::DetermineGenerationElement() {
<< "blacklisted";
continue;
} else {
- generation_data = FindFormGenerationData(generation_enabled_forms_,
- *possible_password_form);
+ generation_data = FindFormGenerationData(
+ generation_enabled_forms_, *possible_password_form,
+ render_frame()->GetWebFrame()->document().baseURL());
if (!generation_data) {
if (AutocompleteAttributesSetForGeneration(*possible_password_form)) {
VLOG(2) << "Ignoring lack of Autofill signal due to Autocomplete "
« no previous file with comments | « components/autofill/content/renderer/form_autofill_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698