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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 bool Address::SetInfo(const AutofillType& type, | 153 bool Address::SetInfo(const AutofillType& type, |
154 const base::string16& value, | 154 const base::string16& value, |
155 const std::string& app_locale) { | 155 const std::string& app_locale) { |
156 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { | 156 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { |
157 if (!value.empty() && (value.size() != 2u || !base::IsStringASCII(value))) { | 157 if (!value.empty() && (value.size() != 2u || !base::IsStringASCII(value))) { |
158 country_code_ = std::string(); | 158 country_code_ = std::string(); |
159 return false; | 159 return false; |
160 } | 160 } |
161 | 161 |
162 country_code_ = StringToUpperASCII(base::UTF16ToASCII(value)); | 162 country_code_ = base::StringToUpperASCII(base::UTF16ToASCII(value)); |
163 return true; | 163 return true; |
164 } else if (type.html_type() == HTML_TYPE_FULL_ADDRESS) { | 164 } else if (type.html_type() == HTML_TYPE_FULL_ADDRESS) { |
165 // Parsing a full address is too hard. | 165 // Parsing a full address is too hard. |
166 return false; | 166 return false; |
167 } | 167 } |
168 | 168 |
169 ServerFieldType storable_type = type.GetStorableType(); | 169 ServerFieldType storable_type = type.GetStorableType(); |
170 if (storable_type == ADDRESS_HOME_COUNTRY && !value.empty()) { | 170 if (storable_type == ADDRESS_HOME_COUNTRY && !value.empty()) { |
171 country_code_ = AutofillCountry::GetCountryCode(value, app_locale); | 171 country_code_ = AutofillCountry::GetCountryCode(value, app_locale); |
172 return !country_code_.empty(); | 172 return !country_code_.empty(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 supported_types->insert(ADDRESS_HOME_COUNTRY); | 211 supported_types->insert(ADDRESS_HOME_COUNTRY); |
212 } | 212 } |
213 | 213 |
214 void Address::TrimStreetAddress() { | 214 void Address::TrimStreetAddress() { |
215 while (!street_address_.empty() && street_address_.back().empty()) { | 215 while (!street_address_.empty() && street_address_.back().empty()) { |
216 street_address_.pop_back(); | 216 street_address_.pop_back(); |
217 } | 217 } |
218 } | 218 } |
219 | 219 |
220 } // namespace autofill | 220 } // namespace autofill |
OLD | NEW |