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

Unified Diff: components/autofill/core/common/password_form.cc

Issue 2747733004: [Password Manager] Send username correction votes (Closed)
Patch Set: Minor changes Created 3 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
Index: components/autofill/core/common/password_form.cc
diff --git a/components/autofill/core/common/password_form.cc b/components/autofill/core/common/password_form.cc
index 3969e1ff4e4a41f9adba4503b0f339986e3e0a6c..a3361f87ccabe8c6fee3c94e75a512fba85d487c 100644
--- a/components/autofill/core/common/password_form.cc
+++ b/components/autofill/core/common/password_form.cc
@@ -16,6 +16,17 @@ namespace autofill {
namespace {
+base::string16 OtherPossibleUsernamesToString(
vabr (Chromium) 2017/03/16 21:00:42 You can also implement it as two pass processing:
kolos1 2017/03/17 14:09:34 Done.
+ PossibleUsernamesVector possible_usernames) {
vabr (Chromium) 2017/03/16 21:00:42 const PossibleUsernamesVector&
kolos1 2017/03/17 14:09:34 Done.
+ base::string16 result;
+ for (const PossibleUsernamePair pair : possible_usernames) {
vabr (Chromium) 2017/03/16 21:00:41 use const ref not const value: const PossibleUsern
kolos1 2017/03/17 14:09:34 Done.
+ if (!result.empty())
+ result += base::ASCIIToUTF16(", ");
+ result += pair.first + base::ASCIIToUTF16("+") + pair.second;
+ }
+ return result;
+}
+
// Serializes a PasswordForm to a JSON object. Used only for logging in tests.
void PasswordFormToJSON(const PasswordForm& form,
base::DictionaryValue* target) {
@@ -40,9 +51,9 @@ void PasswordFormToJSON(const PasswordForm& form,
form.new_password_value_is_default);
target->SetBoolean("new_password_marked_by_site",
form.new_password_marked_by_site);
- target->SetString("other_possible_usernames",
- base::JoinString(form.other_possible_usernames,
- base::ASCIIToUTF16("|")));
+ target->SetString(
+ "other_possible_usernames",
+ OtherPossibleUsernamesToString(form.other_possible_usernames));
target->SetBoolean("blacklisted", form.blacklisted_by_user);
target->SetBoolean("preferred", form.preferred);
target->SetDouble("date_created", form.date_created.ToDoubleT());
@@ -207,4 +218,8 @@ std::ostream& operator<<(std::ostream& os, PasswordForm* form) {
return os << "&" << *form;
}
+base::string16 OtherPossibleUsernamesToStr(const PasswordForm& form) {
+ return OtherPossibleUsernamesToString(form.other_possible_usernames);
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698