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/address.h" | 5 #include "components/autofill/core/browser/address.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 | 9 |
10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/stl_util.h" |
12 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "components/autofill/core/browser/autofill_country.h" | 16 #include "components/autofill/core/browser/autofill_country.h" |
16 #include "components/autofill/core/browser/autofill_data_util.h" | 17 #include "components/autofill/core/browser/autofill_data_util.h" |
17 #include "components/autofill/core/browser/autofill_field.h" | 18 #include "components/autofill/core/browser/autofill_field.h" |
18 #include "components/autofill/core/browser/autofill_profile.h" | 19 #include "components/autofill/core/browser/autofill_profile.h" |
19 #include "components/autofill/core/browser/autofill_profile_comparator.h" | 20 #include "components/autofill/core/browser/autofill_profile_comparator.h" |
20 #include "components/autofill/core/browser/autofill_type.h" | 21 #include "components/autofill/core/browser/autofill_type.h" |
21 #include "components/autofill/core/browser/country_names.h" | 22 #include "components/autofill/core/browser/country_names.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 country_code_ = CountryNames::GetInstance()->GetCountryCode(value); | 193 country_code_ = CountryNames::GetInstance()->GetCountryCode(value); |
193 return !country_code_.empty(); | 194 return !country_code_.empty(); |
194 } | 195 } |
195 | 196 |
196 SetRawInfo(storable_type, value); | 197 SetRawInfo(storable_type, value); |
197 | 198 |
198 // Give up when importing addresses with any entirely blank lines. | 199 // Give up when importing addresses with any entirely blank lines. |
199 // There's a good chance that this formatting is not intentional, but it's | 200 // There's a good chance that this formatting is not intentional, but it's |
200 // also not obviously safe to just strip the newlines. | 201 // also not obviously safe to just strip the newlines. |
201 if (storable_type == ADDRESS_HOME_STREET_ADDRESS && | 202 if (storable_type == ADDRESS_HOME_STREET_ADDRESS && |
202 std::find(street_address_.begin(), street_address_.end(), | 203 base::ContainsValue(street_address_, base::string16())) { |
203 base::string16()) != street_address_.end()) { | |
204 street_address_.clear(); | 204 street_address_.clear(); |
205 return false; | 205 return false; |
206 } | 206 } |
207 | 207 |
208 return true; | 208 return true; |
209 } | 209 } |
210 | 210 |
211 void Address::GetMatchingTypes(const base::string16& text, | 211 void Address::GetMatchingTypes(const base::string16& text, |
212 const std::string& app_locale, | 212 const std::string& app_locale, |
213 ServerFieldTypeSet* matching_types) const { | 213 ServerFieldTypeSet* matching_types) const { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 supported_types->insert(ADDRESS_HOME_COUNTRY); | 253 supported_types->insert(ADDRESS_HOME_COUNTRY); |
254 } | 254 } |
255 | 255 |
256 void Address::TrimStreetAddress() { | 256 void Address::TrimStreetAddress() { |
257 while (!street_address_.empty() && street_address_.back().empty()) { | 257 while (!street_address_.empty() && street_address_.back().empty()) { |
258 street_address_.pop_back(); | 258 street_address_.pop_back(); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 } // namespace autofill | 262 } // namespace autofill |
OLD | NEW |