| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/combobox_model.h" | 9 #include "app/combobox_model.h" |
| 10 #include "base/string16.h" |
| 10 #include "chrome/browser/chromeos/language_preferences.h" | 11 #include "chrome/browser/chromeos/language_preferences.h" |
| 11 #include "views/controls/combobox/combobox.h" | 12 #include "views/controls/combobox/combobox.h" |
| 12 | 13 |
| 13 namespace chromeos { | 14 namespace chromeos { |
| 14 | 15 |
| 15 // The combobox model for Language input method prefs. | 16 // The combobox model for Language input method prefs. |
| 16 template <typename DataType> | 17 template <typename DataType> |
| 17 class LanguageComboboxModel : public ComboboxModel { | 18 class LanguageComboboxModel : public ComboboxModel { |
| 18 public: | 19 public: |
| 19 explicit LanguageComboboxModel( | 20 explicit LanguageComboboxModel( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 ++num_items_; | 32 ++num_items_; |
| 32 } | 33 } |
| 33 } | 34 } |
| 34 | 35 |
| 35 // Implements ComboboxModel interface. | 36 // Implements ComboboxModel interface. |
| 36 virtual int GetItemCount() { | 37 virtual int GetItemCount() { |
| 37 return num_items_; | 38 return num_items_; |
| 38 } | 39 } |
| 39 | 40 |
| 40 // Implements ComboboxModel interface. | 41 // Implements ComboboxModel interface. |
| 41 virtual std::wstring GetItemAt(int index) { | 42 virtual string16 GetItemAt(int index) { |
| 42 if (index < 0 || index >= num_items_) { | 43 if (index < 0 || index >= num_items_) { |
| 43 LOG(ERROR) << "Index is out of bounds: " << index; | 44 LOG(ERROR) << "Index is out of bounds: " << index; |
| 44 return L""; | 45 return string16(); |
| 45 } | 46 } |
| 46 const int message_id = (pref_data_->values_and_ids)[index].item_message_id; | 47 const int message_id = (pref_data_->values_and_ids)[index].item_message_id; |
| 47 return l10n_util::GetString(message_id); | 48 return l10n_util::GetStringUTF16(message_id); |
| 48 } | 49 } |
| 49 | 50 |
| 50 // Gets a label for the combobox like "Input mode". This function is NOT part | 51 // Gets a label for the combobox like "Input mode". This function is NOT part |
| 51 // of the ComboboxModel interface. | 52 // of the ComboboxModel interface. |
| 52 std::wstring GetLabel() const { | 53 std::wstring GetLabel() const { |
| 53 return l10n_util::GetString(pref_data_->label_message_id); | 54 return l10n_util::GetString(pref_data_->label_message_id); |
| 54 } | 55 } |
| 55 | 56 |
| 56 // Gets a config value for the ibus configuration daemon (e.g. "KUTEN_TOUTEN", | 57 // Gets a config value for the ibus configuration daemon (e.g. "KUTEN_TOUTEN", |
| 57 // "KUTEN_PERIOD", ..) for an item at zero-origin |index|. This function is | 58 // "KUTEN_PERIOD", ..) for an item at zero-origin |index|. This function is |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 private: | 93 private: |
| 93 static const int kMinComboboxWidth = 250; | 94 static const int kMinComboboxWidth = 250; |
| 94 | 95 |
| 95 DISALLOW_COPY_AND_ASSIGN(LanguageCombobox); | 96 DISALLOW_COPY_AND_ASSIGN(LanguageCombobox); |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 } // namespace chromeos | 99 } // namespace chromeos |
| 99 | 100 |
| 100 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ | 101 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ |
| OLD | NEW |