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_field.h" | 5 #include "components/autofill/core/browser/address_field.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 AddClassification(address1_, ADDRESS_HOME_LINE1, map) && | 119 AddClassification(address1_, ADDRESS_HOME_LINE1, map) && |
120 AddClassification(address2_, ADDRESS_HOME_LINE2, map) && | 120 AddClassification(address2_, ADDRESS_HOME_LINE2, map) && |
121 AddClassification(address3_, ADDRESS_HOME_LINE3, map) && | 121 AddClassification(address3_, ADDRESS_HOME_LINE3, map) && |
122 AddClassification(street_address_, ADDRESS_HOME_STREET_ADDRESS, map) && | 122 AddClassification(street_address_, ADDRESS_HOME_STREET_ADDRESS, map) && |
123 AddClassification(city_, ADDRESS_HOME_CITY, map) && | 123 AddClassification(city_, ADDRESS_HOME_CITY, map) && |
124 AddClassification(state_, ADDRESS_HOME_STATE, map) && | 124 AddClassification(state_, ADDRESS_HOME_STATE, map) && |
125 AddClassification(zip_, ADDRESS_HOME_ZIP, map) && | 125 AddClassification(zip_, ADDRESS_HOME_ZIP, map) && |
126 AddClassification(country_, ADDRESS_HOME_COUNTRY, map); | 126 AddClassification(country_, ADDRESS_HOME_COUNTRY, map); |
127 } | 127 } |
128 | 128 |
129 size_t AddressField::FieldCount() const { | |
130 size_t count = 0; | |
131 | |
132 if (company_) | |
133 ++count; | |
134 if (address1_) | |
135 ++count; | |
136 if (address2_) | |
137 ++count; | |
138 if (address3_) | |
139 ++count; | |
140 if (street_address_) | |
141 ++count; | |
142 if (city_) | |
143 ++count; | |
144 if (state_) | |
145 ++count; | |
146 if (zip_) | |
147 ++count; | |
148 if (zip4_) | |
149 ++count; | |
150 if (country_) | |
151 ++count; | |
152 | |
153 return count;; | |
Evan Stade
2015/01/21 22:52:49
nit: ;;
Lei Zhang
2015/01/22 08:07:36
Done.
| |
154 } | |
155 | |
129 bool AddressField::ParseCompany(AutofillScanner* scanner) { | 156 bool AddressField::ParseCompany(AutofillScanner* scanner) { |
130 if (company_ && !company_->IsEmpty()) | 157 if (company_ && !company_->IsEmpty()) |
131 return false; | 158 return false; |
132 | 159 |
133 return ParseField(scanner, UTF8ToUTF16(kCompanyRe), &company_); | 160 return ParseField(scanner, UTF8ToUTF16(kCompanyRe), &company_); |
134 } | 161 } |
135 | 162 |
136 bool AddressField::ParseAddressLines(AutofillScanner* scanner) { | 163 bool AddressField::ParseAddressLines(AutofillScanner* scanner) { |
137 // We only match the string "address" in page text, not in element names, | 164 // We only match the string "address" in page text, not in element names, |
138 // because sometimes every element in a group of address fields will have | 165 // because sometimes every element in a group of address fields will have |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 if (state_) | 274 if (state_) |
248 return false; | 275 return false; |
249 | 276 |
250 return ParseFieldSpecifics(scanner, | 277 return ParseFieldSpecifics(scanner, |
251 UTF8ToUTF16(kStateRe), | 278 UTF8ToUTF16(kStateRe), |
252 MATCH_DEFAULT | MATCH_SELECT, | 279 MATCH_DEFAULT | MATCH_SELECT, |
253 &state_); | 280 &state_); |
254 } | 281 } |
255 | 282 |
256 } // namespace autofill | 283 } // namespace autofill |
OLD | NEW |