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

Side by Side Diff: components/autofill/core/browser/autofill_profile.cc

Issue 1110833002: [autofill] Sync server card and address metadata. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Work Created 5 years, 7 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 "components/autofill/core/browser/autofill_profile.h" 5 #include "components/autofill/core/browser/autofill_profile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <ostream> 10 #include <ostream>
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 name_(1), 247 name_(1),
248 email_(1), 248 email_(1),
249 phone_number_(1, PhoneNumber(this)) { 249 phone_number_(1, PhoneNumber(this)) {
250 } 250 }
251 251
252 AutofillProfile::AutofillProfile(RecordType type, const std::string& server_id) 252 AutofillProfile::AutofillProfile(RecordType type, const std::string& server_id)
253 : AutofillDataModel(base::GenerateGUID(), std::string()), 253 : AutofillDataModel(base::GenerateGUID(), std::string()),
254 record_type_(type), 254 record_type_(type),
255 name_(1), 255 name_(1),
256 email_(1), 256 email_(1),
257 phone_number_(1, PhoneNumber(this)), 257 phone_number_(1, PhoneNumber(this)) {
258 server_id_(server_id) {
259 DCHECK(type == SERVER_PROFILE); 258 DCHECK(type == SERVER_PROFILE);
259 set_server_id(server_id);
260 } 260 }
261 261
262 AutofillProfile::AutofillProfile() 262 AutofillProfile::AutofillProfile()
263 : AutofillDataModel(base::GenerateGUID(), std::string()), 263 : AutofillDataModel(base::GenerateGUID(), std::string()),
264 record_type_(LOCAL_PROFILE), 264 record_type_(LOCAL_PROFILE),
265 name_(1), 265 name_(1),
266 email_(1), 266 email_(1),
267 phone_number_(1, PhoneNumber(this)) { 267 phone_number_(1, PhoneNumber(this)) {
268 } 268 }
269 269
270 AutofillProfile::AutofillProfile(const AutofillProfile& profile) 270 AutofillProfile::AutofillProfile(const AutofillProfile& profile)
271 : AutofillDataModel(std::string(), std::string()) { 271 : AutofillDataModel(std::string(), std::string()) {
272 operator=(profile); 272 operator=(profile);
273 } 273 }
274 274
275 AutofillProfile::~AutofillProfile() { 275 AutofillProfile::~AutofillProfile() {
276 } 276 }
277 277
278 AutofillProfile& AutofillProfile::operator=(const AutofillProfile& profile) { 278 AutofillProfile& AutofillProfile::operator=(const AutofillProfile& profile) {
279 set_server_id(profile.server_id());
279 set_use_count(profile.use_count()); 280 set_use_count(profile.use_count());
280 set_use_date(profile.use_date()); 281 set_use_date(profile.use_date());
281 set_modification_date(profile.modification_date()); 282 set_modification_date(profile.modification_date());
282 283
283 if (this == &profile) 284 if (this == &profile)
284 return *this; 285 return *this;
285 286
286 set_guid(profile.guid()); 287 set_guid(profile.guid());
287 set_origin(profile.origin()); 288 set_origin(profile.origin());
288 289
289 record_type_ = profile.record_type_; 290 record_type_ = profile.record_type_;
290 291
291 name_ = profile.name_; 292 name_ = profile.name_;
292 email_ = profile.email_; 293 email_ = profile.email_;
293 company_ = profile.company_; 294 company_ = profile.company_;
294 phone_number_ = profile.phone_number_; 295 phone_number_ = profile.phone_number_;
295 296
296 for (size_t i = 0; i < phone_number_.size(); ++i) 297 for (size_t i = 0; i < phone_number_.size(); ++i)
297 phone_number_[i].set_profile(this); 298 phone_number_[i].set_profile(this);
298 299
299 address_ = profile.address_; 300 address_ = profile.address_;
300 set_language_code(profile.language_code()); 301 set_language_code(profile.language_code());
301 302
302 server_id_ = profile.server_id();
303
304 return *this; 303 return *this;
305 } 304 }
306 305
307 void AutofillProfile::GetMatchingTypes( 306 void AutofillProfile::GetMatchingTypes(
308 const base::string16& text, 307 const base::string16& text,
309 const std::string& app_locale, 308 const std::string& app_locale,
310 ServerFieldTypeSet* matching_types) const { 309 ServerFieldTypeSet* matching_types) const {
311 FormGroupList info = FormGroups(); 310 FormGroupList info = FormGroups();
312 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) 311 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it)
313 (*it)->GetMatchingTypes(text, app_locale, matching_types); 312 (*it)->GetMatchingTypes(text, app_locale, matching_types);
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 contents.append(GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); 830 contents.append(GetRawInfo(ADDRESS_HOME_STREET_ADDRESS));
832 contents.append(GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)); 831 contents.append(GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY));
833 contents.append(GetRawInfo(ADDRESS_HOME_CITY)); 832 contents.append(GetRawInfo(ADDRESS_HOME_CITY));
834 contents.append(GetRawInfo(ADDRESS_HOME_STATE)); 833 contents.append(GetRawInfo(ADDRESS_HOME_STATE));
835 contents.append(GetRawInfo(ADDRESS_HOME_ZIP)); 834 contents.append(GetRawInfo(ADDRESS_HOME_ZIP));
836 contents.append(GetRawInfo(ADDRESS_HOME_SORTING_CODE)); 835 contents.append(GetRawInfo(ADDRESS_HOME_SORTING_CODE));
837 contents.append(GetRawInfo(ADDRESS_HOME_COUNTRY)); 836 contents.append(GetRawInfo(ADDRESS_HOME_COUNTRY));
838 contents.append(MultiString(*this, PHONE_HOME_WHOLE_NUMBER)); 837 contents.append(MultiString(*this, PHONE_HOME_WHOLE_NUMBER));
839 std::string contents_utf8 = UTF16ToUTF8(contents); 838 std::string contents_utf8 = UTF16ToUTF8(contents);
840 contents_utf8.append(language_code()); 839 contents_utf8.append(language_code());
841 server_id_ = base::SHA1HashString(contents_utf8); 840 set_server_id(base::SHA1HashString(contents_utf8));
842 } 841 }
843 842
844 // static 843 // static
845 base::string16 AutofillProfile::CanonicalizeProfileString( 844 base::string16 AutofillProfile::CanonicalizeProfileString(
846 const base::string16& str) { 845 const base::string16& str) {
847 base::string16 ret; 846 base::string16 ret;
848 ret.reserve(str.size()); 847 ret.reserve(str.size());
849 848
850 bool previous_was_whitespace = false; 849 bool previous_was_whitespace = false;
851 850
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) 1171 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))
1173 << " " 1172 << " "
1174 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) 1173 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))
1175 << " " 1174 << " "
1176 << profile.language_code() 1175 << profile.language_code()
1177 << " " 1176 << " "
1178 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); 1177 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER));
1179 } 1178 }
1180 1179
1181 } // namespace autofill 1180 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698