OLD | NEW |
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/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // abandon the import. | 282 // abandon the import. |
283 if (!IsValidFieldTypeAndValue(types_seen, server_field_type, value)) { | 283 if (!IsValidFieldTypeAndValue(types_seen, server_field_type, value)) { |
284 imported_profile.reset(); | 284 imported_profile.reset(); |
285 local_imported_credit_card.reset(); | 285 local_imported_credit_card.reset(); |
286 break; | 286 break; |
287 } | 287 } |
288 | 288 |
289 types_seen.insert(server_field_type); | 289 types_seen.insert(server_field_type); |
290 | 290 |
291 if (group == CREDIT_CARD) { | 291 if (group == CREDIT_CARD) { |
292 if (LowerCaseEqualsASCII(field->form_control_type, "month")) { | 292 if (base::LowerCaseEqualsASCII(field->form_control_type, "month")) { |
293 DCHECK_EQ(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, server_field_type); | 293 DCHECK_EQ(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR, server_field_type); |
294 local_imported_credit_card->SetInfoForMonthInputType(value); | 294 local_imported_credit_card->SetInfoForMonthInputType(value); |
295 } else { | 295 } else { |
296 local_imported_credit_card->SetInfo(field_type, value, app_locale_); | 296 local_imported_credit_card->SetInfo(field_type, value, app_locale_); |
297 } | 297 } |
298 ++importable_credit_card_fields; | 298 ++importable_credit_card_fields; |
299 } else { | 299 } else { |
300 // We need to store phone data in the variables, before building the whole | 300 // We need to store phone data in the variables, before building the whole |
301 // number at the end. The rest of the fields are set "as is". | 301 // number at the end. The rest of the fields are set "as is". |
302 // If the fields are not the phone fields in question home.SetInfo() is | 302 // If the fields are not the phone fields in question home.SetInfo() is |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 return std::string(); | 1056 return std::string(); |
1057 | 1057 |
1058 // Count up country codes from existing profiles. | 1058 // Count up country codes from existing profiles. |
1059 std::map<std::string, int> votes; | 1059 std::map<std::string, int> votes; |
1060 // TODO(estade): can we make this GetProfiles() instead? It seems to cause | 1060 // TODO(estade): can we make this GetProfiles() instead? It seems to cause |
1061 // errors in tests on mac trybots. See http://crbug.com/57221 | 1061 // errors in tests on mac trybots. See http://crbug.com/57221 |
1062 const std::vector<AutofillProfile*>& profiles = web_profiles(); | 1062 const std::vector<AutofillProfile*>& profiles = web_profiles(); |
1063 std::vector<std::string> country_codes; | 1063 std::vector<std::string> country_codes; |
1064 AutofillCountry::GetAvailableCountries(&country_codes); | 1064 AutofillCountry::GetAvailableCountries(&country_codes); |
1065 for (size_t i = 0; i < profiles.size(); ++i) { | 1065 for (size_t i = 0; i < profiles.size(); ++i) { |
1066 std::string country_code = StringToUpperASCII(base::UTF16ToASCII( | 1066 std::string country_code = base::StringToUpperASCII(base::UTF16ToASCII( |
1067 profiles[i]->GetRawInfo(ADDRESS_HOME_COUNTRY))); | 1067 profiles[i]->GetRawInfo(ADDRESS_HOME_COUNTRY))); |
1068 | 1068 |
1069 if (std::find(country_codes.begin(), country_codes.end(), country_code) != | 1069 if (std::find(country_codes.begin(), country_codes.end(), country_code) != |
1070 country_codes.end()) { | 1070 country_codes.end()) { |
1071 // Verified profiles count 100x more than unverified ones. | 1071 // Verified profiles count 100x more than unverified ones. |
1072 votes[country_code] += profiles[i]->IsVerified() ? 100 : 1; | 1072 votes[country_code] += profiles[i]->IsVerified() ? 100 : 1; |
1073 } | 1073 } |
1074 } | 1074 } |
1075 | 1075 |
1076 // Take the most common country code. | 1076 // Take the most common country code. |
(...skipping 26 matching lines...) Expand all Loading... |
1103 // Populates |auxiliary_profiles_|. | 1103 // Populates |auxiliary_profiles_|. |
1104 LoadAuxiliaryProfiles(record_metrics); | 1104 LoadAuxiliaryProfiles(record_metrics); |
1105 | 1105 |
1106 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); | 1106 profiles_.insert(profiles_.end(), web_profiles_.begin(), web_profiles_.end()); |
1107 profiles_.insert( | 1107 profiles_.insert( |
1108 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); | 1108 profiles_.end(), auxiliary_profiles_.begin(), auxiliary_profiles_.end()); |
1109 return profiles_; | 1109 return profiles_; |
1110 } | 1110 } |
1111 | 1111 |
1112 } // namespace autofill | 1112 } // namespace autofill |
OLD | NEW |