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

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: Changed to password generation specific version 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
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..04811489b8854510a1a963b5aaf0673b7b079da8 100644
--- a/components/autofill/content/renderer/password_generation_agent.cc
+++ b/components/autofill/content/renderer/password_generation_agent.cc
@@ -31,6 +31,8 @@
#include "third_party/WebKit/public/web/WebView.h"
#include "ui/gfx/geometry/rect.h"
+using autofill::form_util::StripAuthAndParams;
vabr (Chromium) 2016/09/07 13:10:08 nit: Move this below "namespace autofill" and drop
kolos1 2016/09/07 13:19:00 Done.
+
namespace autofill {
namespace {
@@ -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 "

Powered by Google App Engine
This is Rietveld 408576698