| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 base::string16 Address::GetRawInfo(ServerFieldType type) const { | 43 base::string16 Address::GetRawInfo(ServerFieldType type) const { |
| 44 DCHECK_EQ(ADDRESS_HOME, AutofillType(type).group()); | 44 DCHECK_EQ(ADDRESS_HOME, AutofillType(type).group()); |
| 45 switch (type) { | 45 switch (type) { |
| 46 case ADDRESS_HOME_LINE1: | 46 case ADDRESS_HOME_LINE1: |
| 47 return street_address_.size() > 0 ? street_address_[0] : base::string16(); | 47 return street_address_.size() > 0 ? street_address_[0] : base::string16(); |
| 48 | 48 |
| 49 case ADDRESS_HOME_LINE2: | 49 case ADDRESS_HOME_LINE2: |
| 50 return street_address_.size() > 1 ? street_address_[1] : base::string16(); | 50 return street_address_.size() > 1 ? street_address_[1] : base::string16(); |
| 51 | 51 |
| 52 case ADDRESS_HOME_LINE3: |
| 53 return street_address_.size() > 2 ? street_address_[2] : base::string16(); |
| 54 |
| 52 case ADDRESS_HOME_DEPENDENT_LOCALITY: | 55 case ADDRESS_HOME_DEPENDENT_LOCALITY: |
| 53 return dependent_locality_; | 56 return dependent_locality_; |
| 54 | 57 |
| 55 case ADDRESS_HOME_CITY: | 58 case ADDRESS_HOME_CITY: |
| 56 return city_; | 59 return city_; |
| 57 | 60 |
| 58 case ADDRESS_HOME_STATE: | 61 case ADDRESS_HOME_STATE: |
| 59 return state_; | 62 return state_; |
| 60 | 63 |
| 61 case ADDRESS_HOME_ZIP: | 64 case ADDRESS_HOME_ZIP: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 TrimStreetAddress(); | 89 TrimStreetAddress(); |
| 87 break; | 90 break; |
| 88 | 91 |
| 89 case ADDRESS_HOME_LINE2: | 92 case ADDRESS_HOME_LINE2: |
| 90 if (street_address_.size() < 2) | 93 if (street_address_.size() < 2) |
| 91 street_address_.resize(2); | 94 street_address_.resize(2); |
| 92 street_address_[1] = value; | 95 street_address_[1] = value; |
| 93 TrimStreetAddress(); | 96 TrimStreetAddress(); |
| 94 break; | 97 break; |
| 95 | 98 |
| 99 case ADDRESS_HOME_LINE3: |
| 100 if (street_address_.size() < 3) |
| 101 street_address_.resize(3); |
| 102 street_address_[2] = value; |
| 103 TrimStreetAddress(); |
| 104 break; |
| 105 |
| 96 case ADDRESS_HOME_DEPENDENT_LOCALITY: | 106 case ADDRESS_HOME_DEPENDENT_LOCALITY: |
| 97 dependent_locality_ = value; | 107 dependent_locality_ = value; |
| 98 break; | 108 break; |
| 99 | 109 |
| 100 case ADDRESS_HOME_CITY: | 110 case ADDRESS_HOME_CITY: |
| 101 city_ = value; | 111 city_ = value; |
| 102 break; | 112 break; |
| 103 | 113 |
| 104 case ADDRESS_HOME_STATE: | 114 case ADDRESS_HOME_STATE: |
| 105 state_ = value; | 115 state_ = value; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 204 |
| 195 // Check to see if the |text| canonicalized as a country name is a match. | 205 // Check to see if the |text| canonicalized as a country name is a match. |
| 196 std::string country_code = AutofillCountry::GetCountryCode(text, app_locale); | 206 std::string country_code = AutofillCountry::GetCountryCode(text, app_locale); |
| 197 if (!country_code.empty() && country_code_ == country_code) | 207 if (!country_code.empty() && country_code_ == country_code) |
| 198 matching_types->insert(ADDRESS_HOME_COUNTRY); | 208 matching_types->insert(ADDRESS_HOME_COUNTRY); |
| 199 } | 209 } |
| 200 | 210 |
| 201 void Address::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { | 211 void Address::GetSupportedTypes(ServerFieldTypeSet* supported_types) const { |
| 202 supported_types->insert(ADDRESS_HOME_LINE1); | 212 supported_types->insert(ADDRESS_HOME_LINE1); |
| 203 supported_types->insert(ADDRESS_HOME_LINE2); | 213 supported_types->insert(ADDRESS_HOME_LINE2); |
| 214 supported_types->insert(ADDRESS_HOME_LINE3); |
| 204 supported_types->insert(ADDRESS_HOME_STREET_ADDRESS); | 215 supported_types->insert(ADDRESS_HOME_STREET_ADDRESS); |
| 205 supported_types->insert(ADDRESS_HOME_DEPENDENT_LOCALITY); | 216 supported_types->insert(ADDRESS_HOME_DEPENDENT_LOCALITY); |
| 206 supported_types->insert(ADDRESS_HOME_CITY); | 217 supported_types->insert(ADDRESS_HOME_CITY); |
| 207 supported_types->insert(ADDRESS_HOME_STATE); | 218 supported_types->insert(ADDRESS_HOME_STATE); |
| 208 supported_types->insert(ADDRESS_HOME_ZIP); | 219 supported_types->insert(ADDRESS_HOME_ZIP); |
| 209 supported_types->insert(ADDRESS_HOME_SORTING_CODE); | 220 supported_types->insert(ADDRESS_HOME_SORTING_CODE); |
| 210 supported_types->insert(ADDRESS_HOME_COUNTRY); | 221 supported_types->insert(ADDRESS_HOME_COUNTRY); |
| 211 } | 222 } |
| 212 | 223 |
| 213 void Address::TrimStreetAddress() { | 224 void Address::TrimStreetAddress() { |
| 214 while (!street_address_.empty() && street_address_.back().empty()) { | 225 while (!street_address_.empty() && street_address_.back().empty()) { |
| 215 street_address_.pop_back(); | 226 street_address_.pop_back(); |
| 216 } | 227 } |
| 217 } | 228 } |
| 218 | 229 |
| 219 } // namespace autofill | 230 } // namespace autofill |
| OLD | NEW |