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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 case ADDRESS_HOME_CITY: | 100 case ADDRESS_HOME_CITY: |
101 city_ = value; | 101 city_ = value; |
102 break; | 102 break; |
103 | 103 |
104 case ADDRESS_HOME_STATE: | 104 case ADDRESS_HOME_STATE: |
105 state_ = value; | 105 state_ = value; |
106 break; | 106 break; |
107 | 107 |
108 case ADDRESS_HOME_COUNTRY: | 108 case ADDRESS_HOME_COUNTRY: |
109 DCHECK(value.empty() || | 109 DCHECK(value.empty() || |
110 (value.length() == 2u && IsStringASCII(value))); | 110 (value.length() == 2u && base::IsStringASCII(value))); |
111 country_code_ = base::UTF16ToASCII(value); | 111 country_code_ = base::UTF16ToASCII(value); |
112 break; | 112 break; |
113 | 113 |
114 case ADDRESS_HOME_ZIP: | 114 case ADDRESS_HOME_ZIP: |
115 zip_code_ = value; | 115 zip_code_ = value; |
116 break; | 116 break; |
117 | 117 |
118 case ADDRESS_HOME_SORTING_CODE: | 118 case ADDRESS_HOME_SORTING_CODE: |
119 sorting_code_ = value; | 119 sorting_code_ = value; |
120 break; | 120 break; |
(...skipping 16 matching lines...) Expand all Loading... |
137 if (storable_type == ADDRESS_HOME_COUNTRY && !country_code_.empty()) | 137 if (storable_type == ADDRESS_HOME_COUNTRY && !country_code_.empty()) |
138 return AutofillCountry(country_code_, app_locale).name(); | 138 return AutofillCountry(country_code_, app_locale).name(); |
139 | 139 |
140 return GetRawInfo(storable_type); | 140 return GetRawInfo(storable_type); |
141 } | 141 } |
142 | 142 |
143 bool Address::SetInfo(const AutofillType& type, | 143 bool Address::SetInfo(const AutofillType& type, |
144 const base::string16& value, | 144 const base::string16& value, |
145 const std::string& app_locale) { | 145 const std::string& app_locale) { |
146 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { | 146 if (type.html_type() == HTML_TYPE_COUNTRY_CODE) { |
147 if (!value.empty() && (value.size() != 2u || !IsStringASCII(value))) { | 147 if (!value.empty() && (value.size() != 2u || !base::IsStringASCII(value))) { |
148 country_code_ = std::string(); | 148 country_code_ = std::string(); |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 country_code_ = StringToUpperASCII(base::UTF16ToASCII(value)); | 152 country_code_ = StringToUpperASCII(base::UTF16ToASCII(value)); |
153 return true; | 153 return true; |
154 } | 154 } |
155 | 155 |
156 ServerFieldType storable_type = type.GetStorableType(); | 156 ServerFieldType storable_type = type.GetStorableType(); |
157 if (storable_type == ADDRESS_HOME_COUNTRY && !value.empty()) { | 157 if (storable_type == ADDRESS_HOME_COUNTRY && !value.empty()) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 supported_types->insert(ADDRESS_HOME_COUNTRY); | 207 supported_types->insert(ADDRESS_HOME_COUNTRY); |
208 } | 208 } |
209 | 209 |
210 void Address::TrimStreetAddress() { | 210 void Address::TrimStreetAddress() { |
211 while (!street_address_.empty() && street_address_.back().empty()) { | 211 while (!street_address_.empty() && street_address_.back().empty()) { |
212 street_address_.pop_back(); | 212 street_address_.pop_back(); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 } // namespace autofill | 216 } // namespace autofill |
OLD | NEW |