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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_LIST_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_LIST_H_
12 #include "base/basictypes.h"
13 #include "base/strings/string16.h"
17 // LanguageList is used to enumerate native names corresponding to the
18 // language code (e.g. English (United States) for en-US).
24 // Returns the number of locale names.
25 int languages_count() const { return static_cast<int>(locale_names_
.size()); }
27 // Returns the language for the given |index|.
28 base::string16
GetLanguageNameAt(int index
) const;
30 // Return the locale for the given |index|. E.g., may return pt-BR.
31 std::string
GetLocaleFromIndex(int index
) const;
33 // Returns the index for the given |locale|. Returns -1 if it's not found.
34 int GetIndexFromLocale(const std::string
& locale
) const;
36 // Duplicates specified languages at the beginning of the list for easier
38 void CopySpecifiedLanguagesUp(const std::string
& locale_codes
);
43 LocaleData(const base::string16
& name
, const std::string
& code
)
44 : native_name(name
), locale_code(code
) {}
46 base::string16 native_name
;
47 std::string locale_code
; // E.g., en-us.
50 typedef std::map
<base::string16
, LocaleData
> LocaleDataMap
;
52 void InitNativeNames(const std::vector
<std::string
>& locale_codes
);
54 // The names of all the locales in the current application locale.
55 std::vector
<base::string16
> locale_names_
;
57 // A map of some extra data (LocaleData) keyed off the name of the locale.
58 LocaleDataMap native_names_
;
60 DISALLOW_COPY_AND_ASSIGN(LanguageList
);
63 } // namespace chromeos
65 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LANGUAGE_LIST_H_