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

Side by Side Diff: chrome/browser/ui/webui/options2/chromeos/language_options_util2.h

Issue 10698140: Remove "2" suffixes from options2 code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 5 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
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_LANGUAGE_OPTIONS_UTIL2_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_LANGUAGE_OPTIONS_UTIL2_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/utf_string_conversions.h"
12 #include "base/values.h"
13 #include "chrome/browser/chromeos/language_preferences.h"
14 #include "ui/base/l10n/l10n_util.h"
15
16 namespace base {
17 class ListValue;
18 }
19
20 namespace chromeos {
21 namespace options2 {
22
23 // Returns an i18n-content value corresponding to |preference|.
24 template <typename T>
25 std::string GetI18nContentValue(const T& preference, const char* prefix) {
26 return std::string(prefix) + preference.ibus_config_name;
27 }
28
29 // Returns a property name of templateData corresponding to |preference|.
30 template <typename T>
31 std::string GetTemplateDataPropertyName(const T& preference,
32 const char* prefix) {
33 return std::string(prefix) + preference.ibus_config_name + "Value";
34 }
35
36 // Returns an property name of templateData corresponding the value of the min
37 // attribute.
38 template <typename T>
39 std::string GetTemplateDataMinName(const T& preference, const char* prefix) {
40 return std::string(prefix) + preference.ibus_config_name + "Min";
41 }
42
43 // Returns an property name of templateData corresponding the value of the max
44 // attribute.
45 template <typename T>
46 std::string GetTemplateDataMaxName(const T& preference, const char* prefix) {
47 return std::string(prefix) + preference.ibus_config_name + "Max";
48 }
49
50 // Creates a Value object from the given value. Here we use function
51 // overloading to handle string and integer preferences in
52 // CreateMultipleChoiceList.
53 Value* CreateValue(const char* in_value);
54 Value* CreateValue(int in_value);
55
56 // Creates a multiple choice list from the given preference.
57 template <typename T>
58 base::ListValue* CreateMultipleChoiceList(
59 const language_prefs::LanguageMultipleChoicePreference<T>& preference) {
60 int list_length = 0;
61 for (size_t i = 0;
62 i < language_prefs::LanguageMultipleChoicePreference<T>::kMaxItems;
63 ++i) {
64 if (preference.values_and_ids[i].item_message_id == 0)
65 break;
66 ++list_length;
67 }
68 DCHECK_GT(list_length, 0);
69
70 base::ListValue* list_value = new base::ListValue();
71 for (int i = 0; i < list_length; ++i) {
72 base::ListValue* option = new base::ListValue();
73 option->Append(CreateValue(
74 preference.values_and_ids[i].ibus_config_value));
75 option->Append(base::Value::CreateStringValue(l10n_util::GetStringUTF16(
76 preference.values_and_ids[i].item_message_id)));
77 list_value->Append(option);
78 }
79 return list_value;
80 }
81
82 } // namespace options2
83 } // namespace chromeos
84
85 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_LANGUAGE_OPTIONS_UTIL2_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698