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_DOM_UI_LANGUAGE_OPTIONS_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DOM_UI_LANGUAGE_OPTIONS_UTIL_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DOM_UI_LANGUAGE_OPTIONS_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DOM_UI_LANGUAGE_OPTIONS_UTIL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 return Value::CreateIntegerValue(in_value); | 55 return Value::CreateIntegerValue(in_value); |
56 } | 56 } |
57 | 57 |
58 } // namespace | 58 } // namespace |
59 | 59 |
60 namespace chromeos { | 60 namespace chromeos { |
61 | 61 |
62 // Creates a multiple choice list from the given preference. | 62 // Creates a multiple choice list from the given preference. |
63 template <typename T> | 63 template <typename T> |
64 ListValue* CreateMultipleChoiceList( | 64 ListValue* CreateMultipleChoiceList( |
65 const LanguageMultipleChoicePreference<T>& preference) { | 65 const language_prefs::LanguageMultipleChoicePreference<T>& preference) { |
66 int list_length = 0; | 66 int list_length = 0; |
67 for (size_t i = 0; | 67 for (size_t i = 0; |
68 i < LanguageMultipleChoicePreference<T>::kMaxItems; | 68 i < language_prefs::LanguageMultipleChoicePreference<T>::kMaxItems; |
69 ++i) { | 69 ++i) { |
70 if (preference.values_and_ids[i].item_message_id == 0) | 70 if (preference.values_and_ids[i].item_message_id == 0) |
71 break; | 71 break; |
72 ++list_length; | 72 ++list_length; |
73 } | 73 } |
74 DCHECK_GT(list_length, 0); | 74 DCHECK_GT(list_length, 0); |
75 | 75 |
76 ListValue* list_value = new ListValue(); | 76 ListValue* list_value = new ListValue(); |
77 for (int i = 0; i < list_length; ++i) { | 77 for (int i = 0; i < list_length; ++i) { |
78 ListValue* option = new ListValue(); | 78 ListValue* option = new ListValue(); |
79 option->Append(CreateValue( | 79 option->Append(CreateValue( |
80 preference.values_and_ids[i].ibus_config_value)); | 80 preference.values_and_ids[i].ibus_config_value)); |
81 option->Append(Value::CreateStringValue(l10n_util::GetStringUTF16( | 81 option->Append(Value::CreateStringValue(l10n_util::GetStringUTF16( |
82 preference.values_and_ids[i].item_message_id))); | 82 preference.values_and_ids[i].item_message_id))); |
83 list_value->Append(option); | 83 list_value->Append(option); |
84 } | 84 } |
85 return list_value; | 85 return list_value; |
86 } | 86 } |
87 | 87 |
88 } // namespace chromeos | 88 } // namespace chromeos |
89 | 89 |
90 #endif // CHROME_BROWSER_CHROMEOS_DOM_UI_LANGUAGE_OPTIONS_UTIL_H_ | 90 #endif // CHROME_BROWSER_CHROMEOS_DOM_UI_LANGUAGE_OPTIONS_UTIL_H_ |
OLD | NEW |