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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/language_options_util.h

Issue 7259019: Move base/values.h into the base namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_UI_WEBUI_OPTIONS_CHROMEOS_LANGUAGE_OPTIONS_UTIL_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_LANGUAGE_OPTIONS_UTIL_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_LANGUAGE_OPTIONS_UTIL_H_ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_LANGUAGE_OPTIONS_UTIL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/chromeos/language_preferences.h" 13 #include "chrome/browser/chromeos/language_preferences.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 15
16 namespace base {
16 class ListValue; 17 class ListValue;
18 }
17 19
18 namespace chromeos { 20 namespace chromeos {
19 21
20 // Returns an i18n-content value corresponding to |preference|. 22 // Returns an i18n-content value corresponding to |preference|.
21 template <typename T> 23 template <typename T>
22 std::string GetI18nContentValue(const T& preference, const char* prefix) { 24 std::string GetI18nContentValue(const T& preference, const char* prefix) {
23 return std::string(prefix) + preference.ibus_config_name; 25 return std::string(prefix) + preference.ibus_config_name;
24 } 26 }
25 27
26 // Returns a property name of templateData corresponding to |preference|. 28 // Returns a property name of templateData corresponding to |preference|.
(...skipping 18 matching lines...) Expand all
45 } 47 }
46 48
47 // Creates a Value object from the given value. Here we use function 49 // Creates a Value object from the given value. Here we use function
48 // overloading to handle string and integer preferences in 50 // overloading to handle string and integer preferences in
49 // CreateMultipleChoiceList. 51 // CreateMultipleChoiceList.
50 Value* CreateValue(const char* in_value); 52 Value* CreateValue(const char* in_value);
51 Value* CreateValue(int in_value); 53 Value* CreateValue(int in_value);
52 54
53 // Creates a multiple choice list from the given preference. 55 // Creates a multiple choice list from the given preference.
54 template <typename T> 56 template <typename T>
55 ListValue* CreateMultipleChoiceList( 57 base::ListValue* CreateMultipleChoiceList(
56 const language_prefs::LanguageMultipleChoicePreference<T>& preference) { 58 const language_prefs::LanguageMultipleChoicePreference<T>& preference) {
57 int list_length = 0; 59 int list_length = 0;
58 for (size_t i = 0; 60 for (size_t i = 0;
59 i < language_prefs::LanguageMultipleChoicePreference<T>::kMaxItems; 61 i < language_prefs::LanguageMultipleChoicePreference<T>::kMaxItems;
60 ++i) { 62 ++i) {
61 if (preference.values_and_ids[i].item_message_id == 0) 63 if (preference.values_and_ids[i].item_message_id == 0)
62 break; 64 break;
63 ++list_length; 65 ++list_length;
64 } 66 }
65 DCHECK_GT(list_length, 0); 67 DCHECK_GT(list_length, 0);
66 68
67 ListValue* list_value = new ListValue(); 69 base::ListValue* list_value = new base::ListValue();
68 for (int i = 0; i < list_length; ++i) { 70 for (int i = 0; i < list_length; ++i) {
69 ListValue* option = new ListValue(); 71 base::ListValue* option = new base::ListValue();
70 option->Append(CreateValue( 72 option->Append(CreateValue(
71 preference.values_and_ids[i].ibus_config_value)); 73 preference.values_and_ids[i].ibus_config_value));
72 option->Append(Value::CreateStringValue(l10n_util::GetStringUTF16( 74 option->Append(base::Value::CreateStringValue(l10n_util::GetStringUTF16(
73 preference.values_and_ids[i].item_message_id))); 75 preference.values_and_ids[i].item_message_id)));
74 list_value->Append(option); 76 list_value->Append(option);
75 } 77 }
76 return list_value; 78 return list_value;
77 } 79 }
78 80
79 } // namespace chromeos 81 } // namespace chromeos
80 82
81 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_LANGUAGE_OPTIONS_UTIL_H_ 83 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_LANGUAGE_OPTIONS_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698