Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1871)

Unified Diff: chrome/browser/autofill/autofill_country.cc

Issue 6484022: Autofill i18n: Set postal code and state field labels based on the selected country. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: I see you, ICU Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/autofill_country.cc
diff --git a/chrome/browser/autofill/autofill_country.cc b/chrome/browser/autofill/autofill_country.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ab69baf67a8f4d5d31e6fa1499416568d7e0ff67
--- /dev/null
+++ b/chrome/browser/autofill/autofill_country.cc
@@ -0,0 +1,1335 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/autofill/autofill_country.h"
+
+#include <map>
+#include <utility>
+
+#include "base/logging.h"
+#include "base/singleton.h"
+#include "base/utf_string_conversions.h"
James Hawkins 2011/02/12 20:32:45 Is this header used?
Ilya Sherman 2011/02/16 10:27:18 It was, then it wasn't, and now it is again. Well
+#include "chrome/browser/browser_process.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "third_party/icu/public/common/unicode/locid.h"
James Hawkins 2011/02/12 20:32:45 't' before 'u'.
Ilya Sherman 2011/02/16 10:27:18 Done.
+
+namespace {
+
+struct AutoFillCountryData {
+ std::string country_code;
+ int postal_code_label_id;
+ int state_label_id;
+};
+
+const AutoFillCountryData kCountryData[] = {
+ {
+ "AD",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PARISH
+ },
+ {
+ "AE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_EMIRATE
+ },
+ {
+ "AF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AQ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "AS",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "AT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AU",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "AW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AX",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "AZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BB",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PARISH
+ },
+ {
+ "BD",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BJ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "BS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "BT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BV",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "BZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CD",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "CM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CV",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "CX",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "CZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "DE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "DJ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "DK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "DM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "DO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "DZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "EC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "EE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "EG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "EH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ER",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ES",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ET",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "FI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "FJ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "FK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "FM",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "FO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "FR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GB",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_COUNTY
+ },
+ {
+ "GD",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GP",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GQ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GU",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "GW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "GY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "HK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_AREA
+ },
+ {
+ "HM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "HN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "HR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "HT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "HU",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ID",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "IE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_COUNTY
+ },
+ {
+ "IL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "IM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "IN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "IO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "IQ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "IS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "IT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "JE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "JM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PARISH
+ },
+ {
+ "JO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "JP",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PREFECTURE
+ },
+ {
+ "KE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "KG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "KH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "KI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "KM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "KN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "KP",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "KR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "KW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "KY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "KZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LB",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LU",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LV",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "LY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MD",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ME",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MH",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "MK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ML",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MP",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "MQ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MU",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MV",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "MX",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "MY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "MZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "NI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_DEPARTMENT
+ },
+ {
+ "NL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NP",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_DISTRICT
+ },
+ {
+ "NU",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "NZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "OM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "PG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PR",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "PW",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "PY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "QA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "RE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "RO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "RS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "RU",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "RW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SB",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "SE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SI",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SJ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ST",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SV",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "SZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TD",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TH",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TJ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TK",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TL",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TO",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TR",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "TV",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_ISLAND
+ },
+ {
+ "TW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_COUNTY
+ },
+ {
+ "TZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "UA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "UG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "UM",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "US",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "UY",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "UZ",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "VA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "VC",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "VE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "VG",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "VI",
+ IDS_AUTOFILL_DIALOG_ZIP_CODE,
+ IDS_AUTOFILL_DIALOG_STATE
+ },
+ {
+ "VN",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "VU",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "WF",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "WS",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "YE",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "YT",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ZA",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ZM",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+ {
+ "ZW",
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ },
+};
+
+// A singleton class that encapsulates a map from country codes to country data.
+class AutoFillCountries {
+ public:
+ typedef std::map<std::string, AutoFillCountryData> MapType;
James Hawkins 2011/02/12 20:32:45 Document this type.
Ilya Sherman 2011/02/16 10:27:18 Done, though not sure how much value-add the comme
+
+ static AutoFillCountries* GetInstance();
+ static const MapType& countries();
+
+ private:
+ AutoFillCountries();
+ friend struct DefaultSingletonTraits<AutoFillCountries>;
James Hawkins 2011/02/12 20:32:45 friend declarations should be first in the section
Ilya Sherman 2011/02/16 10:27:18 That doesn't seem to be the style used elsewhere -
+
+ MapType countries_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutoFillCountries);
+};
+
+// static
+AutoFillCountries* AutoFillCountries::GetInstance() {
+ return Singleton<AutoFillCountries>::get();
+}
+
+AutoFillCountries::AutoFillCountries() {
+ // Add all the countries we have explicit data for.
+ for (size_t i = 0; i < arraysize(kCountryData); ++i) {
+ const AutoFillCountryData& data = kCountryData[i];
+ countries_.insert(std::make_pair(data.country_code, data));
+ }
+
+ // Add any other countries that ICU knows about, falling back to default data
+ // values.
+ for (const char* const* country_pointer = Locale::getISOCountries();
+ *country_pointer;
+ ++country_pointer) {
+ std::string country_code = *country_pointer;
+ if (!countries_.count(country_code)) {
+ AutoFillCountryData data = {
+ country_code,
+ IDS_AUTOFILL_DIALOG_POSTAL_CODE,
+ IDS_AUTOFILL_DIALOG_PROVINCE
+ };
+ countries_.insert(std::make_pair(country_code, data));
+ }
+ }
+}
+
+const AutoFillCountries::MapType& AutoFillCountries::countries() {
+ return GetInstance()->countries_;
+}
+
+} // namespace
+
+// static
+AutoFillCountry AutoFillCountry::CountryForCountryCode(
+ const std::string& country_code) {
+ const AutoFillCountries::MapType& countries = AutoFillCountries::countries();
+ DCHECK(countries.count(country_code));
+ const AutoFillCountryData& data = countries.find(country_code)->second;
+
+ // Get the localized country name appropriate for the app locale.
+ icu::Locale country_locale(NULL, country_code.c_str());
+ icu::Locale app_locale(g_browser_process->GetApplicationLocale().c_str());
+ icu::UnicodeString icu_name;
+ country_locale.getDisplayName(app_locale, icu_name);
+ DCHECK_GT(icu_name.length(), 0);
+
+ string16 name(icu_name.getBuffer(), icu_name.length());
+ return AutoFillCountry(country_code,
+ name,
+ l10n_util::GetStringUTF16(data.postal_code_label_id),
+ l10n_util::GetStringUTF16(data.state_label_id));
+}
+
+// static
+AutoFillCountry AutoFillCountry::CountryForLocale(const std::string& locale) {
+ std::string country_code = icu::Locale(locale.c_str()).getCountry();
+ return CountryForCountryCode(country_code);
+}
+
+// static
+void AutoFillCountry::GetAvailableCountries(
+ std::vector<AutoFillCountry>* countries) {
+ DCHECK(countries);
+
+ const AutoFillCountries::MapType& country_data =
+ AutoFillCountries::countries();
+ for (AutoFillCountries::MapType::const_iterator it = country_data.begin();
+ it != country_data.end();
+ ++it) {
+ countries->push_back(CountryForCountryCode(it->first));
+ }
+}
+
+AutoFillCountry::AutoFillCountry(const std::string& country_code,
+ const string16& name,
+ const string16& postal_code_label,
+ const string16& state_label)
+ : country_code_(country_code),
+ name_(name),
+ postal_code_label_(postal_code_label),
+ state_label_(state_label) {
+}

Powered by Google App Engine
This is Rietveld 408576698