OLD | NEW |
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/language_options_handler_common.h" | 5 #include "chrome/browser/ui/webui/options/language_options_handler_common.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 &LanguageOptionsHandlerCommon::UpdateLanguageListCallback, | 175 &LanguageOptionsHandlerCommon::UpdateLanguageListCallback, |
176 base::Unretained(this))); | 176 base::Unretained(this))); |
177 } | 177 } |
178 | 178 |
179 void LanguageOptionsHandlerCommon::OnHunspellDictionaryInitialized( | 179 void LanguageOptionsHandlerCommon::OnHunspellDictionaryInitialized( |
180 const std::string& language) { | 180 const std::string& language) { |
181 } | 181 } |
182 | 182 |
183 void LanguageOptionsHandlerCommon::OnHunspellDictionaryDownloadBegin( | 183 void LanguageOptionsHandlerCommon::OnHunspellDictionaryDownloadBegin( |
184 const std::string& language) { | 184 const std::string& language) { |
185 web_ui()->CallJavascriptFunction( | 185 web_ui()->CallJavascriptFunctionUnsafe( |
186 "options.LanguageOptions.onDictionaryDownloadBegin", | 186 "options.LanguageOptions.onDictionaryDownloadBegin", |
187 base::StringValue(language)); | 187 base::StringValue(language)); |
188 } | 188 } |
189 | 189 |
190 void LanguageOptionsHandlerCommon::OnHunspellDictionaryDownloadSuccess( | 190 void LanguageOptionsHandlerCommon::OnHunspellDictionaryDownloadSuccess( |
191 const std::string& language) { | 191 const std::string& language) { |
192 web_ui()->CallJavascriptFunction( | 192 web_ui()->CallJavascriptFunctionUnsafe( |
193 "options.LanguageOptions.onDictionaryDownloadSuccess", | 193 "options.LanguageOptions.onDictionaryDownloadSuccess", |
194 base::StringValue(language)); | 194 base::StringValue(language)); |
195 } | 195 } |
196 | 196 |
197 void LanguageOptionsHandlerCommon::OnHunspellDictionaryDownloadFailure( | 197 void LanguageOptionsHandlerCommon::OnHunspellDictionaryDownloadFailure( |
198 const std::string& language) { | 198 const std::string& language) { |
199 web_ui()->CallJavascriptFunction( | 199 web_ui()->CallJavascriptFunctionUnsafe( |
200 "options.LanguageOptions.onDictionaryDownloadFailure", | 200 "options.LanguageOptions.onDictionaryDownloadFailure", |
201 base::StringValue(language)); | 201 base::StringValue(language)); |
202 } | 202 } |
203 | 203 |
204 base::DictionaryValue* LanguageOptionsHandlerCommon::GetUILanguageCodeSet() { | 204 base::DictionaryValue* LanguageOptionsHandlerCommon::GetUILanguageCodeSet() { |
205 base::DictionaryValue* dictionary = new base::DictionaryValue(); | 205 base::DictionaryValue* dictionary = new base::DictionaryValue(); |
206 const std::vector<std::string>& available_locales = | 206 const std::vector<std::string>& available_locales = |
207 l10n_util::GetAvailableLocales(); | 207 l10n_util::GetAvailableLocales(); |
208 for (size_t i = 0; i < available_locales.size(); ++i) | 208 for (size_t i = 0; i < available_locales.size(); ++i) |
209 dictionary->SetBoolean(available_locales[i], true); | 209 dictionary->SetBoolean(available_locales[i], true); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 void LanguageOptionsHandlerCommon::UiLanguageChangeCallback( | 244 void LanguageOptionsHandlerCommon::UiLanguageChangeCallback( |
245 const base::ListValue* args) { | 245 const base::ListValue* args) { |
246 const std::string language_code = | 246 const std::string language_code = |
247 base::UTF16ToASCII(ExtractStringValue(args)); | 247 base::UTF16ToASCII(ExtractStringValue(args)); |
248 CHECK(!language_code.empty()); | 248 CHECK(!language_code.empty()); |
249 const std::string action = base::StringPrintf( | 249 const std::string action = base::StringPrintf( |
250 "LanguageOptions_UiLanguageChange_%s", language_code.c_str()); | 250 "LanguageOptions_UiLanguageChange_%s", language_code.c_str()); |
251 content::RecordComputedAction(action); | 251 content::RecordComputedAction(action); |
252 SetApplicationLocale(language_code); | 252 SetApplicationLocale(language_code); |
253 base::StringValue language_value(language_code); | 253 base::StringValue language_value(language_code); |
254 web_ui()->CallJavascriptFunction("options.LanguageOptions.uiLanguageSaved", | 254 web_ui()->CallJavascriptFunctionUnsafe( |
255 language_value); | 255 "options.LanguageOptions.uiLanguageSaved", language_value); |
256 } | 256 } |
257 | 257 |
258 void LanguageOptionsHandlerCommon::SpellCheckLanguageChangeCallback( | 258 void LanguageOptionsHandlerCommon::SpellCheckLanguageChangeCallback( |
259 const base::ListValue* args) { | 259 const base::ListValue* args) { |
260 const std::string language_code = | 260 const std::string language_code = |
261 base::UTF16ToASCII(ExtractStringValue(args)); | 261 base::UTF16ToASCII(ExtractStringValue(args)); |
262 const std::string action = base::StringPrintf( | 262 const std::string action = base::StringPrintf( |
263 "LanguageOptions_SpellCheckLanguageChange_%s", language_code.c_str()); | 263 "LanguageOptions_SpellCheckLanguageChange_%s", language_code.c_str()); |
264 content::RecordComputedAction(action); | 264 content::RecordComputedAction(action); |
265 | 265 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 return; | 308 return; |
309 } | 309 } |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 SpellcheckService* LanguageOptionsHandlerCommon::GetSpellcheckService() { | 313 SpellcheckService* LanguageOptionsHandlerCommon::GetSpellcheckService() { |
314 return SpellcheckServiceFactory::GetForContext(Profile::FromWebUI(web_ui())); | 314 return SpellcheckServiceFactory::GetForContext(Profile::FromWebUI(web_ui())); |
315 } | 315 } |
316 | 316 |
317 } // namespace options | 317 } // namespace options |
OLD | NEW |