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

Side by Side Diff: chrome/browser/views/options/language_combobox_model.h

Issue 113991: Make Combobox portable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_ 5 #ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_
6 #define CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_ 6 #define CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_
7 7
8 #include "chrome/browser/profile.h" 8 #include "chrome/browser/profile.h"
9 #include "views/controls/combo_box.h" 9 #include "views/controls/combobox/combobox.h"
10 10
11 /////////////////////////////////////////////////////////////////////////////// 11 ///////////////////////////////////////////////////////////////////////////////
12 // LanguageComboboxModel 12 // LanguageComboboxModel
13 // The model that fills the dropdown of valid UI languages. 13 // The model that fills the dropdown of valid UI languages.
14 class LanguageComboboxModel : public views::ComboBox::Model { 14 class LanguageComboboxModel : public views::Combobox::Model {
15 public: 15 public:
16 struct LocaleData { 16 struct LocaleData {
17 LocaleData() { } 17 LocaleData() { }
18 LocaleData(const std::wstring& name, const std::string& code) 18 LocaleData(const std::wstring& name, const std::string& code)
19 : native_name(name), locale_code(code) { } 19 : native_name(name), locale_code(code) { }
20 20
21 std::wstring native_name; 21 std::wstring native_name;
22 std::string locale_code; // E.g., en-us. 22 std::string locale_code; // E.g., en-us.
23 }; 23 };
24 typedef std::map<std::wstring, LocaleData> LocaleDataMap; 24 typedef std::map<std::wstring, LocaleData> LocaleDataMap;
25 25
26 LanguageComboboxModel(); 26 LanguageComboboxModel();
27 27
28 // Temporary compatibility constructor. 28 // Temporary compatibility constructor.
29 LanguageComboboxModel(Profile* profile, 29 LanguageComboboxModel(Profile* profile,
30 const std::vector<std::string>& locale_codes); 30 const std::vector<std::string>& locale_codes);
31 31
32 virtual ~LanguageComboboxModel() {} 32 virtual ~LanguageComboboxModel() {}
33 33
34 void InitNativeNames(const std::vector<std::string>& locale_codes); 34 void InitNativeNames(const std::vector<std::string>& locale_codes);
35 35
36 // Overridden from views::Combobox::Model: 36 // Overridden from views::Combobox::Model:
37 virtual int GetItemCount(views::ComboBox* source); 37 virtual int GetItemCount(views::Combobox* source);
38 38
39 virtual std::wstring GetItemAt(views::ComboBox* source, int index); 39 virtual std::wstring GetItemAt(views::Combobox* source, int index);
40 40
41 // Return the locale for the given index. E.g., may return pt-BR. 41 // Return the locale for the given index. E.g., may return pt-BR.
42 std::string GetLocaleFromIndex(int index); 42 std::string GetLocaleFromIndex(int index);
43 43
44 // Returns the index for the given locale. Returns -1 if the locale is not 44 // Returns the index for the given locale. Returns -1 if the locale is not
45 // in the combobox model. 45 // in the combobox model.
46 int GetIndexFromLocale(const std::string& locale); 46 int GetIndexFromLocale(const std::string& locale);
47 47
48 // Returns the index of the language currently specified in the user's 48 // Returns the index of the language currently specified in the user's
49 // preference file. Note that it's possible for language A to be picked 49 // preference file. Note that it's possible for language A to be picked
(...skipping 11 matching lines...) Expand all
61 // A map of some extra data (LocaleData) keyed off the name of the locale. 61 // A map of some extra data (LocaleData) keyed off the name of the locale.
62 LocaleDataMap native_names_; 62 LocaleDataMap native_names_;
63 63
64 // Profile. 64 // Profile.
65 Profile* profile_; 65 Profile* profile_;
66 66
67 DISALLOW_COPY_AND_ASSIGN(LanguageComboboxModel); 67 DISALLOW_COPY_AND_ASSIGN(LanguageComboboxModel);
68 }; 68 };
69 69
70 #endif // #ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_ 70 #endif // #ifndef CHROME_BROWSER_VIEWS_OPTIONS_LANGUAGE_COMBOBOX_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/views/options/general_page_view.cc ('k') | chrome/browser/views/options/language_combobox_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698