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

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

Issue 2832003003: Revert of [Payments] Normalize Shipping Address sent to merchant on Desktop. (Closed)
Patch Set: Created 3 years, 8 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/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"
11 #include "base/logging.h" 10 #include "base/logging.h"
12 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
13 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "components/autofill/core/browser/autofill_country.h" 14 #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_field.h" 15 #include "components/autofill/core/browser/autofill_field.h"
18 #include "components/autofill/core/browser/autofill_profile.h" 16 #include "components/autofill/core/browser/autofill_profile.h"
19 #include "components/autofill/core/browser/autofill_profile_comparator.h" 17 #include "components/autofill/core/browser/autofill_profile_comparator.h"
20 #include "components/autofill/core/browser/autofill_type.h" 18 #include "components/autofill/core/browser/autofill_type.h"
21 #include "components/autofill/core/browser/country_names.h" 19 #include "components/autofill/core/browser/country_names.h"
22 #include "components/autofill/core/browser/state_names.h" 20 #include "components/autofill/core/browser/state_names.h"
23 #include "components/autofill/core/common/autofill_l10n_util.h" 21 #include "components/autofill/core/common/autofill_l10n_util.h"
24 22
25 namespace autofill { 23 namespace autofill {
26 24
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 case ADDRESS_HOME_CITY: 127 case ADDRESS_HOME_CITY:
130 city_ = value; 128 city_ = value;
131 break; 129 break;
132 130
133 case ADDRESS_HOME_STATE: 131 case ADDRESS_HOME_STATE:
134 state_ = value; 132 state_ = value;
135 break; 133 break;
136 134
137 case ADDRESS_HOME_COUNTRY: 135 case ADDRESS_HOME_COUNTRY:
138 DCHECK(value.empty() || 136 DCHECK(value.empty() ||
139 data_util::IsValidCountryCode(base::i18n::ToUpper(value))); 137 (value.length() == 2u && base::IsStringASCII(value)));
140 country_code_ = base::ToUpperASCII(base::UTF16ToASCII(value)); 138 country_code_ = base::UTF16ToASCII(value);
141 break; 139 break;
142 140
143 case ADDRESS_HOME_ZIP: 141 case ADDRESS_HOME_ZIP:
144 zip_code_ = value; 142 zip_code_ = value;
145 break; 143 break;
146 144
147 case ADDRESS_HOME_SORTING_CODE: 145 case ADDRESS_HOME_SORTING_CODE:
148 sorting_code_ = value; 146 sorting_code_ = value;
149 break; 147 break;
150 148
(...skipping 17 matching lines...) Expand all
168 if (storable_type == ADDRESS_HOME_COUNTRY && !country_code_.empty()) 166 if (storable_type == ADDRESS_HOME_COUNTRY && !country_code_.empty())
169 return AutofillCountry(country_code_, app_locale).name(); 167 return AutofillCountry(country_code_, app_locale).name();
170 168
171 return GetRawInfo(storable_type); 169 return GetRawInfo(storable_type);
172 } 170 }
173 171
174 bool Address::SetInfo(const AutofillType& type, 172 bool Address::SetInfo(const AutofillType& type,
175 const base::string16& value, 173 const base::string16& value,
176 const std::string& app_locale) { 174 const std::string& app_locale) {
177 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { 175 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) {
178 if (!data_util::IsValidCountryCode(base::i18n::ToUpper(value))) { 176 if (!value.empty() && (value.size() != 2u || !base::IsStringASCII(value))) {
179 country_code_ = std::string(); 177 country_code_ = std::string();
180 return false; 178 return false;
181 } 179 }
182 180
183 country_code_ = base::ToUpperASCII(base::UTF16ToASCII(value)); 181 country_code_ = base::ToUpperASCII(base::UTF16ToASCII(value));
184 return true; 182 return true;
185 } else if (type.html_type() == HTML_TYPE_FULL_ADDRESS) { 183 } else if (type.html_type() == HTML_TYPE_FULL_ADDRESS) {
186 // Parsing a full address is too hard. 184 // Parsing a full address is too hard.
187 return false; 185 return false;
188 } 186 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 supported_types->insert(ADDRESS_HOME_COUNTRY); 251 supported_types->insert(ADDRESS_HOME_COUNTRY);
254 } 252 }
255 253
256 void Address::TrimStreetAddress() { 254 void Address::TrimStreetAddress() {
257 while (!street_address_.empty() && street_address_.back().empty()) { 255 while (!street_address_.empty() && street_address_.back().empty()) {
258 street_address_.pop_back(); 256 street_address_.pop_back();
259 } 257 }
260 } 258 }
261 259
262 } // namespace autofill 260 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698