Home | History | Annotate | Download | only in autofill
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_COUNTRY_H_
      6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_COUNTRY_H_
      7 #pragma once
      8 
      9 #include <string>
     10 #include <vector>
     11 
     12 #include "base/basictypes.h"
     13 #include "base/string16.h"
     14 
     15 // Stores data associated with a country. Strings are localized to the app
     16 // locale.
     17 class AutofillCountry {
     18  public:
     19   // Returns country data corresponding to the two-letter ISO code
     20   // |country_code|.
     21   AutofillCountry(const std::string& country_code, const std::string& locale);
     22   ~AutofillCountry();
     23 
     24   // Fills |country_codes| with a list of the available countries' codes.
     25   static void GetAvailableCountries(
     26       std::vector<std::string>* country_codes);
     27 
     28   // Returns the likely country code for |locale|, or "US" as a fallback if no
     29   // mapping from the locale is available.
     30   static const std::string CountryCodeForLocale(const std::string& locale);
     31 
     32   // Returns the country code corresponding to |country|, which should be a
     33   // country code or country name localized to |locale|.  This function can
     34   // be expensive so use judiciously.
     35   static const std::string GetCountryCode(const string16& country,
     36                                           const std::string& locale);
     37 
     38   // Returns the application locale.
     39   static const std::string ApplicationLocale();
     40 
     41   const std::string country_code() const { return country_code_; }
     42   const string16 name() const { return name_; }
     43   const string16 postal_code_label() const { return postal_code_label_; }
     44   const string16 state_label() const { return state_label_; }
     45 
     46  private:
     47   AutofillCountry(const std::string& country_code,
     48                   const string16& name,
     49                   const string16& postal_code_label,
     50                   const string16& state_label);
     51 
     52   // The two-letter ISO-3166 country code.
     53   std::string country_code_;
     54 
     55   // The country's name, localized to the app locale.
     56   string16 name_;
     57 
     58   // The localized label for the postal code (or zip code) field.
     59   string16 postal_code_label_;
     60 
     61   // The localized label for the state (or province, district, etc.) field.
     62   string16 state_label_;
     63 
     64   DISALLOW_COPY_AND_ASSIGN(AutofillCountry);
     65 };
     66 
     67 #endif  // CHROME_BROWSER_AUTOFILL_AUTOFILL_COUNTRY_H_
     68