autofill_country.cc revision ca12bfac764ba476d6cd062bf1dde12cc64c3f40
15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/autofill/core/browser/autofill_country.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include <stddef.h>
84e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include <stdint.h>
94e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include <map>
10c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include <utility>
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/logging.h"
13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "base/memory/singleton.h"
15d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/stl_util.h"
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/strings/string_util.h"
175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/strings/utf_string_conversions.h"
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "grit/component_strings.h"
195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "third_party/icu/source/common/unicode/locid.h"
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "third_party/icu/source/common/unicode/uloc.h"
215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "third_party/icu/source/common/unicode/unistr.h"
226d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)#include "third_party/icu/source/common/unicode/urename.h"
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "third_party/icu/source/common/unicode/utypes.h"
24a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "third_party/icu/source/i18n/unicode/coll.h"
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "third_party/icu/source/i18n/unicode/ucol.h"
267d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "ui/base/l10n/l10n_util.h"
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace autofill {
29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)namespace {
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The maximum capacity needed to store a locale up to the country code.
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)const size_t kLocaleCapacity =
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY + 1;
34116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)struct CountryData {
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int postal_code_label_id;
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  int state_label_id;
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  AddressRequiredFields address_required_fields;
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)};
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdochstruct StaticCountryData {
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  char country_code[3];
43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  CountryData country_data;
44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch};
45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Maps country codes to localized label string identifiers.
477d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)const StaticCountryData kCountryData[] = {
487d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)  { "AD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PARISH,
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_STATE } },
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
526d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_EMIRATE,
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            ADDRESS_REQUIRES_STATE } },
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
55c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
56ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch            ADDRESS_REQUIREMENTS_UNKNOWN } },
57c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "AG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
59f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } },
605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
616d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  { "AR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_STATE,
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AS", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_STATE,
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
8403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)  { "AT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_STATE,
895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "AX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
956d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
966d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  { "AZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PARISH,
1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1065d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1096d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1106d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
1115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
116a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
117a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "BH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
118a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci            ADDRESS_REQUIREMENTS_UNKNOWN } },
120a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "BI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
121a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
123a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "BJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
124a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
125a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
126a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "BL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
127a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
128a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
129a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "BM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1314e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
132c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "BN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_STATE,
140c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
142c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_ISLAND,
143c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
144c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "BT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
145c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
147868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  { "BV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  { "BW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
15203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  { "BY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "BZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "CA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
1625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "CC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
163c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
164c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
165c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "CD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
166c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
167c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
168c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "CF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
169c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
170c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
171c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "CG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
172c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
173c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
174c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "CH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
175f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
176f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
177f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "CI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
178f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
179c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
180c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "CK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "CL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_STATE,
1851320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci            ADDRESS_REQUIREMENTS_UNKNOWN } },
186f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "CM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
187f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
188f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
189f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "CN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
190f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
191c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
1922a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  { "CO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1932a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  { "CR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
1975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
1985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "CS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
1995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "CV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_ISLAND,
2035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
204c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "CX", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
205c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
206ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdoch            ADDRESS_REQUIREMENTS_UNKNOWN } },
207c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  { "CY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
208c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2094e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
210f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "CZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  { "DE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
2164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  { "DJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2174e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
218f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
219f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "DK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
220f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
221f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
222f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "DM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
223f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
224f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
225f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "DO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
226f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
227f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
228f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "DZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
229f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
230f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  { "EC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
232f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
233f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
234f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "EE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
235f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
236f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
237f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "EG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
238f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
239f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
240f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "EH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
241f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2421320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci            ADDRESS_REQUIREMENTS_UNKNOWN } },
2434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  { "ER", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
244f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2454e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2464e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  { "ES", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2474e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2484e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
2494e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  { "ET", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2504e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
252a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "FI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
253c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2541320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci            ADDRESS_REQUIRES_CITY_ZIP } },
255f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "FJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
256c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2574e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2584e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  { "FK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
259c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
260c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
261f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "FM", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
262c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_STATE,
263c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
264c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "FO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
265c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
266c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
267c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)  { "FR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
268c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
270868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  { "GA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
271c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  { "GB", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_COUNTY,
275f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
276f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "GD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
277f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
278f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
279f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "GE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
280f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2831320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
2855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
2885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
2895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
2905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
2915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GI", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
292f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
293f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } },
2945d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
295f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
296f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
297f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  { "GM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
298f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
299f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
3005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
301a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
302a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
303a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "GP", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
304a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
305a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
306a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "GQ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
307a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
308a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
309a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "GR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
3105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
3115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
3125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
3135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
3145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_ZIP } },
3155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
3165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
3175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            ADDRESS_REQUIREMENTS_UNKNOWN } },
3185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  { "GU", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
3195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_STATE,
320a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
321a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  { "GW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
322a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
3232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)            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  { "TC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
667            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
668            ADDRESS_REQUIRES_CITY_ZIP } },
669  { "TD", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
670            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
671            ADDRESS_REQUIREMENTS_UNKNOWN } },
672  { "TF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
673            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
674            ADDRESS_REQUIREMENTS_UNKNOWN } },
675  { "TG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
676            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
677            ADDRESS_REQUIREMENTS_UNKNOWN } },
678  { "TH", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
679            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
680            ADDRESS_REQUIREMENTS_UNKNOWN } },
681  { "TJ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
682            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
683            ADDRESS_REQUIREMENTS_UNKNOWN } },
684  { "TK", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
685            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
686            ADDRESS_REQUIREMENTS_UNKNOWN } },
687  { "TL", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
688            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
689            ADDRESS_REQUIREMENTS_UNKNOWN } },
690  { "TM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
691            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
692            ADDRESS_REQUIREMENTS_UNKNOWN } },
693  { "TN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
694            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
695            ADDRESS_REQUIREMENTS_UNKNOWN } },
696  { "TO", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
697            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
698            ADDRESS_REQUIREMENTS_UNKNOWN } },
699  { "TR", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
700            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
701            ADDRESS_REQUIRES_CITY_ZIP } },
702  { "TT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
703            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
704            ADDRESS_REQUIREMENTS_UNKNOWN } },
705  { "TV", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
706            IDS_AUTOFILL_FIELD_LABEL_ISLAND,
707            ADDRESS_REQUIREMENTS_UNKNOWN } },
708  { "TW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
709            IDS_AUTOFILL_FIELD_LABEL_COUNTY,
710            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
711  { "TZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
712            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
713            ADDRESS_REQUIREMENTS_UNKNOWN } },
714  { "UA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
715            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
716            ADDRESS_REQUIREMENTS_UNKNOWN } },
717  { "UG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
718            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
719            ADDRESS_REQUIREMENTS_UNKNOWN } },
720  { "UM", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
721            IDS_AUTOFILL_FIELD_LABEL_STATE,
722            ADDRESS_REQUIRES_CITY_STATE } },
723  { "US", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
724            IDS_AUTOFILL_FIELD_LABEL_STATE,
725            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
726  { "UY", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
727            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
728            ADDRESS_REQUIREMENTS_UNKNOWN } },
729  { "UZ", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
730            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
731            ADDRESS_REQUIREMENTS_UNKNOWN } },
732  { "VA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
733            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
734            ADDRESS_REQUIREMENTS_UNKNOWN } },
735  { "VC", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
736            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
737            ADDRESS_REQUIREMENTS_UNKNOWN } },
738  { "VE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
739            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
740            ADDRESS_REQUIRES_CITY_STATE } },
741  { "VG", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
742            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
743            ADDRESS_REQUIRES_ADDRESS_LINE_1_ONLY } },
744  { "VI", { IDS_AUTOFILL_FIELD_LABEL_ZIP_CODE,
745            IDS_AUTOFILL_FIELD_LABEL_STATE,
746            ADDRESS_REQUIRES_CITY_STATE_ZIP } },
747  { "VN", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
748            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
749            ADDRESS_REQUIRES_CITY } },
750  { "VU", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
751            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
752            ADDRESS_REQUIREMENTS_UNKNOWN } },
753  { "WF", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
754            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
755            ADDRESS_REQUIRES_CITY_ZIP } },
756  { "WS", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
757            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
758            ADDRESS_REQUIREMENTS_UNKNOWN } },
759  { "YE", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
760            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
761            ADDRESS_REQUIRES_CITY } },
762  { "YT", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
763            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
764            ADDRESS_REQUIRES_CITY_ZIP } },
765  { "ZA", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
766            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
767            ADDRESS_REQUIRES_CITY_ZIP } },
768  { "ZM", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
769            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
770            ADDRESS_REQUIRES_CITY } },
771  { "ZW", { IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
772            IDS_AUTOFILL_FIELD_LABEL_PROVINCE,
773            ADDRESS_REQUIREMENTS_UNKNOWN } },
774};
775
776// A singleton class that encapsulates a map from country codes to country data.
777class CountryDataMap {
778 public:
779  // A const iterator over the wrapped map data.
780  typedef std::map<std::string, CountryData>::const_iterator Iterator;
781
782  static CountryDataMap* GetInstance();
783  static const Iterator Begin();
784  static const Iterator End();
785  static const Iterator Find(const std::string& country_code);
786
787 private:
788  CountryDataMap();
789  friend struct DefaultSingletonTraits<CountryDataMap>;
790
791  std::map<std::string, CountryData> country_data_;
792
793  DISALLOW_COPY_AND_ASSIGN(CountryDataMap);
794};
795
796// static
797CountryDataMap* CountryDataMap::GetInstance() {
798  return Singleton<CountryDataMap>::get();
799}
800
801CountryDataMap::CountryDataMap() {
802  // Add all the countries we have explicit data for.
803  for (size_t i = 0; i < arraysize(kCountryData); ++i) {
804    const StaticCountryData& static_data = kCountryData[i];
805    country_data_.insert(std::make_pair(static_data.country_code,
806                                        static_data.country_data));
807  }
808
809  // Add any other countries that ICU knows about, falling back to default data
810  // values.
811  for (const char* const* country_pointer = icu::Locale::getISOCountries();
812       *country_pointer;
813       ++country_pointer) {
814    std::string country_code = *country_pointer;
815    if (!country_data_.count(country_code)) {
816      CountryData data = {
817        IDS_AUTOFILL_FIELD_LABEL_POSTAL_CODE,
818        IDS_AUTOFILL_FIELD_LABEL_PROVINCE
819      };
820      country_data_.insert(std::make_pair(country_code, data));
821    }
822  }
823}
824
825const CountryDataMap::Iterator CountryDataMap::Begin() {
826  return GetInstance()->country_data_.begin();
827}
828
829const CountryDataMap::Iterator CountryDataMap::End() {
830  return GetInstance()->country_data_.end();
831}
832
833const CountryDataMap::Iterator CountryDataMap::Find(
834    const std::string& country_code) {
835  return GetInstance()->country_data_.find(country_code);
836}
837
838// A singleton class that encapsulates mappings from country names to their
839// corresponding country codes.
840class CountryNames {
841 public:
842  static CountryNames* GetInstance();
843
844  // Returns the country code corresponding to |country|, which should be a
845  // country code or country name localized to |locale|.
846  const std::string GetCountryCode(const base::string16& country,
847                                   const std::string& locale);
848
849 private:
850  CountryNames();
851  ~CountryNames();
852  friend struct DefaultSingletonTraits<CountryNames>;
853
854  // Populates |locales_to_localized_names_| with the mapping of country names
855  // localized to |locale| to their corresponding country codes.
856  void AddLocalizedNamesForLocale(const std::string& locale);
857
858  // Interprets |country_name| as a full country name localized to the given
859  // |locale| and returns the corresponding country code stored in
860  // |locales_to_localized_names_|, or an empty string if there is none.
861  const std::string GetCountryCodeForLocalizedName(
862      const base::string16& country_name,
863      const std::string& locale);
864
865  // Returns an ICU collator -- i.e. string comparator -- appropriate for the
866  // given |locale|.
867  icu::Collator* GetCollatorForLocale(const std::string& locale);
868
869  // Returns the ICU sort key corresponding to |str| for the given |collator|.
870  // Uses |buffer| as temporary storage, and might resize |buffer| as a side-
871  // effect. |buffer_size| should specify the |buffer|'s size, and is updated if
872  // the |buffer| is resized.
873  const std::string GetSortKey(const icu::Collator& collator,
874                               const base::string16& str,
875                               scoped_ptr<uint8_t[]>* buffer,
876                               int32_t* buffer_size) const;
877
878  // Maps from common country names, including 2- and 3-letter country codes,
879  // to the corresponding 2-letter country codes. The keys are uppercase ASCII
880  // strings.
881  std::map<std::string, std::string> common_names_;
882
883  // The outer map keys are ICU locale identifiers.
884  // The inner maps map from localized country names to their corresponding
885  // country codes. The inner map keys are ICU collation sort keys corresponding
886  // to the target localized country name.
887  std::map<std::string, std::map<std::string, std::string> >
888      locales_to_localized_names_;
889
890  // Maps ICU locale names to their corresponding collators.
891  std::map<std::string, icu::Collator*> collators_;
892
893  DISALLOW_COPY_AND_ASSIGN(CountryNames);
894};
895
896// static
897CountryNames* CountryNames::GetInstance() {
898  return Singleton<CountryNames>::get();
899}
900
901CountryNames::CountryNames() {
902  // Add 2- and 3-letter ISO country codes.
903  for (CountryDataMap::Iterator it = CountryDataMap::Begin();
904       it != CountryDataMap::End();
905       ++it) {
906    const std::string& country_code = it->first;
907    std::string iso3_country_code =
908        icu::Locale(NULL, country_code.c_str()).getISO3Country();
909
910    common_names_.insert(std::make_pair(country_code, country_code));
911    common_names_.insert(std::make_pair(iso3_country_code, country_code));
912  }
913
914  // Add a few other common synonyms.
915  common_names_.insert(std::make_pair("UNITED STATES OF AMERICA", "US"));
916  common_names_.insert(std::make_pair("U.S.A.", "US"));
917  common_names_.insert(std::make_pair("GREAT BRITAIN", "GB"));
918  common_names_.insert(std::make_pair("UK", "GB"));
919  common_names_.insert(std::make_pair("BRASIL", "BR"));
920  common_names_.insert(std::make_pair("DEUTSCHLAND", "DE"));
921}
922
923CountryNames::~CountryNames() {
924  STLDeleteContainerPairSecondPointers(collators_.begin(),
925                                       collators_.end());
926}
927
928const std::string CountryNames::GetCountryCode(const base::string16& country,
929                                               const std::string& locale) {
930  // First, check common country names, including 2- and 3-letter country codes.
931  std::string country_utf8 = UTF16ToUTF8(StringToUpperASCII(country));
932  std::map<std::string, std::string>::const_iterator result =
933      common_names_.find(country_utf8);
934  if (result != common_names_.end())
935    return result->second;
936
937  // Next, check country names localized to |locale|.
938  std::string country_code = GetCountryCodeForLocalizedName(country, locale);
939  if (!country_code.empty())
940    return country_code;
941
942  // Finally, check country names localized to US English.
943  return GetCountryCodeForLocalizedName(country, "en_US");
944}
945
946void CountryNames::AddLocalizedNamesForLocale(const std::string& locale) {
947  // Nothing to do if we've previously added the localized names for the given
948  // |locale|.
949  if (locales_to_localized_names_.count(locale))
950    return;
951
952  std::map<std::string, std::string> localized_names;
953  const icu::Collator* collator = GetCollatorForLocale(locale);
954  int32_t buffer_size = 1000;
955  scoped_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
956
957  for (CountryDataMap::Iterator it = CountryDataMap::Begin();
958       it != CountryDataMap::End();
959       ++it) {
960    const std::string& country_code = it->first;
961    base::string16 country_name = l10n_util::GetDisplayNameForCountry(
962        country_code, locale);
963    std::string sort_key = GetSortKey(*collator,
964                                      country_name,
965                                      &buffer,
966                                      &buffer_size);
967
968    localized_names.insert(std::make_pair(sort_key, country_code));
969  }
970
971  locales_to_localized_names_.insert(std::make_pair(locale, localized_names));
972}
973
974const std::string CountryNames::GetCountryCodeForLocalizedName(
975    const base::string16& country_name,
976    const std::string& locale) {
977  AddLocalizedNamesForLocale(locale);
978
979  icu::Collator* collator = GetCollatorForLocale(locale);
980
981  // As recommended[1] by ICU, initialize the buffer size to four times the
982  // source string length.
983  // [1] http://userguide.icu-project.org/collation/api#TOC-Examples
984  int32_t buffer_size = country_name.size() * 4;
985  scoped_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
986  std::string sort_key = GetSortKey(*collator,
987                                    country_name,
988                                    &buffer,
989                                    &buffer_size);
990
991  const std::map<std::string, std::string>& localized_names =
992      locales_to_localized_names_[locale];
993  std::map<std::string, std::string>::const_iterator result =
994      localized_names.find(sort_key);
995
996  if (result != localized_names.end())
997    return result->second;
998
999  return std::string();
1000}
1001
1002icu::Collator* CountryNames::GetCollatorForLocale(const std::string& locale) {
1003  if (!collators_.count(locale)) {
1004    icu::Locale icu_locale(locale.c_str());
1005    UErrorCode ignored = U_ZERO_ERROR;
1006    icu::Collator* collator(icu::Collator::createInstance(icu_locale, ignored));
1007
1008    // Compare case-insensitively and ignoring punctuation.
1009    ignored = U_ZERO_ERROR;
1010    collator->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, ignored);
1011    ignored = U_ZERO_ERROR;
1012    collator->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, ignored);
1013
1014    collators_.insert(std::make_pair(locale, collator));
1015  }
1016
1017  return collators_[locale];
1018}
1019
1020const std::string CountryNames::GetSortKey(const icu::Collator& collator,
1021                                           const base::string16& str,
1022                                           scoped_ptr<uint8_t[]>* buffer,
1023                                           int32_t* buffer_size) const {
1024  DCHECK(buffer);
1025  DCHECK(buffer_size);
1026
1027  icu::UnicodeString icu_str(str.c_str(), str.length());
1028  int32_t expected_size = collator.getSortKey(icu_str, buffer->get(),
1029                                              *buffer_size);
1030  if (expected_size > *buffer_size) {
1031    // If there wasn't enough space, grow the buffer and try again.
1032    *buffer_size = expected_size;
1033    buffer->reset(new uint8_t[*buffer_size]);
1034    DCHECK(buffer->get());
1035
1036    expected_size = collator.getSortKey(icu_str, buffer->get(), *buffer_size);
1037    DCHECK_EQ(*buffer_size, expected_size);
1038  }
1039
1040  return std::string(reinterpret_cast<const char*>(buffer->get()));
1041}
1042
1043}  // namespace
1044
1045AutofillCountry::AutofillCountry(const std::string& country_code,
1046                                 const std::string& locale) {
1047  const CountryDataMap::Iterator result = CountryDataMap::Find(country_code);
1048  DCHECK(result != CountryDataMap::End());
1049  const CountryData& data = result->second;
1050
1051  country_code_ = country_code;
1052  name_ = l10n_util::GetDisplayNameForCountry(country_code, locale);
1053  postal_code_label_ = l10n_util::GetStringUTF16(data.postal_code_label_id);
1054  state_label_ = l10n_util::GetStringUTF16(data.state_label_id);
1055  address_required_fields_ = data.address_required_fields;
1056}
1057
1058AutofillCountry::~AutofillCountry() {
1059}
1060
1061// static
1062void AutofillCountry::GetAvailableCountries(
1063    std::vector<std::string>* country_codes) {
1064  DCHECK(country_codes);
1065
1066  for (CountryDataMap::Iterator it = CountryDataMap::Begin();
1067       it != CountryDataMap::End();
1068       ++it) {
1069    country_codes->push_back(it->first);
1070  }
1071}
1072
1073// static
1074const std::string AutofillCountry::CountryCodeForLocale(
1075    const std::string& locale) {
1076  // Add likely subtags to the locale. In particular, add any likely country
1077  // subtags -- e.g. for locales like "ru" that only include the language.
1078  std::string likely_locale;
1079  UErrorCode error_ignored = U_ZERO_ERROR;
1080  uloc_addLikelySubtags(locale.c_str(),
1081                        WriteInto(&likely_locale, kLocaleCapacity),
1082                        kLocaleCapacity,
1083                        &error_ignored);
1084
1085  // Extract the country code.
1086  std::string country_code = icu::Locale(likely_locale.c_str()).getCountry();
1087
1088  // Default to the United States if we have no better guess.
1089  if (CountryDataMap::Find(country_code) == CountryDataMap::End())
1090    return "US";
1091
1092  return country_code;
1093}
1094
1095// static
1096const std::string AutofillCountry::GetCountryCode(const base::string16& country,
1097                                                  const std::string& locale) {
1098  return CountryNames::GetInstance()->GetCountryCode(country, locale);
1099}
1100
1101AutofillCountry::AutofillCountry(const std::string& country_code,
1102                                 const base::string16& name,
1103                                 const base::string16& postal_code_label,
1104                                 const base::string16& state_label)
1105    : country_code_(country_code),
1106      name_(name),
1107      postal_code_label_(postal_code_label),
1108      state_label_(state_label) {
1109}
1110
1111}  // namespace autofill
1112