diff options
author | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 18:18:59 +0000 |
---|---|---|
committer | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 18:18:59 +0000 |
commit | 627edeba9f3069b36309c30fa526459a191c9731 (patch) | |
tree | ff30534f2abe0a983594ac6e8f86f6a1375e6c2e /chrome/browser/language_combobox_model.h | |
parent | ccd2bd7df05b22b1a081b3ae86b351e5bf7ba837 (diff) | |
download | chromium_src-627edeba9f3069b36309c30fa526459a191c9731.zip chromium_src-627edeba9f3069b36309c30fa526459a191c9731.tar.gz chromium_src-627edeba9f3069b36309c30fa526459a191c9731.tar.bz2 |
Separated basic language-list code from the combobox model
implementation. This is because we needed a menu (not combobox) with
languages in another part of Chromium (CL 661475).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/668068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/language_combobox_model.h')
-rw-r--r-- | chrome/browser/language_combobox_model.h | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/chrome/browser/language_combobox_model.h b/chrome/browser/language_combobox_model.h index 98f74a0..8a58d0e 100644 --- a/chrome/browser/language_combobox_model.h +++ b/chrome/browser/language_combobox_model.h @@ -13,9 +13,10 @@ #include "chrome/browser/profile.h" /////////////////////////////////////////////////////////////////////////////// -// LanguageComboboxModel -// The model that fills the dropdown of valid UI languages. -class LanguageComboboxModel : public ComboboxModel { +// LanguageList +// Provides code to enumerate locale names for language selection lists. +// To be used by combobox, menu or other models. +class LanguageList { public: struct LocaleData { LocaleData() { } @@ -27,27 +28,51 @@ class LanguageComboboxModel : public ComboboxModel { }; typedef std::map<std::wstring, LocaleData> LocaleDataMap; - LanguageComboboxModel(); - - // Temporary compatibility constructor. - LanguageComboboxModel(Profile* profile, - const std::vector<std::string>& locale_codes); + LanguageList(); - virtual ~LanguageComboboxModel() {} + explicit LanguageList(const std::vector<std::string>& locale_codes); - void InitNativeNames(const std::vector<std::string>& locale_codes); + virtual ~LanguageList() {} - // Overridden from ComboboxModel: - virtual int GetItemCount(); + virtual int get_languages_count() const; - virtual std::wstring GetItemAt(int index); + virtual std::wstring GetLanguageNameAt(int index) const; // Return the locale for the given index. E.g., may return pt-BR. - std::string GetLocaleFromIndex(int index); + std::string GetLocaleFromIndex(int index) const; // Returns the index for the given locale. Returns -1 if the locale is not // in the combobox model. - int GetIndexFromLocale(const std::string& locale); + int GetIndexFromLocale(const std::string& locale) const; + + private: + // The names of all the locales in the current application locale. + std::vector<std::wstring> locale_names_; + + // A map of some extra data (LocaleData) keyed off the name of the locale. + LocaleDataMap native_names_; + + void InitNativeNames(const std::vector<std::string>& locale_codes); + + DISALLOW_COPY_AND_ASSIGN(LanguageList); +}; + +/////////////////////////////////////////////////////////////////////////////// +// LanguageComboboxModel +// The combobox model implementation. +class LanguageComboboxModel : public LanguageList, public ComboboxModel { + public: + LanguageComboboxModel(); + + // Temporary compatibility constructor. + LanguageComboboxModel(Profile* profile, + const std::vector<std::string>& locale_codes); + + virtual ~LanguageComboboxModel() {} + + virtual int GetItemCount() { return get_languages_count(); } + + virtual std::wstring GetItemAt(int index) { return GetLanguageNameAt(index); } // Returns the index of the language currently specified in the user's // preference file. Note that it's possible for language A to be picked @@ -59,12 +84,6 @@ class LanguageComboboxModel : public ComboboxModel { int GetSelectedLanguageIndex(const std::wstring& prefs); private: - // The names of all the locales in the current application locale. - std::vector<std::wstring> locale_names_; - - // A map of some extra data (LocaleData) keyed off the name of the locale. - LocaleDataMap native_names_; - // Profile. Profile* profile_; |