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

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

Issue 1265203002: Convert autocomplete attribute values to constants (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to latest code Created 5 years, 4 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 | « no previous file | 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 7f82a96a4d058dc49fb65f2e11438cd656af1d9c..8d5d03f42e2a98c2c61f71b431e733fd330f2487 100644
--- a/components/autofill/content/renderer/password_form_conversion_utils.cc
+++ b/components/autofill/content/renderer/password_form_conversion_utils.cc
@@ -58,6 +58,10 @@ const char kLoginAndSignupRegex[] =
"N+P" // Sign-up section.
".*"; // Anything beyond that.
+const char kAutocompleteUsername[] = "username";
+const char kAutocompleteCurrentPassword[] = "current-password";
+const char kAutocompleteNewPassword[] = "new-password";
+
struct LoginAndSignupLazyInstanceTraits
: public base::DefaultLazyInstanceTraits<icu::RegexMatcher> {
static icu::RegexMatcher* New(void* instance) {
@@ -119,10 +123,10 @@ bool LocateSpecificPasswords(std::vector<WebInputElement> passwords,
// each kind as the element we are looking for.
for (std::vector<WebInputElement>::const_iterator it = passwords.begin();
it != passwords.end(); it++) {
- if (HasAutocompleteAttributeValue(*it, "current-password") &&
+ if (HasAutocompleteAttributeValue(*it, kAutocompleteCurrentPassword) &&
current_password->isNull()) {
*current_password = *it;
- } else if (HasAutocompleteAttributeValue(*it, "new-password") &&
+ } else if (HasAutocompleteAttributeValue(*it, kAutocompleteNewPassword) &&
new_password->isNull()) {
*new_password = *it;
}
@@ -289,8 +293,10 @@ void GetPasswordForm(
(nonscript_modified_values &&
nonscript_modified_values->find(*input_element) !=
nonscript_modified_values->end()) ||
- HasAutocompleteAttributeValue(*input_element, "current-password") ||
- HasAutocompleteAttributeValue(*input_element, "new-password"))) {
+ HasAutocompleteAttributeValue(*input_element,
+ kAutocompleteCurrentPassword) ||
+ HasAutocompleteAttributeValue(*input_element,
+ kAutocompleteNewPassword))) {
passwords.push_back(*input_element);
// If we have not yet considered any element to be the username so far,
// provisionally select the input element just before the first password
@@ -310,7 +316,8 @@ void GetPasswordForm(
// Various input types such as text, url, email can be a username field.
if (input_element->isTextField() && !input_element->isPasswordField()) {
- if (HasAutocompleteAttributeValue(*input_element, "username")) {
+ if (HasAutocompleteAttributeValue(*input_element,
+ kAutocompleteUsername)) {
if (password_form->username_marked_by_site) {
// A second or subsequent element marked with autocomplete='username'.
// This makes us less confident that we have understood the form. We
@@ -425,7 +432,7 @@ void GetPasswordForm(
if (!new_password.isNull()) {
password_form->new_password_element = new_password.nameForAutofill();
password_form->new_password_value = new_password.value();
- if (HasAutocompleteAttributeValue(new_password, "new-password"))
+ if (HasAutocompleteAttributeValue(new_password, kAutocompleteNewPassword))
password_form->new_password_marked_by_site = true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698