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

Side by Side Diff: components/autofill/core/common/password_form.cc

Issue 2747733004: [Password Manager] Send username correction votes (Closed)
Patch Set: Changes addressed to reviewer comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm>
5 #include <ostream> 6 #include <ostream>
6 #include <sstream> 7 #include <sstream>
7 8
8 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "base/values.h" 13 #include "base/values.h"
13 #include "components/autofill/core/common/password_form.h" 14 #include "components/autofill/core/common/password_form.h"
14 15
(...skipping 18 matching lines...) Expand all
33 target->SetString("password_elem", form.password_element); 34 target->SetString("password_elem", form.password_element);
34 target->SetString("password_value", form.password_value); 35 target->SetString("password_value", form.password_value);
35 target->SetBoolean("password_value_is_default", 36 target->SetBoolean("password_value_is_default",
36 form.password_value_is_default); 37 form.password_value_is_default);
37 target->SetString("new_password_element", form.new_password_element); 38 target->SetString("new_password_element", form.new_password_element);
38 target->SetString("new_password_value", form.new_password_value); 39 target->SetString("new_password_value", form.new_password_value);
39 target->SetBoolean("new_password_value_is_default", 40 target->SetBoolean("new_password_value_is_default",
40 form.new_password_value_is_default); 41 form.new_password_value_is_default);
41 target->SetBoolean("new_password_marked_by_site", 42 target->SetBoolean("new_password_marked_by_site",
42 form.new_password_marked_by_site); 43 form.new_password_marked_by_site);
43 target->SetString("other_possible_usernames", 44 target->SetString(
44 base::JoinString(form.other_possible_usernames, 45 "other_possible_usernames",
45 base::ASCIIToUTF16("|"))); 46 OtherPossibleUsernamesToString(form.other_possible_usernames));
46 target->SetBoolean("blacklisted", form.blacklisted_by_user); 47 target->SetBoolean("blacklisted", form.blacklisted_by_user);
47 target->SetBoolean("preferred", form.preferred); 48 target->SetBoolean("preferred", form.preferred);
48 target->SetDouble("date_created", form.date_created.ToDoubleT()); 49 target->SetDouble("date_created", form.date_created.ToDoubleT());
49 target->SetDouble("date_synced", form.date_synced.ToDoubleT()); 50 target->SetDouble("date_synced", form.date_synced.ToDoubleT());
50 target->SetInteger("type", form.type); 51 target->SetInteger("type", form.type);
51 target->SetInteger("times_used", form.times_used); 52 target->SetInteger("times_used", form.times_used);
52 std::ostringstream form_data_string_stream; 53 std::ostringstream form_data_string_stream;
53 form_data_string_stream << form.form_data; 54 form_data_string_stream << form.form_data;
54 target->SetString("form_data", form_data_string_stream.str()); 55 target->SetString("form_data", form_data_string_stream.str());
55 target->SetInteger("generation_upload_status", form.generation_upload_status); 56 target->SetInteger("generation_upload_status", form.generation_upload_status);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (result) 161 if (result)
161 return result < 0; 162 return result < 0;
162 163
163 result = left->password_element.compare(right->password_element); 164 result = left->password_element.compare(right->password_element);
164 if (result) 165 if (result)
165 return result < 0; 166 return result < 0;
166 167
167 return left->origin < right->origin; 168 return left->origin < right->origin;
168 } 169 }
169 170
171 base::string16 OtherPossibleUsernamesToString(
172 const PossibleUsernamesVector& possible_usernames) {
173 std::vector<base::string16> pairs(possible_usernames.size());
174 std::transform(possible_usernames.begin(), possible_usernames.end(),
175 pairs.begin(), [](PossibleUsernamePair p) {
dvadym 2017/03/22 10:56:18 Nit: const PossibleUsernamePair&
kolos1 2017/03/22 13:40:39 Done.
176 return p.first + base::ASCIIToUTF16("+") + p.second;
177 });
178 return base::JoinString(pairs, base::ASCIIToUTF16(", "));
179 }
180
170 std::ostream& operator<<(std::ostream& os, PasswordForm::Layout layout) { 181 std::ostream& operator<<(std::ostream& os, PasswordForm::Layout layout) {
171 switch (layout) { 182 switch (layout) {
172 case PasswordForm::Layout::LAYOUT_OTHER: 183 case PasswordForm::Layout::LAYOUT_OTHER:
173 os << "LAYOUT_OTHER"; 184 os << "LAYOUT_OTHER";
174 break; 185 break;
175 case PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP: 186 case PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP:
176 os << "LAYOUT_LOGIN_AND_SIGNUP"; 187 os << "LAYOUT_LOGIN_AND_SIGNUP";
177 break; 188 break;
178 } 189 }
179 return os; 190 return os;
(...skipping 21 matching lines...) Expand all
201 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string); 212 form_json, base::JSONWriter::OPTIONS_PRETTY_PRINT, &form_as_string);
202 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string); 213 base::TrimWhitespaceASCII(form_as_string, base::TRIM_ALL, &form_as_string);
203 return os << "PasswordForm(" << form_as_string << ")"; 214 return os << "PasswordForm(" << form_as_string << ")";
204 } 215 }
205 216
206 std::ostream& operator<<(std::ostream& os, PasswordForm* form) { 217 std::ostream& operator<<(std::ostream& os, PasswordForm* form) {
207 return os << "&" << *form; 218 return os << "&" << *form;
208 } 219 }
209 220
210 } // namespace autofill 221 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698