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

Side by Side Diff: chrome/browser/chromeos/dom_ui/language_chewing_options_handler.cc

Issue 3043023: Add remaining stuff for Mozc configuration DOMUI. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix for review comments (real for this time) Created 10 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/dom_ui/language_mozc_options_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/chromeos/dom_ui/language_chewing_options_handler.h" 5 #include "chrome/browser/chromeos/dom_ui/language_chewing_options_handler.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/chromeos/dom_ui/language_options_util.h" 13 #include "chrome/browser/chromeos/dom_ui/language_options_util.h"
14 #include "chrome/browser/chromeos/language_preferences.h" 14 #include "chrome/browser/chromeos/language_preferences.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 16
17 namespace {
18
19 ListValue* CreateMultipleChoiceList(
20 const chromeos::LanguageMultipleChoicePreference<const char*>& preference) {
21 int list_length = 0;
22 for (size_t i = 0;
23 i < chromeos::LanguageMultipleChoicePreference<const char*>::kMaxItems;
24 ++i) {
25 if (preference.values_and_ids[i].item_message_id == 0)
26 break;
27 ++list_length;
28 }
29 DCHECK_GT(list_length, 0);
30
31 ListValue* list_value = new ListValue();
32 for (int i = 0; i < list_length; ++i) {
33 ListValue* option = new ListValue();
34 option->Append(Value::CreateStringValue(
35 preference.values_and_ids[i].ibus_config_value));
36 option->Append(Value::CreateStringValue(l10n_util::GetString(
37 preference.values_and_ids[i].item_message_id)));
38 list_value->Append(option);
39 }
40 return list_value;
41 }
42
43 } // namespace
44
45 LanguageChewingOptionsHandler::LanguageChewingOptionsHandler() { 17 LanguageChewingOptionsHandler::LanguageChewingOptionsHandler() {
46 } 18 }
47 19
48 LanguageChewingOptionsHandler::~LanguageChewingOptionsHandler() { 20 LanguageChewingOptionsHandler::~LanguageChewingOptionsHandler() {
49 } 21 }
50 22
51 void LanguageChewingOptionsHandler::GetLocalizedValues( 23 void LanguageChewingOptionsHandler::GetLocalizedValues(
52 DictionaryValue* localized_strings) { 24 DictionaryValue* localized_strings) {
53 DCHECK(localized_strings); 25 DCHECK(localized_strings);
54 // Language Chewing page - ChromeOS 26 // Language Chewing page - ChromeOS
(...skipping 19 matching lines...) Expand all
74 46
75 for (size_t i = 0; i < arraysize(chromeos::kChewingMultipleChoicePrefs); 47 for (size_t i = 0; i < arraysize(chromeos::kChewingMultipleChoicePrefs);
76 ++i) { 48 ++i) {
77 const chromeos::LanguageMultipleChoicePreference<const char*>& preference = 49 const chromeos::LanguageMultipleChoicePreference<const char*>& preference =
78 chromeos::kChewingMultipleChoicePrefs[i]; 50 chromeos::kChewingMultipleChoicePrefs[i];
79 localized_strings->SetString( 51 localized_strings->SetString(
80 GetI18nContentValue(preference), 52 GetI18nContentValue(preference),
81 l10n_util::GetString(preference.label_message_id)); 53 l10n_util::GetString(preference.label_message_id));
82 localized_strings->Set( 54 localized_strings->Set(
83 GetTemplateDataPropertyName(preference), 55 GetTemplateDataPropertyName(preference),
84 CreateMultipleChoiceList(preference)); 56 chromeos::CreateMultipleChoiceList(preference));
85 } 57 }
86 58
87 localized_strings->SetString( 59 localized_strings->SetString(
88 GetI18nContentValue(chromeos::kChewingHsuSelKeyType), 60 GetI18nContentValue(chromeos::kChewingHsuSelKeyType),
89 l10n_util::GetString(chromeos::kChewingHsuSelKeyType.label_message_id)); 61 l10n_util::GetString(chromeos::kChewingHsuSelKeyType.label_message_id));
90 62
91 int hsu_sel_key_type_min = std::numeric_limits<int>::max(); 63 int hsu_sel_key_type_min = std::numeric_limits<int>::max();
92 int hsu_sel_key_type_max = std::numeric_limits<int>::min(); 64 int hsu_sel_key_type_max = std::numeric_limits<int>::min();
93 for (size_t i = 0; 65 for (size_t i = 0;
94 i < chromeos::LanguageMultipleChoicePreference<int>::kMaxItems; 66 i < chromeos::LanguageMultipleChoicePreference<int>::kMaxItems;
(...skipping 10 matching lines...) Expand all
105 DCHECK_NE(hsu_sel_key_type_min, std::numeric_limits<int>::max()); 77 DCHECK_NE(hsu_sel_key_type_min, std::numeric_limits<int>::max());
106 DCHECK_NE(hsu_sel_key_type_max, std::numeric_limits<int>::min()); 78 DCHECK_NE(hsu_sel_key_type_max, std::numeric_limits<int>::min());
107 79
108 localized_strings->SetString( 80 localized_strings->SetString(
109 GetTemplateDataMinName(chromeos::kChewingHsuSelKeyType), 81 GetTemplateDataMinName(chromeos::kChewingHsuSelKeyType),
110 IntToWString(hsu_sel_key_type_min)); 82 IntToWString(hsu_sel_key_type_min));
111 localized_strings->SetString( 83 localized_strings->SetString(
112 GetTemplateDataMaxName(chromeos::kChewingHsuSelKeyType), 84 GetTemplateDataMaxName(chromeos::kChewingHsuSelKeyType),
113 IntToWString(hsu_sel_key_type_max)); 85 IntToWString(hsu_sel_key_type_max));
114 } 86 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/dom_ui/language_mozc_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698