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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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(); |
173 } | 173 } |
174 | 174 |
175 // If the address doesn't have any newlines, don't attempt to parse it into | |
176 // lines, since this is potentially a user-entered address in the user's own | |
177 // format, so the code would have to rely on iffy heuristics at best. | |
178 // Instead, just give up when importing addresses like this. | |
179 if (storable_type == ADDRESS_HOME_STREET_ADDRESS && !value.empty() && | |
Evan Stade
2014/06/28 01:01:35
this behavior was causing problems when I was tryi
| |
180 value.find(base::char16('\n')) == base::string16::npos) { | |
181 street_address_.clear(); | |
182 return false; | |
183 } | |
184 | |
185 SetRawInfo(storable_type, value); | 175 SetRawInfo(storable_type, value); |
186 | 176 |
187 // Likewise, give up when importing addresses with any entirely blank lines. | 177 // Give up when importing addresses with any entirely blank lines. |
188 // There's a good chance that this formatting is not intentional, but it's | 178 // There's a good chance that this formatting is not intentional, but it's |
189 // also not obviously safe to just strip the newlines. | 179 // also not obviously safe to just strip the newlines. |
190 if (storable_type == ADDRESS_HOME_STREET_ADDRESS && | 180 if (storable_type == ADDRESS_HOME_STREET_ADDRESS && |
191 std::find(street_address_.begin(), street_address_.end(), | 181 std::find(street_address_.begin(), street_address_.end(), |
192 base::string16()) != street_address_.end()) { | 182 base::string16()) != street_address_.end()) { |
193 street_address_.clear(); | 183 street_address_.clear(); |
194 return false; | 184 return false; |
195 } | 185 } |
196 | 186 |
197 return true; | 187 return true; |
(...skipping 23 matching lines...) Expand all Loading... | |
221 supported_types->insert(ADDRESS_HOME_COUNTRY); | 211 supported_types->insert(ADDRESS_HOME_COUNTRY); |
222 } | 212 } |
223 | 213 |
224 void Address::TrimStreetAddress() { | 214 void Address::TrimStreetAddress() { |
225 while (!street_address_.empty() && street_address_.back().empty()) { | 215 while (!street_address_.empty() && street_address_.back().empty()) { |
226 street_address_.pop_back(); | 216 street_address_.pop_back(); |
227 } | 217 } |
228 } | 218 } |
229 | 219 |
230 } // namespace autofill | 220 } // namespace autofill |
OLD | NEW |