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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.cc

Issue 10907196: Add the ability to filter out extension IMEs from the language settings page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mock input manager Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/webui/options/chromeos/cros_language_options_handler .h" 5 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_INSTRUCTIONS)); 60 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_INSTRUCTIONS));
61 localized_strings->SetString("switch_input_methods_hint", 61 localized_strings->SetString("switch_input_methods_hint",
62 l10n_util::GetStringUTF16( 62 l10n_util::GetStringUTF16(
63 IDS_OPTIONS_SETTINGS_LANGUAGES_SWITCH_INPUT_METHODS_HINT)); 63 IDS_OPTIONS_SETTINGS_LANGUAGES_SWITCH_INPUT_METHODS_HINT));
64 localized_strings->SetString("select_previous_input_method_hint", 64 localized_strings->SetString("select_previous_input_method_hint",
65 l10n_util::GetStringUTF16( 65 l10n_util::GetStringUTF16(
66 IDS_OPTIONS_SETTINGS_LANGUAGES_SELECT_PREVIOUS_INPUT_METHOD_HINT)); 66 IDS_OPTIONS_SETTINGS_LANGUAGES_SELECT_PREVIOUS_INPUT_METHOD_HINT));
67 localized_strings->SetString("restart_button", 67 localized_strings->SetString("restart_button",
68 l10n_util::GetStringUTF16( 68 l10n_util::GetStringUTF16(
69 IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON)); 69 IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON));
70 localized_strings->SetString("extension_ime_label",
71 l10n_util::GetStringUTF16(
72 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_EXTENSION_IME));
73 localized_strings->SetString("extension_ime_description",
74 l10n_util::GetStringUTF16(
75 IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_EXTENSION_DESCRIPTION));
70 76
71 input_method::InputMethodManager* manager = 77 input_method::InputMethodManager* manager =
72 input_method::InputMethodManager::GetInstance(); 78 input_method::InputMethodManager::GetInstance();
73 // GetSupportedInputMethods() never return NULL. 79 // GetSupportedInputMethods() never return NULL.
74 scoped_ptr<input_method::InputMethodDescriptors> descriptors( 80 scoped_ptr<input_method::InputMethodDescriptors> descriptors(
75 manager->GetSupportedInputMethods()); 81 manager->GetSupportedInputMethods());
76 localized_strings->Set("languageList", GetLanguageList(*descriptors)); 82 localized_strings->Set("languageList", GetLanguageList(*descriptors));
77 localized_strings->Set("inputMethodList", GetInputMethodList(*descriptors)); 83 localized_strings->Set("inputMethodList", GetInputMethodList(*descriptors));
84 localized_strings->Set("extensionImeList", GetExtensionImeList());
78 } 85 }
79 86
80 void CrosLanguageOptionsHandler::RegisterMessages() { 87 void CrosLanguageOptionsHandler::RegisterMessages() {
81 ::options::LanguageOptionsHandlerCommon::RegisterMessages(); 88 ::options::LanguageOptionsHandlerCommon::RegisterMessages();
82 89
83 web_ui()->RegisterMessageCallback("inputMethodDisable", 90 web_ui()->RegisterMessageCallback("inputMethodDisable",
84 base::Bind(&CrosLanguageOptionsHandler::InputMethodDisableCallback, 91 base::Bind(&CrosLanguageOptionsHandler::InputMethodDisableCallback,
85 base::Unretained(this))); 92 base::Unretained(this)));
86 web_ui()->RegisterMessageCallback("inputMethodEnable", 93 web_ui()->RegisterMessageCallback("inputMethodEnable",
87 base::Bind(&CrosLanguageOptionsHandler::InputMethodEnableCallback, 94 base::Bind(&CrosLanguageOptionsHandler::InputMethodEnableCallback,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Sets the directionality of the display language name. 193 // Sets the directionality of the display language name.
187 string16 display_name(display_names[i]); 194 string16 display_name(display_names[i]);
188 bool markup_removal = 195 bool markup_removal =
189 base::i18n::UnadjustStringForLocaleDirection(&display_name); 196 base::i18n::UnadjustStringForLocaleDirection(&display_name);
190 DCHECK(markup_removal); 197 DCHECK(markup_removal);
191 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(display_name); 198 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(display_name);
192 std::string directionality = has_rtl_chars ? "rtl" : "ltr"; 199 std::string directionality = has_rtl_chars ? "rtl" : "ltr";
193 200
194 const LanguagePair& pair = language_map[display_names[i]]; 201 const LanguagePair& pair = language_map[display_names[i]];
195 DictionaryValue* dictionary = new DictionaryValue(); 202 DictionaryValue* dictionary = new DictionaryValue();
196 dictionary->SetString("code", pair.first); 203 dictionary->SetString("code", pair.first);
197 dictionary->SetString("displayName", display_names[i]); 204 dictionary->SetString("displayName", display_names[i]);
198 dictionary->SetString("textDirection", directionality); 205 dictionary->SetString("textDirection", directionality);
199 dictionary->SetString("nativeDisplayName", pair.second); 206 dictionary->SetString("nativeDisplayName", pair.second);
200 language_list->Append(dictionary); 207 language_list->Append(dictionary);
201 } 208 }
202 209
203 return language_list; 210 return language_list;
204 } 211 }
205 212
213 base::ListValue* CrosLanguageOptionsHandler::GetExtensionImeList() {
214 input_method::InputMethodManager* manager =
215 input_method::InputMethodManager::GetInstance();
216
217 input_method::InputMethodDescriptors descriptors;
218 manager->GetInputMethodExtensions(&descriptors);
219
220 ListValue* extension_ime_ids_list = new ListValue();
221
222 for (size_t i = 0; i < descriptors.size(); ++i) {
223 const input_method::InputMethodDescriptor& descriptor = descriptors[i];
224 DictionaryValue* dictionary = new DictionaryValue();
225 dictionary->SetString("id", descriptor.id());
226 dictionary->SetString("displayName", descriptor.name());
227 extension_ime_ids_list->Append(dictionary);
228 }
229
230 return extension_ime_ids_list;
231 }
232
206 string16 CrosLanguageOptionsHandler::GetProductName() { 233 string16 CrosLanguageOptionsHandler::GetProductName() {
207 return l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME); 234 return l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME);
208 } 235 }
209 236
210 void CrosLanguageOptionsHandler::SetApplicationLocale( 237 void CrosLanguageOptionsHandler::SetApplicationLocale(
211 const std::string& language_code) { 238 const std::string& language_code) {
212 Profile::FromWebUI(web_ui())->ChangeAppLocale( 239 Profile::FromWebUI(web_ui())->ChangeAppLocale(
213 language_code, Profile::APP_LOCALE_CHANGED_VIA_SETTINGS); 240 language_code, Profile::APP_LOCALE_CHANGED_VIA_SETTINGS);
214 } 241 }
215 242
(...skipping 21 matching lines...) Expand all
237 void CrosLanguageOptionsHandler::InputMethodOptionsOpenCallback( 264 void CrosLanguageOptionsHandler::InputMethodOptionsOpenCallback(
238 const ListValue* args) { 265 const ListValue* args) {
239 const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); 266 const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args));
240 const std::string action = base::StringPrintf( 267 const std::string action = base::StringPrintf(
241 "InputMethodOptions_Open_%s", input_method_id.c_str()); 268 "InputMethodOptions_Open_%s", input_method_id.c_str());
242 content::RecordComputedAction(action); 269 content::RecordComputedAction(action);
243 } 270 }
244 271
245 } // namespace options 272 } // namespace options
246 } // namespace chromeos 273 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/cros_language_options_handler.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698