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

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

Issue 2411333004: Make HasAutocompleteAttributeValue handle multi-valued strings (Closed)
Patch Set: Created 4 years, 2 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_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 317807fd18e5b0608bbb6647c5bb662659792dab..a5bce11c3f632fd8abd8d2e2ff1a7f09c57d84e7 100644
--- a/components/autofill/content/renderer/password_form_conversion_utils.cc
+++ b/components/autofill/content/renderer/password_form_conversion_utils.cc
@@ -13,9 +13,11 @@
#include "base/lazy_instance.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
+#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
+#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/password_form.h"
#include "components/autofill/core/common/password_form_field_prediction_map.h"
#include "google_apis/gaia/gaia_urls.h"
@@ -702,9 +704,13 @@ std::unique_ptr<PasswordForm> CreatePasswordFormFromUnownedInputElements(
bool HasAutocompleteAttributeValue(const blink::WebInputElement& element,
const char* value_in_lowercase) {
- return base::LowerCaseEqualsASCII(
- base::StringPiece16(element.getAttribute("autocomplete")),
- value_in_lowercase);
+ base::string16 autocomplete_attribute(element.getAttribute("autocomplete"));
vabr (Chromium) 2016/10/13 12:49:31 Please #include "base/strings/string16.h"
jdoerrie 2016/10/13 13:45:07 Done.
+ // Lowercase and tokenize attribute string. Convert to UTF8 beforehand.
vabr (Chromium) 2016/10/13 12:49:31 Your comments here and on line 712 are correct and
jdoerrie 2016/10/13 13:45:07 Done.
+ std::vector<std::string> tokens = LowercaseAndTokenizeAttributeString(
+ base::UTF16ToUTF8(autocomplete_attribute));
+
+ // Return if any of the obtained attribute tokens equals the value.
vabr (Chromium) 2016/10/13 12:49:31 optional nit: if -> whether
jdoerrie 2016/10/13 13:45:07 Acknowledged.
+ return base::ContainsValue(tokens, value_in_lowercase);
}
} // namespace autofill
« no previous file with comments | « no previous file | components/autofill/core/browser/form_structure.cc » ('j') | components/autofill/core/browser/form_structure.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698