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 <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 GetSpellCheckLanguageCodeSet()); | 125 GetSpellCheckLanguageCodeSet()); |
126 localized_strings->Set("uiLanguageCodeSet", GetUILanguageCodeSet()); | 126 localized_strings->Set("uiLanguageCodeSet", GetUILanguageCodeSet()); |
127 | 127 |
128 const base::CommandLine& command_line = | 128 const base::CommandLine& command_line = |
129 *base::CommandLine::ForCurrentProcess(); | 129 *base::CommandLine::ForCurrentProcess(); |
130 bool enable_spelling_auto_correct = | 130 bool enable_spelling_auto_correct = |
131 command_line.HasSwitch(switches::kEnableSpellingAutoCorrect); | 131 command_line.HasSwitch(switches::kEnableSpellingAutoCorrect); |
132 localized_strings->SetBoolean("enableSpellingAutoCorrect", | 132 localized_strings->SetBoolean("enableSpellingAutoCorrect", |
133 enable_spelling_auto_correct); | 133 enable_spelling_auto_correct); |
134 | 134 |
135 localized_strings->SetBoolean( | |
136 "enableMultilingualSpellChecker", | |
137 chrome::spellcheck_common::IsMultilingualSpellcheckEnabled()); | |
138 | |
135 Profile* profile = Profile::FromWebUI(web_ui()); | 139 Profile* profile = Profile::FromWebUI(web_ui()); |
136 PrefService* prefs = profile->GetPrefs(); | 140 PrefService* prefs = profile->GetPrefs(); |
137 std::string default_target_language = | 141 std::string default_target_language = |
138 TranslateService::GetTargetLanguage(prefs); | 142 TranslateService::GetTargetLanguage(prefs); |
139 localized_strings->SetString("defaultTargetLanguage", | 143 localized_strings->SetString("defaultTargetLanguage", |
140 default_target_language); | 144 default_target_language); |
141 localized_strings->SetBoolean( | 145 localized_strings->SetBoolean( |
142 "enableMultilingualSpellChecker", | 146 "enableMultilingualSpellChecker", |
143 chrome::spellcheck_common::IsMultilingualSpellcheckEnabled()); | 147 chrome::spellcheck_common::IsMultilingualSpellcheckEnabled()); |
144 | 148 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 SetApplicationLocale(language_code); | 251 SetApplicationLocale(language_code); |
248 base::StringValue language_value(language_code); | 252 base::StringValue language_value(language_code); |
249 web_ui()->CallJavascriptFunction("options.LanguageOptions.uiLanguageSaved", | 253 web_ui()->CallJavascriptFunction("options.LanguageOptions.uiLanguageSaved", |
250 language_value); | 254 language_value); |
251 } | 255 } |
252 | 256 |
253 void LanguageOptionsHandlerCommon::SpellCheckLanguageChangeCallback( | 257 void LanguageOptionsHandlerCommon::SpellCheckLanguageChangeCallback( |
254 const base::ListValue* args) { | 258 const base::ListValue* args) { |
255 const std::string language_code = | 259 const std::string language_code = |
256 base::UTF16ToASCII(ExtractStringValue(args)); | 260 base::UTF16ToASCII(ExtractStringValue(args)); |
257 CHECK(!language_code.empty()); | |
please use gerrit instead
2015/07/06 23:28:15
Why remove this?
Julius
2015/07/07 01:14:21
Because now language_code can actually be empty if
| |
258 const std::string action = base::StringPrintf( | 261 const std::string action = base::StringPrintf( |
259 "LanguageOptions_SpellCheckLanguageChange_%s", language_code.c_str()); | 262 "LanguageOptions_SpellCheckLanguageChange_%s", language_code.c_str()); |
260 content::RecordComputedAction(action); | 263 content::RecordComputedAction(action); |
261 RefreshHunspellDictionary(); | 264 RefreshHunspellDictionary(); |
262 } | 265 } |
263 | 266 |
264 void LanguageOptionsHandlerCommon::UpdateLanguageListCallback( | 267 void LanguageOptionsHandlerCommon::UpdateLanguageListCallback( |
265 const base::ListValue* args) { | 268 const base::ListValue* args) { |
266 CHECK_EQ(args->GetSize(), 1u); | 269 CHECK_EQ(args->GetSize(), 1u); |
267 const base::ListValue* language_list; | 270 const base::ListValue* language_list; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 } | 302 } |
300 | 303 |
301 base::WeakPtr<SpellcheckHunspellDictionary>& | 304 base::WeakPtr<SpellcheckHunspellDictionary>& |
302 LanguageOptionsHandlerCommon::GetHunspellDictionary() { | 305 LanguageOptionsHandlerCommon::GetHunspellDictionary() { |
303 if (!hunspell_dictionary_.get()) | 306 if (!hunspell_dictionary_.get()) |
304 RefreshHunspellDictionary(); | 307 RefreshHunspellDictionary(); |
305 return hunspell_dictionary_; | 308 return hunspell_dictionary_; |
306 } | 309 } |
307 | 310 |
308 } // namespace options | 311 } // namespace options |
OLD | NEW |