Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_country.cc
blob9740eb450238eb59e99c99514a68525a7be9538b
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
3 // found in the LICENSE file.
5 #include "components/autofill/core/browser/autofill_country.h"
7 #include <stddef.h>
8 #include <stdint.h>
9 #include <map>
10 #include <utility>
12 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/singleton.h"
15 #include "base/stl_util.h"
16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h"
18 #include "grit/components_strings.h"
19 #include "third_party/icu/source/common/unicode/locid.h"
20 #include "third_party/icu/source/common/unicode/uloc.h"
21 #include "third_party/icu/source/common/unicode/unistr.h"
22 #include "third_party/icu/source/common/unicode/urename.h"
23 #include "third_party/icu/source/common/unicode/utypes.h"
24 #include "third_party/icu/source/i18n/unicode/coll.h"
25 #include "third_party/icu/source/i18n/unicode/ucol.h"
26 #include "ui/base/l10n/l10n_util.h"
28 namespace autofill {
29 namespace {
31 // The maximum capacity needed to store a locale up to the country code.
32 const size_t kLocaleCapacity =
33 ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY + 1;
35 struct CountryData {
36 int postal_code_label_id;
37 int state_label_id;
38 AddressRequiredFields address_required_fields;
41 struct StaticCountryData {
42 char country_code[3];
43 CountryData country_data;
46 // Maps country codes to localized label string identifiers.
47 const StaticCountryData kCountryData[] = {
48 { "AC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
49 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
50 ADDRESS_REQUIRES_CITY } },
51 { "AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
52 IDS_AUTOFILL_FIELD_LABEL_PARISH,
53 ADDRESS_REQUIRES_STATE } },
54 { "AE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
55 IDS_AUTOFILL_FIELD_LABEL_EMIRATE,
56 ADDRESS_REQUIRES_STATE } },
57 { "AF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
58 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
59 ADDRESS_REQUIREMENTS_UNKNOWN } },
60 { "AG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
61 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
62 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } },
63 { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
64 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
65 ADDRESS_REQUIREMENTS_UNKNOWN } },
66 { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
67 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
68 ADDRESS_REQUIREMENTS_UNKNOWN } },
69 { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
70 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
71 ADDRESS_REQUIREMENTS_UNKNOWN } },
72 { "AO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
73 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
74 ADDRESS_REQUIREMENTS_UNKNOWN } },
75 { "AQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
76 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
77 ADDRESS_REQUIREMENTS_UNKNOWN } },
78 { "AR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
79 IDS_AUTOFILL_FIELD_LABEL_STATE,
80 ADDRESS_REQUIREMENTS_UNKNOWN } },
81 { "AS", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
82 IDS_AUTOFILL_FIELD_LABEL_STATE,
83 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
84 { "AT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
85 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
86 ADDRESS_REQUIRES_CITY_ZIP } },
87 { "AU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
88 IDS_AUTOFILL_FIELD_LABEL_STATE,
89 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
90 { "AW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
91 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
92 ADDRESS_REQUIREMENTS_UNKNOWN } },
93 { "AX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
94 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
95 ADDRESS_REQUIRES_CITY_ZIP } },
96 { "AZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
97 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
98 ADDRESS_REQUIREMENTS_UNKNOWN } },
99 { "BA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
100 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
101 ADDRESS_REQUIREMENTS_UNKNOWN } },
102 { "BB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
103 IDS_AUTOFILL_FIELD_LABEL_PARISH,
104 ADDRESS_REQUIREMENTS_UNKNOWN } },
105 { "BD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
106 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
107 ADDRESS_REQUIREMENTS_UNKNOWN } },
108 { "BE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
109 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
110 ADDRESS_REQUIRES_CITY_ZIP } },
111 { "BF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
112 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
113 ADDRESS_REQUIREMENTS_UNKNOWN } },
114 { "BG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
115 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
116 ADDRESS_REQUIREMENTS_UNKNOWN } },
117 { "BH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
118 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
119 ADDRESS_REQUIREMENTS_UNKNOWN } },
120 { "BI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
121 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
122 ADDRESS_REQUIREMENTS_UNKNOWN } },
123 { "BJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
124 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
125 ADDRESS_REQUIREMENTS_UNKNOWN } },
126 { "BL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
127 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
128 ADDRESS_REQUIRES_CITY_ZIP } },
129 { "BM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
130 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
131 ADDRESS_REQUIREMENTS_UNKNOWN } },
132 { "BN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
133 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
134 ADDRESS_REQUIREMENTS_UNKNOWN } },
135 { "BO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
136 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
137 ADDRESS_REQUIREMENTS_UNKNOWN } },
138 { "BR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
139 IDS_AUTOFILL_FIELD_LABEL_STATE,
140 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
141 { "BS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
142 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
143 ADDRESS_REQUIREMENTS_UNKNOWN } },
144 { "BT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
145 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
146 ADDRESS_REQUIREMENTS_UNKNOWN } },
147 { "BV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
148 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
149 ADDRESS_REQUIREMENTS_UNKNOWN } },
150 { "BW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
151 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
152 ADDRESS_REQUIREMENTS_UNKNOWN } },
153 { "BY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
154 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
155 ADDRESS_REQUIREMENTS_UNKNOWN } },
156 { "BZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
157 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
158 ADDRESS_REQUIREMENTS_UNKNOWN } },
159 { "CA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
160 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
161 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
162 { "CC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
163 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
164 ADDRESS_REQUIREMENTS_UNKNOWN } },
165 { "CD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
166 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
167 ADDRESS_REQUIREMENTS_UNKNOWN } },
168 { "CF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
169 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
170 ADDRESS_REQUIREMENTS_UNKNOWN } },
171 { "CG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
172 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
173 ADDRESS_REQUIREMENTS_UNKNOWN } },
174 { "CH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
175 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
176 ADDRESS_REQUIRES_CITY_ZIP } },
177 { "CI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
178 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
179 ADDRESS_REQUIREMENTS_UNKNOWN } },
180 { "CK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
181 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
182 ADDRESS_REQUIREMENTS_UNKNOWN } },
183 { "CL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
184 IDS_AUTOFILL_FIELD_LABEL_STATE,
185 ADDRESS_REQUIREMENTS_UNKNOWN } },
186 { "CM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
187 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
188 ADDRESS_REQUIREMENTS_UNKNOWN } },
189 { "CN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
190 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
191 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
192 { "CO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
193 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
194 ADDRESS_REQUIREMENTS_UNKNOWN } },
195 { "CR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
196 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
197 ADDRESS_REQUIREMENTS_UNKNOWN } },
198 { "CS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
199 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
200 ADDRESS_REQUIREMENTS_UNKNOWN } },
201 { "CV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
202 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
203 ADDRESS_REQUIREMENTS_UNKNOWN } },
204 { "CX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
205 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
206 ADDRESS_REQUIREMENTS_UNKNOWN } },
207 { "CY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
208 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
209 ADDRESS_REQUIREMENTS_UNKNOWN } },
210 { "CZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
211 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
212 ADDRESS_REQUIREMENTS_UNKNOWN } },
213 { "DE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
214 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
215 ADDRESS_REQUIRES_CITY_ZIP } },
216 { "DJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
217 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
218 ADDRESS_REQUIREMENTS_UNKNOWN } },
219 { "DK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
220 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
221 ADDRESS_REQUIRES_CITY_ZIP } },
222 { "DM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
223 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
224 ADDRESS_REQUIREMENTS_UNKNOWN } },
225 { "DO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
226 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
227 ADDRESS_REQUIREMENTS_UNKNOWN } },
228 { "DZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
229 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
230 ADDRESS_REQUIREMENTS_UNKNOWN } },
231 { "EC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
232 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
233 ADDRESS_REQUIREMENTS_UNKNOWN } },
234 { "EE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
235 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
236 ADDRESS_REQUIREMENTS_UNKNOWN } },
237 { "EG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
238 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
239 ADDRESS_REQUIREMENTS_UNKNOWN } },
240 { "EH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
241 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
242 ADDRESS_REQUIREMENTS_UNKNOWN } },
243 { "ER", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
244 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
245 ADDRESS_REQUIREMENTS_UNKNOWN } },
246 { "ES", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
247 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
248 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
249 { "ET", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
250 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
251 ADDRESS_REQUIREMENTS_UNKNOWN } },
252 { "FI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
253 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
254 ADDRESS_REQUIRES_CITY_ZIP } },
255 { "FJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
256 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
257 ADDRESS_REQUIREMENTS_UNKNOWN } },
258 { "FK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
259 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
260 ADDRESS_REQUIRES_CITY_ZIP } },
261 { "FM", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
262 IDS_AUTOFILL_FIELD_LABEL_STATE,
263 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
264 { "FO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
265 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
266 ADDRESS_REQUIREMENTS_UNKNOWN } },
267 { "FR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
268 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
269 ADDRESS_REQUIRES_CITY_ZIP } },
270 { "GA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
271 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
272 ADDRESS_REQUIREMENTS_UNKNOWN } },
273 { "GB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
274 IDS_AUTOFILL_FIELD_LABEL_COUNTY,
275 ADDRESS_REQUIRES_CITY_ZIP } },
276 { "GD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
277 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
278 ADDRESS_REQUIREMENTS_UNKNOWN } },
279 { "GE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
280 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
281 ADDRESS_REQUIREMENTS_UNKNOWN } },
282 { "GF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
283 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
284 ADDRESS_REQUIRES_CITY_ZIP } },
285 { "GG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
286 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
287 ADDRESS_REQUIRES_CITY_ZIP } },
288 { "GH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
289 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
290 ADDRESS_REQUIREMENTS_UNKNOWN } },
291 { "GI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
292 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
293 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } },
294 { "GL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
295 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
296 ADDRESS_REQUIRES_CITY_ZIP } },
297 { "GM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
298 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
299 ADDRESS_REQUIREMENTS_UNKNOWN } },
300 { "GN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
301 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
302 ADDRESS_REQUIREMENTS_UNKNOWN } },
303 { "GP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
304 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
305 ADDRESS_REQUIRES_CITY_ZIP } },
306 { "GQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
307 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
308 ADDRESS_REQUIREMENTS_UNKNOWN } },
309 { "GR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
310 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
311 ADDRESS_REQUIRES_CITY_ZIP } },
312 { "GS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
313 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
314 ADDRESS_REQUIRES_CITY_ZIP } },
315 { "GT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
316 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
317 ADDRESS_REQUIREMENTS_UNKNOWN } },
318 { "GU", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
319 IDS_AUTOFILL_FIELD_LABEL_STATE,
320 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
321 { "GW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
322 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
323 ADDRESS_REQUIREMENTS_UNKNOWN } },
324 { "GY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
325 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
326 ADDRESS_REQUIREMENTS_UNKNOWN } },
327 { "HK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
328 IDS_AUTOFILL_FIELD_LABEL_AREA,
329 ADDRESS_REQUIRES_STATE } },
330 { "HM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
331 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
332 ADDRESS_REQUIREMENTS_UNKNOWN } },
333 { "HN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
334 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
335 ADDRESS_REQUIRES_CITY_STATE } },
336 { "HR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
337 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
338 ADDRESS_REQUIREMENTS_UNKNOWN } },
339 { "HT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
340 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
341 ADDRESS_REQUIREMENTS_UNKNOWN } },
342 { "HU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
343 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
344 ADDRESS_REQUIREMENTS_UNKNOWN } },
345 { "ID", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
346 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
347 ADDRESS_REQUIREMENTS_UNKNOWN } },
348 { "IE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
349 IDS_AUTOFILL_FIELD_LABEL_COUNTY,
350 ADDRESS_REQUIREMENTS_UNKNOWN } },
351 { "IL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
352 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
353 ADDRESS_REQUIREMENTS_UNKNOWN } },
354 { "IM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
355 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
356 ADDRESS_REQUIRES_CITY_ZIP } },
357 { "IN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
358 IDS_AUTOFILL_FIELD_LABEL_STATE,
359 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
360 { "IO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
361 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
362 ADDRESS_REQUIRES_CITY_ZIP } },
363 { "IQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
364 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
365 ADDRESS_REQUIRES_CITY_STATE } },
366 { "IS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
367 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
368 ADDRESS_REQUIREMENTS_UNKNOWN } },
369 { "IT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
370 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
371 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
372 { "JE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
373 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
374 ADDRESS_REQUIRES_CITY_ZIP } },
375 { "JM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
376 IDS_AUTOFILL_FIELD_LABEL_PARISH,
377 ADDRESS_REQUIRES_CITY_STATE } },
378 { "JO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
379 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
380 ADDRESS_REQUIREMENTS_UNKNOWN } },
381 { "JP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
382 IDS_AUTOFILL_FIELD_LABEL_PREFECTURE,
383 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
384 { "KE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
385 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
386 ADDRESS_REQUIREMENTS_UNKNOWN } },
387 { "KG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
388 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
389 ADDRESS_REQUIREMENTS_UNKNOWN } },
390 { "KH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
391 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
392 ADDRESS_REQUIREMENTS_UNKNOWN } },
393 { "KI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
394 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
395 ADDRESS_REQUIREMENTS_UNKNOWN } },
396 { "KM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
397 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
398 ADDRESS_REQUIREMENTS_UNKNOWN } },
399 { "KN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
400 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
401 ADDRESS_REQUIRES_CITY_STATE } },
402 { "KP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
403 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
404 ADDRESS_REQUIREMENTS_UNKNOWN } },
405 { "KR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
406 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
407 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
408 { "KW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
409 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
410 ADDRESS_REQUIREMENTS_UNKNOWN } },
411 { "KY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
412 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
413 ADDRESS_REQUIRES_STATE } },
414 { "KZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
415 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
416 ADDRESS_REQUIREMENTS_UNKNOWN } },
417 { "LA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
418 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
419 ADDRESS_REQUIREMENTS_UNKNOWN } },
420 { "LB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
421 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
422 ADDRESS_REQUIREMENTS_UNKNOWN } },
423 { "LC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
424 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
425 ADDRESS_REQUIREMENTS_UNKNOWN } },
426 { "LI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
427 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
428 ADDRESS_REQUIRES_CITY_ZIP } },
429 { "LK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
430 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
431 ADDRESS_REQUIREMENTS_UNKNOWN } },
432 { "LR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
433 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
434 ADDRESS_REQUIREMENTS_UNKNOWN } },
435 { "LS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
436 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
437 ADDRESS_REQUIREMENTS_UNKNOWN } },
438 { "LT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
439 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
440 ADDRESS_REQUIREMENTS_UNKNOWN } },
441 { "LU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
442 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
443 ADDRESS_REQUIRES_CITY_ZIP } },
444 { "LV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
445 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
446 ADDRESS_REQUIREMENTS_UNKNOWN } },
447 { "LY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
448 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
449 ADDRESS_REQUIREMENTS_UNKNOWN } },
450 { "MA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
451 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
452 ADDRESS_REQUIREMENTS_UNKNOWN } },
453 { "MC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
454 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
455 ADDRESS_REQUIREMENTS_UNKNOWN } },
456 { "MD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
457 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
458 ADDRESS_REQUIREMENTS_UNKNOWN } },
459 { "ME", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
460 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
461 ADDRESS_REQUIREMENTS_UNKNOWN } },
462 { "MF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
463 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
464 ADDRESS_REQUIRES_CITY_ZIP } },
465 { "MG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
466 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
467 ADDRESS_REQUIREMENTS_UNKNOWN } },
468 { "MH", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
469 IDS_AUTOFILL_FIELD_LABEL_STATE,
470 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
471 { "MK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
472 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
473 ADDRESS_REQUIREMENTS_UNKNOWN } },
474 { "ML", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
475 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
476 ADDRESS_REQUIREMENTS_UNKNOWN } },
477 { "MN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
478 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
479 ADDRESS_REQUIREMENTS_UNKNOWN } },
480 { "MO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
481 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
482 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } },
483 { "MP", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
484 IDS_AUTOFILL_FIELD_LABEL_STATE,
485 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
486 { "MQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
487 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
488 ADDRESS_REQUIRES_CITY_ZIP } },
489 { "MR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
490 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
491 ADDRESS_REQUIREMENTS_UNKNOWN } },
492 { "MS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
493 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
494 ADDRESS_REQUIREMENTS_UNKNOWN } },
495 { "MT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
496 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
497 ADDRESS_REQUIREMENTS_UNKNOWN } },
498 { "MU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
499 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
500 ADDRESS_REQUIREMENTS_UNKNOWN } },
501 { "MV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
502 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
503 ADDRESS_REQUIREMENTS_UNKNOWN } },
504 { "MW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
505 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
506 ADDRESS_REQUIREMENTS_UNKNOWN } },
507 { "MX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
508 IDS_AUTOFILL_FIELD_LABEL_STATE,
509 ADDRESS_REQUIRES_CITY_ZIP } },
510 { "MY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
511 IDS_AUTOFILL_FIELD_LABEL_STATE,
512 ADDRESS_REQUIRES_CITY_ZIP } },
513 { "MZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
514 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
515 ADDRESS_REQUIREMENTS_UNKNOWN } },
516 { "NA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
517 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
518 ADDRESS_REQUIREMENTS_UNKNOWN } },
519 { "NC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
520 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
521 ADDRESS_REQUIRES_CITY_ZIP } },
522 { "NE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
523 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
524 ADDRESS_REQUIREMENTS_UNKNOWN } },
525 { "NF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
526 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
527 ADDRESS_REQUIREMENTS_UNKNOWN } },
528 { "NG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
529 IDS_AUTOFILL_FIELD_LABEL_STATE,
530 ADDRESS_REQUIREMENTS_UNKNOWN } },
531 { "NI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
532 IDS_AUTOFILL_FIELD_LABEL_DEPARTMENT,
533 ADDRESS_REQUIREMENTS_UNKNOWN } },
534 { "NL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
535 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
536 ADDRESS_REQUIRES_CITY_ZIP } },
537 { "NO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
538 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
539 ADDRESS_REQUIRES_CITY_ZIP } },
540 { "NP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
541 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
542 ADDRESS_REQUIREMENTS_UNKNOWN } },
543 { "NR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
544 IDS_AUTOFILL_FIELD_LABEL_DISTRICT,
545 ADDRESS_REQUIRES_STATE } },
546 { "NU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
547 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
548 ADDRESS_REQUIREMENTS_UNKNOWN } },
549 { "NZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
550 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
551 ADDRESS_REQUIRES_CITY_ZIP } },
552 { "OM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
553 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
554 ADDRESS_REQUIREMENTS_UNKNOWN } },
555 { "PA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
556 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
557 ADDRESS_REQUIREMENTS_UNKNOWN } },
558 { "PE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
559 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
560 ADDRESS_REQUIREMENTS_UNKNOWN } },
561 { "PF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
562 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
563 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
564 { "PG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
565 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
566 ADDRESS_REQUIRES_CITY_STATE } },
567 { "PH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
568 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
569 ADDRESS_REQUIRES_CITY } },
570 { "PK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
571 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
572 ADDRESS_REQUIREMENTS_UNKNOWN } },
573 { "PL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
574 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
575 ADDRESS_REQUIRES_CITY_ZIP } },
576 { "PM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
577 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
578 ADDRESS_REQUIRES_CITY_ZIP } },
579 { "PN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
580 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
581 ADDRESS_REQUIRES_CITY_ZIP } },
582 { "PR", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
583 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
584 ADDRESS_REQUIRES_CITY_ZIP } },
585 { "PS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
586 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
587 ADDRESS_REQUIREMENTS_UNKNOWN } },
588 { "PT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
589 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
590 ADDRESS_REQUIRES_CITY_ZIP } },
591 { "PW", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
592 IDS_AUTOFILL_FIELD_LABEL_STATE,
593 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
594 { "PY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
595 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
596 ADDRESS_REQUIREMENTS_UNKNOWN } },
597 { "QA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
598 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
599 ADDRESS_REQUIREMENTS_UNKNOWN } },
600 { "RE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
601 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
602 ADDRESS_REQUIRES_CITY_ZIP } },
603 { "RO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
604 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
605 ADDRESS_REQUIREMENTS_UNKNOWN } },
606 { "RS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
607 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
608 ADDRESS_REQUIREMENTS_UNKNOWN } },
609 { "RU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
610 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
611 ADDRESS_REQUIRES_CITY_ZIP } },
612 { "RW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
613 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
614 ADDRESS_REQUIREMENTS_UNKNOWN } },
615 { "SA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
616 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
617 ADDRESS_REQUIREMENTS_UNKNOWN } },
618 { "SB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
619 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
620 ADDRESS_REQUIREMENTS_UNKNOWN } },
621 { "SC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
622 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
623 ADDRESS_REQUIREMENTS_UNKNOWN } },
624 { "SE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
625 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
626 ADDRESS_REQUIRES_CITY_ZIP } },
627 { "SG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
628 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
629 ADDRESS_REQUIRES_ZIP } },
630 { "SH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
631 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
632 ADDRESS_REQUIRES_CITY_ZIP } },
633 { "SI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
634 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
635 ADDRESS_REQUIREMENTS_UNKNOWN } },
636 { "SJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
637 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
638 ADDRESS_REQUIRES_CITY_ZIP } },
639 { "SK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
640 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
641 ADDRESS_REQUIREMENTS_UNKNOWN } },
642 { "SL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
643 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
644 ADDRESS_REQUIREMENTS_UNKNOWN } },
645 { "SM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
646 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
647 ADDRESS_REQUIRES_ZIP } },
648 { "SN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
649 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
650 ADDRESS_REQUIREMENTS_UNKNOWN } },
651 { "SO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
652 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
653 ADDRESS_REQUIRES_CITY_STATE } },
654 { "SR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
655 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
656 ADDRESS_REQUIREMENTS_UNKNOWN } },
657 { "ST", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
658 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
659 ADDRESS_REQUIREMENTS_UNKNOWN } },
660 { "SV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
661 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
662 ADDRESS_REQUIRES_CITY_STATE } },
663 { "SZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
664 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
665 ADDRESS_REQUIREMENTS_UNKNOWN } },
666 { "TA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
667 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
668 ADDRESS_REQUIRES_CITY } },
669 { "TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
670 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
671 ADDRESS_REQUIRES_CITY_ZIP } },
672 { "TD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
673 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
674 ADDRESS_REQUIREMENTS_UNKNOWN } },
675 { "TF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
676 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
677 ADDRESS_REQUIREMENTS_UNKNOWN } },
678 { "TG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
679 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
680 ADDRESS_REQUIREMENTS_UNKNOWN } },
681 { "TH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
682 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
683 ADDRESS_REQUIREMENTS_UNKNOWN } },
684 { "TJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
685 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
686 ADDRESS_REQUIREMENTS_UNKNOWN } },
687 { "TK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
688 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
689 ADDRESS_REQUIREMENTS_UNKNOWN } },
690 { "TL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
691 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
692 ADDRESS_REQUIREMENTS_UNKNOWN } },
693 { "TM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
694 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
695 ADDRESS_REQUIREMENTS_UNKNOWN } },
696 { "TN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
697 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
698 ADDRESS_REQUIREMENTS_UNKNOWN } },
699 { "TO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
700 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
701 ADDRESS_REQUIREMENTS_UNKNOWN } },
702 { "TR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
703 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
704 ADDRESS_REQUIRES_CITY_ZIP } },
705 { "TT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
706 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
707 ADDRESS_REQUIREMENTS_UNKNOWN } },
708 { "TV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
709 IDS_AUTOFILL_FIELD_LABEL_ISLAND,
710 ADDRESS_REQUIREMENTS_UNKNOWN } },
711 { "TW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
712 IDS_AUTOFILL_FIELD_LABEL_COUNTY,
713 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
714 { "TZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
715 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
716 ADDRESS_REQUIREMENTS_UNKNOWN } },
717 { "UA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
718 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
719 ADDRESS_REQUIREMENTS_UNKNOWN } },
720 { "UG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
721 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
722 ADDRESS_REQUIREMENTS_UNKNOWN } },
723 { "UM", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
724 IDS_AUTOFILL_FIELD_LABEL_STATE,
725 ADDRESS_REQUIRES_CITY_STATE } },
726 { "US", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
727 IDS_AUTOFILL_FIELD_LABEL_STATE,
728 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
729 { "UY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
730 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
731 ADDRESS_REQUIREMENTS_UNKNOWN } },
732 { "UZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
733 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
734 ADDRESS_REQUIREMENTS_UNKNOWN } },
735 { "VA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
736 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
737 ADDRESS_REQUIREMENTS_UNKNOWN } },
738 { "VC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
739 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
740 ADDRESS_REQUIREMENTS_UNKNOWN } },
741 { "VE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
742 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
743 ADDRESS_REQUIRES_CITY_STATE } },
744 { "VG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
745 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
746 ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } },
747 { "VI", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
748 IDS_AUTOFILL_FIELD_LABEL_STATE,
749 ADDRESS_REQUIRES_CITY_STATE_ZIP } },
750 { "VN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
751 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
752 ADDRESS_REQUIRES_CITY } },
753 { "VU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
754 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
755 ADDRESS_REQUIREMENTS_UNKNOWN } },
756 { "WF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
757 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
758 ADDRESS_REQUIRES_CITY_ZIP } },
759 { "WS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
760 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
761 ADDRESS_REQUIREMENTS_UNKNOWN } },
762 { "XK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
763 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
764 ADDRESS_REQUIRES_CITY } },
765 { "YE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
766 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
767 ADDRESS_REQUIRES_CITY } },
768 { "YT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
769 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
770 ADDRESS_REQUIRES_CITY_ZIP } },
771 { "ZA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
772 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
773 ADDRESS_REQUIRES_CITY_ZIP } },
774 { "ZM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
775 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
776 ADDRESS_REQUIRES_CITY } },
777 { "ZW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
778 IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
779 ADDRESS_REQUIREMENTS_UNKNOWN } },
782 // A singleton class that encapsulates a map from country codes to country data.
783 class CountryDataMap {
784 public:
785 // A const iterator over the wrapped map data.
786 typedef std::map<std::string, CountryData>::const_iterator Iterator;
788 static CountryDataMap* GetInstance();
789 static const Iterator Begin();
790 static const Iterator End();
791 static const Iterator Find(const std::string& country_code);
793 private:
794 CountryDataMap();
795 friend struct base::DefaultSingletonTraits<CountryDataMap>;
797 std::map<std::string, CountryData> country_data_;
799 DISALLOW_COPY_AND_ASSIGN(CountryDataMap);
802 // static
803 CountryDataMap* CountryDataMap::GetInstance() {
804 return base::Singleton<CountryDataMap>::get();
807 CountryDataMap::CountryDataMap() {
808 // Add all the countries we have explicit data for.
809 for (size_t i = 0; i < arraysize(kCountryData); ++i) {
810 const StaticCountryData& static_data = kCountryData[i];
811 country_data_.insert(std::make_pair(static_data.country_code,
812 static_data.country_data));
815 // Add any other countries that ICU knows about, falling back to default data
816 // values.
817 for (const char* const* country_pointer = icu::Locale::getISOCountries();
818 *country_pointer;
819 ++country_pointer) {
820 std::string country_code = *country_pointer;
821 if (!country_data_.count(country_code)) {
822 CountryData data = {
823 IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
824 IDS_AUTOFILL_FIELD_LABEL_PROVINCE
826 country_data_.insert(std::make_pair(country_code, data));
831 const CountryDataMap::Iterator CountryDataMap::Begin() {
832 return GetInstance()->country_data_.begin();
835 const CountryDataMap::Iterator CountryDataMap::End() {
836 return GetInstance()->country_data_.end();
839 const CountryDataMap::Iterator CountryDataMap::Find(
840 const std::string& country_code) {
841 return GetInstance()->country_data_.find(country_code);
844 // A singleton class that encapsulates mappings from country names to their
845 // corresponding country codes.
846 class CountryNames {
847 public:
848 static CountryNames* GetInstance();
850 // Returns the country code corresponding to |country|, which should be a
851 // country code or country name localized to |locale|.
852 const std::string GetCountryCode(const base::string16& country,
853 const std::string& locale);
855 private:
856 CountryNames();
857 ~CountryNames();
858 friend struct base::DefaultSingletonTraits<CountryNames>;
860 // Populates |locales_to_localized_names_| with the mapping of country names
861 // localized to |locale| to their corresponding country codes.
862 void AddLocalizedNamesForLocale(const std::string& locale);
864 // Interprets |country_name| as a full country name localized to the given
865 // |locale| and returns the corresponding country code stored in
866 // |locales_to_localized_names_|, or an empty string if there is none.
867 const std::string GetCountryCodeForLocalizedName(
868 const base::string16& country_name,
869 const std::string& locale);
871 // Returns an ICU collator -- i.e. string comparator -- appropriate for the
872 // given |locale|.
873 icu::Collator* GetCollatorForLocale(const std::string& locale);
875 // Returns the ICU sort key corresponding to |str| for the given |collator|.
876 // Uses |buffer| as temporary storage, and might resize |buffer| as a side-
877 // effect. |buffer_size| should specify the |buffer|'s size, and is updated if
878 // the |buffer| is resized.
879 const std::string GetSortKey(const icu::Collator& collator,
880 const base::string16& str,
881 scoped_ptr<uint8_t[]>* buffer,
882 int32_t* buffer_size) const;
884 // Maps from common country names, including 2- and 3-letter country codes,
885 // to the corresponding 2-letter country codes. The keys are uppercase ASCII
886 // strings.
887 std::map<std::string, std::string> common_names_;
889 // The outer map keys are ICU locale identifiers.
890 // The inner maps map from localized country names to their corresponding
891 // country codes. The inner map keys are ICU collation sort keys corresponding
892 // to the target localized country name.
893 std::map<std::string, std::map<std::string, std::string> >
894 locales_to_localized_names_;
896 // Maps ICU locale names to their corresponding collators.
897 std::map<std::string, icu::Collator*> collators_;
899 DISALLOW_COPY_AND_ASSIGN(CountryNames);
902 // static
903 CountryNames* CountryNames::GetInstance() {
904 return base::Singleton<CountryNames>::get();
907 CountryNames::CountryNames() {
908 // Add 2- and 3-letter ISO country codes.
909 for (CountryDataMap::Iterator it = CountryDataMap::Begin();
910 it != CountryDataMap::End();
911 ++it) {
912 const std::string& country_code = it->first;
913 common_names_.insert(std::make_pair(country_code, country_code));
915 std::string iso3_country_code =
916 icu::Locale(NULL, country_code.c_str()).getISO3Country();
918 // ICU list of countries can be out-of-date with CLDR.
919 if (!iso3_country_code.empty())
920 common_names_.insert(std::make_pair(iso3_country_code, country_code));
923 // Add a few other common synonyms.
924 common_names_.insert(std::make_pair("UNITED STATES OF AMERICA", "US"));
925 common_names_.insert(std::make_pair("U.S.A.", "US"));
926 common_names_.insert(std::make_pair("GREAT BRITAIN", "GB"));
927 common_names_.insert(std::make_pair("UK", "GB"));
928 common_names_.insert(std::make_pair("BRASIL", "BR"));
929 common_names_.insert(std::make_pair("DEUTSCHLAND", "DE"));
932 CountryNames::~CountryNames() {
933 STLDeleteContainerPairSecondPointers(collators_.begin(),
934 collators_.end());
937 const std::string CountryNames::GetCountryCode(const base::string16& country,
938 const std::string& locale) {
939 // First, check common country names, including 2- and 3-letter country codes.
940 std::string country_utf8 = base::UTF16ToUTF8(base::ToUpperASCII(country));
941 const auto result = common_names_.find(country_utf8);
942 if (result != common_names_.end())
943 return result->second;
945 // Next, check country names localized to |locale|.
946 std::string country_code = GetCountryCodeForLocalizedName(country, locale);
947 if (!country_code.empty())
948 return country_code;
950 // Finally, check country names localized to US English.
951 return GetCountryCodeForLocalizedName(country, "en_US");
954 void CountryNames::AddLocalizedNamesForLocale(const std::string& locale) {
955 // Nothing to do if we've previously added the localized names for the given
956 // |locale|.
957 if (locales_to_localized_names_.count(locale))
958 return;
960 std::map<std::string, std::string> localized_names;
961 const icu::Collator* collator = GetCollatorForLocale(locale);
962 int32_t buffer_size = 1000;
963 scoped_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
965 for (CountryDataMap::Iterator it = CountryDataMap::Begin();
966 it != CountryDataMap::End();
967 ++it) {
968 const std::string& country_code = it->first;
969 base::string16 country_name = l10n_util::GetDisplayNameForCountry(
970 country_code, locale);
971 std::string sort_key = GetSortKey(*collator,
972 country_name,
973 &buffer,
974 &buffer_size);
976 localized_names.insert(std::make_pair(sort_key, country_code));
979 locales_to_localized_names_.insert(std::make_pair(locale, localized_names));
982 const std::string CountryNames::GetCountryCodeForLocalizedName(
983 const base::string16& country_name,
984 const std::string& locale) {
985 AddLocalizedNamesForLocale(locale);
987 icu::Collator* collator = GetCollatorForLocale(locale);
989 // As recommended[1] by ICU, initialize the buffer size to four times the
990 // source string length.
991 // [1] http://userguide.icu-project.org/collation/api#TOC-Examples
992 int32_t buffer_size = country_name.size() * 4;
993 scoped_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
994 std::string sort_key = GetSortKey(*collator,
995 country_name,
996 &buffer,
997 &buffer_size);
999 const std::map<std::string, std::string>& localized_names =
1000 locales_to_localized_names_[locale];
1001 std::map<std::string, std::string>::const_iterator result =
1002 localized_names.find(sort_key);
1004 if (result != localized_names.end())
1005 return result->second;
1007 return std::string();
1010 icu::Collator* CountryNames::GetCollatorForLocale(const std::string& locale) {
1011 if (!collators_.count(locale)) {
1012 icu::Locale icu_locale(locale.c_str());
1013 UErrorCode ignored = U_ZERO_ERROR;
1014 icu::Collator* collator(icu::Collator::createInstance(icu_locale, ignored));
1016 // Compare case-insensitively and ignoring punctuation.
1017 ignored = U_ZERO_ERROR;
1018 collator->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, ignored);
1019 ignored = U_ZERO_ERROR;
1020 collator->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, ignored);
1022 collators_.insert(std::make_pair(locale, collator));
1025 return collators_[locale];
1028 const std::string CountryNames::GetSortKey(const icu::Collator& collator,
1029 const base::string16& str,
1030 scoped_ptr<uint8_t[]>* buffer,
1031 int32_t* buffer_size) const {
1032 DCHECK(buffer);
1033 DCHECK(buffer_size);
1035 icu::UnicodeString icu_str(str.c_str(), str.length());
1036 int32_t expected_size = collator.getSortKey(icu_str, buffer->get(),
1037 *buffer_size);
1038 if (expected_size > *buffer_size) {
1039 // If there wasn't enough space, grow the buffer and try again.
1040 *buffer_size = expected_size;
1041 buffer->reset(new uint8_t[*buffer_size]);
1042 DCHECK(buffer->get());
1044 expected_size = collator.getSortKey(icu_str, buffer->get(), *buffer_size);
1045 DCHECK_EQ(*buffer_size, expected_size);
1048 return std::string(reinterpret_cast<const char*>(buffer->get()));
1051 } // namespace
1053 AutofillCountry::AutofillCountry(const std::string& country_code,
1054 const std::string& locale) {
1055 const CountryDataMap::Iterator result = CountryDataMap::Find(country_code);
1056 DCHECK(result != CountryDataMap::End());
1057 const CountryData& data = result->second;
1059 country_code_ = country_code;
1060 name_ = l10n_util::GetDisplayNameForCountry(country_code, locale);
1061 postal_code_label_ = l10n_util::GetStringUTF16(data.postal_code_label_id);
1062 state_label_ = l10n_util::GetStringUTF16(data.state_label_id);
1063 address_required_fields_ = data.address_required_fields;
1066 AutofillCountry::~AutofillCountry() {
1069 // static
1070 void AutofillCountry::GetAvailableCountries(
1071 std::vector<std::string>* country_codes) {
1072 DCHECK(country_codes);
1074 for (CountryDataMap::Iterator it = CountryDataMap::Begin();
1075 it != CountryDataMap::End();
1076 ++it) {
1077 country_codes->push_back(it->first);
1081 // static
1082 const std::string AutofillCountry::CountryCodeForLocale(
1083 const std::string& locale) {
1084 // Add likely subtags to the locale. In particular, add any likely country
1085 // subtags -- e.g. for locales like "ru" that only include the language.
1086 std::string likely_locale;
1087 UErrorCode error_ignored = U_ZERO_ERROR;
1088 uloc_addLikelySubtags(locale.c_str(),
1089 base::WriteInto(&likely_locale, kLocaleCapacity),
1090 kLocaleCapacity,
1091 &error_ignored);
1093 // Extract the country code.
1094 std::string country_code = icu::Locale(likely_locale.c_str()).getCountry();
1096 // Default to the United States if we have no better guess.
1097 if (CountryDataMap::Find(country_code) == CountryDataMap::End())
1098 return "US";
1100 return country_code;
1103 // static
1104 const std::string AutofillCountry::GetCountryCode(const base::string16& country,
1105 const std::string& locale) {
1106 return CountryNames::GetInstance()->GetCountryCode(country, locale);
1109 AutofillCountry::AutofillCountry(const std::string& country_code,
1110 const base::string16& name,
1111 const base::string16& postal_code_label,
1112 const base::string16& state_label)
1113 : country_code_(country_code),
1114 name_(name),
1115 postal_code_label_(postal_code_label),
1116 state_label_(state_label) {
1119 } // namespace autofill