1dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// Use of this source code is governed by a BSD-style license that can be 3dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// found in the LICENSE file. 4dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 5dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "chrome/browser/autofill/autofill_country.h" 6dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 7ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include <stddef.h> 8ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include <stdint.h> 9dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include <map> 10dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include <utility> 11dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 12ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/logging.h" 13ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h" 14ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/singleton.h" 15ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/stl_util-inl.h" 16dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "base/string_util.h" 17dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "base/utf_string_conversions.h" 1848b27ac202354d545b08f8a459fe808616f12c4fKristian Monsen#ifndef ANDROID 19dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "chrome/browser/browser_process.h" 2048b27ac202354d545b08f8a459fe808616f12c4fKristian Monsen#endif 21dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "grit/generated_resources.h" 22dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "ui/base/l10n/l10n_util.h" 23dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "unicode/coll.h" 24dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "unicode/locid.h" 25dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "unicode/ucol.h" 26dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "unicode/uloc.h" 27ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "unicode/unistr.h" 28ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "unicode/urename.h" 29ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "unicode/utypes.h" 30dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 31dc0f95d653279beabeb9817299e2902918ba123eKristian Monsennamespace { 32dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 33ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenstruct CountryData { 34dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen std::string country_code; 35dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen int postal_code_label_id; 36dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen int state_label_id; 37dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen}; 38dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 39dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// The maximum capacity needed to store a locale up to the country code. 40dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenconst size_t kLocaleCapacity = 41dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY + 1; 42dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 43dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// Maps country codes to localized label string identifiers. 44ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst CountryData kCountryData[] = { 45dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AD", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PARISH}, 46dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_EMIRATE}, 47dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 48dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 49dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 50dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 51dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 52dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 53dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 54dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AQ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 55dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 56dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AS", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 57dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 58dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AU", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 59dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 60dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AX", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 61dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"AZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 62dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 63dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BB", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PARISH}, 64dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BD", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 65dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 66dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 67dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 68dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 69dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 70dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BJ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 71dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 72dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 73dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 74dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 75dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 76dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 77dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 78dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BV", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 79dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 80dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 81dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"BZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 82dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 83dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 84dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CD", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 85dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 86dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 87dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 88dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 89dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 90dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 91dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 92dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 93dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 94dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 95dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CV", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 96dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CX", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 97dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 98dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"CZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 99dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"DE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 100dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"DJ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 101dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"DK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 102dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"DM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 103dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"DO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 104dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"DZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 105dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"EC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 106dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"EE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 107dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"EG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 108dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"EH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 109dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ER", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 110dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ES", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 111dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ET", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 112dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"FI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 113dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"FJ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 114dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"FK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 115dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"FM", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 116dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"FO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 117dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"FR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 118dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 119dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GB", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_COUNTY}, 120dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GD", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 121dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 122dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 123dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 124dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 125dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 126dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 127dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 128dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 129dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GP", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 130dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GQ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 131dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 132dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 133dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 134dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GU", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 135dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 136dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"GY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 137dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"HK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_AREA}, 138dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"HM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 139dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"HN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 140dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"HR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 141dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"HT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 142dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"HU", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 143dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ID", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 144dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_COUNTY}, 145dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 146dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 147dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 148dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 149dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IQ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 150dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 151dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"IT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 152dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"JE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 153dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"JM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PARISH}, 154dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"JO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 155dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"JP", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PREFECTURE}, 156dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 157dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 158dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 159dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 160dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 161dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 162dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KP", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 163dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 164dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 165dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 166dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"KZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 167dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 168dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LB", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 169dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 170dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 171dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 172dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 173dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 174dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 175dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LU", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 176dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LV", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 177dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"LY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 178dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 179dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 180dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MD", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 181dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ME", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 182dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 183dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 184dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MH", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 185dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 186dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ML", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 187dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 188dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 189dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MP", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 190dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MQ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 191dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 192dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 193dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 194dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MU", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 195dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MV", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 196dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 197dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MX", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 198dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 199dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"MZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 200dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 201dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 202dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 203dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 204dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_STATE}, 205dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_DEPARTMENT}, 206dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 207dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 208dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NP", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 209dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_DISTRICT}, 210dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NU", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 211dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"NZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 212dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"OM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 213dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 214dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 215dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 216dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 217dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 218dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 219dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 220dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 221dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 222dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PR", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 223dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 224dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 225dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PW", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 226dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"PY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 227dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"QA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 228dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"RE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 229dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"RO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 230dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"RS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 231dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"RU", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 232dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"RW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 233dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 234dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SB", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 235dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 236dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 237dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 238dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 239dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SI", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 240dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SJ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 241dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 242dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 243dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 244dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 245dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 246dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 247dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ST", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 248dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SV", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 249dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"SZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 250dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 251dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TD", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 252dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 253dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 254dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TH", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 255dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TJ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 256dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TK", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 257dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TL", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 258dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 259dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 260dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TO", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 261dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TR", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 262dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 263dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TV", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_ISLAND}, 264dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_COUNTY}, 265dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"TZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 266dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"UA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 267dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"UG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 268dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"UM", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 269dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"US", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 270dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"UY", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 271dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"UZ", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 272dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"VA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 273dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"VC", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 274dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"VE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 275dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"VG", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 276dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"VI", IDS_AUTOFILL_DIALOG_ZIP_CODE, IDS_AUTOFILL_DIALOG_STATE}, 277dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"VN", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 278dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"VU", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 279dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"WF", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 280dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"WS", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 281dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"YE", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 282dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"YT", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 283dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ZA", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 284dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ZM", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 285dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen {"ZW", IDS_AUTOFILL_DIALOG_POSTAL_CODE, IDS_AUTOFILL_DIALOG_PROVINCE}, 286dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen}; 287dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 288dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// A singleton class that encapsulates a map from country codes to country data. 289ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass CountryDataMap { 290dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen public: 291ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // A const iterator over the wrapped map data. 292ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen typedef std::map<std::string, CountryData>::const_iterator Iterator; 293dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 294ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen static CountryDataMap* GetInstance(); 295ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen static const Iterator Begin(); 296ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen static const Iterator End(); 297ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen static const Iterator Find(const std::string& country_code); 298dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 299dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen private: 300ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen CountryDataMap(); 301ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen friend struct DefaultSingletonTraits<CountryDataMap>; 302dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 303ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::map<std::string, CountryData> country_data_; 304dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 305ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen DISALLOW_COPY_AND_ASSIGN(CountryDataMap); 306dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen}; 307dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 308dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// static 309ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenCountryDataMap* CountryDataMap::GetInstance() { 310ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return Singleton<CountryDataMap>::get(); 311dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 312dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 313ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenCountryDataMap::CountryDataMap() { 314dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // Add all the countries we have explicit data for. 315dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen for (size_t i = 0; i < arraysize(kCountryData); ++i) { 316ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const CountryData& data = kCountryData[i]; 317ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen country_data_.insert(std::make_pair(data.country_code, data)); 318dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen } 319dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 320dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // Add any other countries that ICU knows about, falling back to default data 321dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // values. 322ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen for (const char* const* country_pointer = icu::Locale::getISOCountries(); 323dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen *country_pointer; 324dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen ++country_pointer) { 325dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen std::string country_code = *country_pointer; 326ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (!country_data_.count(country_code)) { 327ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen CountryData data = { 328dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen country_code, 329dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen IDS_AUTOFILL_DIALOG_POSTAL_CODE, 330dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen IDS_AUTOFILL_DIALOG_PROVINCE 331dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen }; 332ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen country_data_.insert(std::make_pair(country_code, data)); 333dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen } 334dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen } 335dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 336dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 337ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst CountryDataMap::Iterator CountryDataMap::Begin() { 338ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return GetInstance()->country_data_.begin(); 339ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 340ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 341ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst CountryDataMap::Iterator CountryDataMap::End() { 342ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return GetInstance()->country_data_.end(); 343ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 344ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 345ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst CountryDataMap::Iterator CountryDataMap::Find( 346ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& country_code) { 347ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return GetInstance()->country_data_.find(country_code); 348ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 349ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 350ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// A singleton class that encapsulates mappings from country names to their 351ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// corresponding country codes. 352ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass CountryNames { 353ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen public: 354ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen static CountryNames* GetInstance(); 355ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 356ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Returns the country code corresponding to |country|, which should be a 357ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // country code or country name localized to |locale|. 358ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string GetCountryCode(const string16& country, 359ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& locale); 360ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 361ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen private: 362ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen CountryNames(); 363ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen ~CountryNames(); 364ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen friend struct DefaultSingletonTraits<CountryNames>; 365ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 366ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Populates |locales_to_localized_names_| with the mapping of country names 367ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // localized to |locale| to their corresponding country codes. 368ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen void AddLocalizedNamesForLocale(const std::string& locale); 369ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 370ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Interprets |country_name| as a full country name localized to the given 371ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // |locale| and returns the corresponding country code stored in 372ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // |locales_to_localized_names_|, or an empty string if there is none. 373ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string GetCountryCodeForLocalizedName(const string16& country_name, 374ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& locale); 375ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 376ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Returns an ICU collator -- i.e. string comparator -- appropriate for the 377ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // given |locale|. 378ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::Collator* GetCollatorForLocale(const std::string& locale); 379ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 380ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Returns the ICU sort key corresponding to |str| for the given |collator|. 381ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Uses |buffer| as temporary storage, and might resize |buffer| as a side- 382ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // effect. |buffer_size| should specify the |buffer|'s size, and is updated if 383ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // the |buffer| is resized. 384ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string GetSortKey(const icu::Collator& collator, 385ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const icu::UnicodeString& str, 386ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen scoped_array<uint8_t>* buffer, 387ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen int32_t* buffer_size) const; 388ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 389ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 390ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Maps from common country names, including 2- and 3-letter country codes, 391ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // to the corresponding 2-letter country codes. The keys are uppercase ASCII 392ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // strings. 393ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::map<std::string, std::string> common_names_; 394ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 395ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // The outer map keys are ICU locale identifiers. 396ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // The inner maps map from localized country names to their corresponding 397ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // country codes. The inner map keys are ICU collation sort keys corresponding 398ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // to the target localized country name. 399ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::map<std::string, std::map<std::string, std::string> > 400ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen locales_to_localized_names_; 401ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 402ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Maps ICU locale names to their corresponding collators. 403ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::map<std::string, icu::Collator*> collators_; 404ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 405ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen DISALLOW_COPY_AND_ASSIGN(CountryNames); 406ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}; 407ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 408ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// static 409ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenCountryNames* CountryNames::GetInstance() { 410ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return Singleton<CountryNames>::get(); 411ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 412ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 413ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenCountryNames::CountryNames() { 414ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Add 2- and 3-letter ISO country codes. 415ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen for (CountryDataMap::Iterator it = CountryDataMap::Begin(); 416ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen it != CountryDataMap::End(); 417ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen ++it) { 418ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& country_code = it->first; 419ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::string iso3_country_code = 420ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::Locale(NULL, country_code.c_str()).getISO3Country(); 421ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 422ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.insert(std::make_pair(country_code, country_code)); 423ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.insert(std::make_pair(iso3_country_code, country_code)); 424ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen } 425ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 426ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Add a few other common synonyms. 427ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.insert(std::make_pair("UNITED STATES OF AMERICA", "US")); 428ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.insert(std::make_pair("GREAT BRITAIN", "GB")); 429ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.insert(std::make_pair("UK", "GB")); 430ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.insert(std::make_pair("BRASIL", "BR")); 431ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.insert(std::make_pair("DEUTSCHLAND", "DE")); 432ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 433ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 434ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenCountryNames::~CountryNames() { 435ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen STLDeleteContainerPairSecondPointers(collators_.begin(), 436ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen collators_.end()); 437ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 438ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 439ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst std::string CountryNames::GetCountryCode(const string16& country, 440ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& locale) { 441ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // First, check common country names, including 2- and 3-letter country codes. 442ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::string country_utf8 = UTF16ToUTF8(StringToUpperASCII(country)); 443ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::map<std::string, std::string>::const_iterator result = 444ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen common_names_.find(country_utf8); 445ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (result != common_names_.end()) 446ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return result->second; 447ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 448ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Next, check country names localized to |locale|. 449ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::string country_code = GetCountryCodeForLocalizedName(country, locale); 450ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (!country_code.empty()) 451ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return country_code; 452ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 453ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Finally, check country names localized to US English. 454ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return GetCountryCodeForLocalizedName(country, "en_US"); 455ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 456ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 457ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenvoid CountryNames::AddLocalizedNamesForLocale(const std::string& locale) { 458ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Nothing to do if we've previously added the localized names for the given 459ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // |locale|. 460ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (locales_to_localized_names_.count(locale)) 461ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return; 462ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 463ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::map<std::string, std::string> localized_names; 464ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 465ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::Locale icu_locale(locale.c_str()); 466ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const icu::Collator* collator = GetCollatorForLocale(locale); 467ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 468ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen int32_t buffer_size = 1000; 469ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen scoped_array<uint8_t> buffer(new uint8_t[buffer_size]); 470ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 471ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen for (CountryDataMap::Iterator it = CountryDataMap::Begin(); 472ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen it != CountryDataMap::End(); 473ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen ++it) { 474ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& country_code = it->first; 475ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 476ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::Locale country_locale(NULL, country_code.c_str()); 477ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::UnicodeString country_name; 478ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen country_locale.getDisplayName(icu_locale, country_name); 479ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::string sort_key = GetSortKey(*collator, 480ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen country_name, 481ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen &buffer, 482ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen &buffer_size); 483ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 484ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen localized_names.insert(std::make_pair(sort_key, country_code)); 485ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen } 486ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 487ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen locales_to_localized_names_.insert(std::make_pair(locale, localized_names)); 488ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 489ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 490ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst std::string CountryNames::GetCountryCodeForLocalizedName( 491ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const string16& country_name, 492ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& locale) { 493ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen AddLocalizedNamesForLocale(locale); 494ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 495ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::Collator* collator = GetCollatorForLocale(locale); 496ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 497ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // As recommended[1] by ICU, initialize the buffer size to four times the 498ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // source string length. 499ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // [1] http://userguide.icu-project.org/collation/api#TOC-Examples 500ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen int32_t buffer_size = country_name.size() * 4; 501ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen scoped_array<uint8_t> buffer(new uint8_t[buffer_size]); 502ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::string sort_key = GetSortKey(*collator, 503ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen country_name.c_str(), 504ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen &buffer, 505ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen &buffer_size); 506ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 507ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::map<std::string, std::string>& localized_names = 508ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen locales_to_localized_names_[locale]; 509ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen std::map<std::string, std::string>::const_iterator result = 510ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen localized_names.find(sort_key); 511ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 512ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (result != localized_names.end()) 513ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return result->second; 514ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 515ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return std::string(); 516ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 517ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 518ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenicu::Collator* CountryNames::GetCollatorForLocale(const std::string& locale) { 519ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (!collators_.count(locale)) { 520ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::Locale icu_locale(locale.c_str()); 521ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen UErrorCode ignored = U_ZERO_ERROR; 522ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen icu::Collator* collator(icu::Collator::createInstance(icu_locale, ignored)); 523ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 524ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Compare case-insensitively and ignoring punctuation. 525ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen ignored = U_ZERO_ERROR; 526ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen collator->setAttribute(UCOL_STRENGTH, UCOL_SECONDARY, ignored); 527ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen ignored = U_ZERO_ERROR; 528ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen collator->setAttribute(UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, ignored); 529ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 530ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen collators_.insert(std::make_pair(locale, collator)); 531ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen } 532ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 533ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return collators_[locale]; 534ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 535ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 536ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst std::string CountryNames::GetSortKey(const icu::Collator& collator, 537ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const icu::UnicodeString& str, 538ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen scoped_array<uint8_t>* buffer, 539ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen int32_t* buffer_size) const { 540ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen DCHECK(buffer); 541ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen DCHECK(buffer_size); 542ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 543ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen int32_t expected_size = collator.getSortKey(str, buffer->get(), *buffer_size); 544ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (expected_size > *buffer_size) { 545ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // If there wasn't enough space, grow the buffer and try again. 546ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen *buffer_size = expected_size; 547ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen buffer->reset(new uint8_t[*buffer_size]); 548ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen DCHECK(buffer->get()); 549ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 550ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen expected_size = collator.getSortKey(str, buffer->get(), *buffer_size); 551ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen DCHECK_EQ(*buffer_size, expected_size); 552ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen } 553ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 554ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return std::string(reinterpret_cast<const char*>(buffer->get())); 555dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 556dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 557dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// Returns the country name corresponding to |country_code|, localized to the 558dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// |display_locale|. 559dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenstring16 GetDisplayName(const std::string& country_code, 560dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen const icu::Locale& display_locale) { 561dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen icu::Locale country_locale(NULL, country_code.c_str()); 562dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen icu::UnicodeString name; 563dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen country_locale.getDisplayName(display_locale, name); 564dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 565dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen DCHECK_GT(name.length(), 0); 566dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen return string16(name.getBuffer(), name.length()); 567dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 568dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 569dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} // namespace 570dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 571dc0f95d653279beabeb9817299e2902918ba123eKristian MonsenAutofillCountry::AutofillCountry(const std::string& country_code, 572dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen const std::string& locale) { 573ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const CountryDataMap::Iterator result = CountryDataMap::Find(country_code); 574ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen DCHECK(result != CountryDataMap::End()); 575ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const CountryData& data = result->second; 576dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 577dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen country_code_ = country_code; 578dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen name_ = GetDisplayName(country_code, icu::Locale(locale.c_str())); 579dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen postal_code_label_ = l10n_util::GetStringUTF16(data.postal_code_label_id); 580dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen state_label_ = l10n_util::GetStringUTF16(data.state_label_id); 581dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 582dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 583dc0f95d653279beabeb9817299e2902918ba123eKristian MonsenAutofillCountry::~AutofillCountry() { 584dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 585dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 586dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// static 587dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenvoid AutofillCountry::GetAvailableCountries( 588dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen std::vector<std::string>* country_codes) { 589dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen DCHECK(country_codes); 590dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 591ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen for (CountryDataMap::Iterator it = CountryDataMap::Begin(); 592ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen it != CountryDataMap::End(); 593dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen ++it) { 594dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen country_codes->push_back(it->first); 595dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen } 596dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 597dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 598dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// static 599dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenconst std::string AutofillCountry::CountryCodeForLocale( 600dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen const std::string& locale) { 601dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // Add likely subtags to the locale. In particular, add any likely country 602dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // subtags -- e.g. for locales like "ru" that only include the language. 603dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen std::string likely_locale; 604dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen UErrorCode error_ignored = U_ZERO_ERROR; 605dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen uloc_addLikelySubtags(locale.c_str(), 606dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen WriteInto(&likely_locale, kLocaleCapacity), 607dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen kLocaleCapacity, 608dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen &error_ignored); 609dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 610dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // Extract the country code. 611dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen std::string country_code = icu::Locale(likely_locale.c_str()).getCountry(); 612dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 613ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // TODO(isherman): Return an empty string and update the clients instead. 614dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen // Default to the United States if we have no better guess. 615ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen if (CountryDataMap::Find(country_code) == CountryDataMap::End()) 616dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen return "US"; 617dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 618ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return country_code; 619ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen} 620dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 621ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// static 622ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenconst std::string AutofillCountry::GetCountryCode(const string16& country, 623ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& locale) { 624ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return CountryNames::GetInstance()->GetCountryCode(country, locale); 625dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 626dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 627dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen// static 628dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenconst std::string AutofillCountry::ApplicationLocale() { 62948b27ac202354d545b08f8a459fe808616f12c4fKristian Monsen#ifdef ANDROID 63074b084c38a376b8c8ee24cadcc3e65bfb4b47160Ben Murdoch return l10n_util::GetApplicationLocale(); 63148b27ac202354d545b08f8a459fe808616f12c4fKristian Monsen#else 632dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen return g_browser_process->GetApplicationLocale(); 63348b27ac202354d545b08f8a459fe808616f12c4fKristian Monsen#endif 634dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 635dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 636dc0f95d653279beabeb9817299e2902918ba123eKristian MonsenAutofillCountry::AutofillCountry(const std::string& country_code, 637dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen const string16& name, 638dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen const string16& postal_code_label, 639dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen const string16& state_label) 640dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen : country_code_(country_code), 641dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen name_(name), 642dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen postal_code_label_(postal_code_label), 643dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen state_label_(state_label) { 644dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen} 645