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

Unified Diff: chrome/browser/ui/webui/options/language_options_handler_common.cc

Issue 23923007: Bug fix: Append a language to the list after blocking it for Translate on Chrome OS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/options/language_options_handler_common.cc
diff --git a/chrome/browser/ui/webui/options/language_options_handler_common.cc b/chrome/browser/ui/webui/options/language_options_handler_common.cc
index d92737686f66f740efa880ca361fb9e7334379b4..06e8a524df5afaec4fed6fd294edc0b381498b60 100644
--- a/chrome/browser/ui/webui/options/language_options_handler_common.cc
+++ b/chrome/browser/ui/webui/options/language_options_handler_common.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/translate/translate_manager.h"
+#include "chrome/browser/translate/translate_prefs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -163,6 +164,10 @@ void LanguageOptionsHandlerCommon::RegisterMessages() {
base::Bind(
&LanguageOptionsHandlerCommon::RetrySpellcheckDictionaryDownload,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("updateLanguageList",
+ base::Bind(
+ &LanguageOptionsHandlerCommon::UpdateLanguageListCallback,
+ base::Unretained(this)));
}
void LanguageOptionsHandlerCommon::OnHunspellDictionaryInitialized() {
@@ -240,6 +245,27 @@ void LanguageOptionsHandlerCommon::SpellCheckLanguageChangeCallback(
RefreshHunspellDictionary();
}
+void LanguageOptionsHandlerCommon::UpdateLanguageListCallback(
+ const ListValue* args) {
+ CHECK_EQ(args->GetSize(), 1u);
+ const ListValue* language_list;
+ args->GetList(0, &language_list);
+ DCHECK(language_list);
+
+ std::vector<std::string> languages;
+ for (ListValue::const_iterator it = language_list->begin();
+ it != language_list->end(); ++it) {
+ std::string lang;
+ (*it)->GetAsString(&lang);
+ languages.push_back(lang);
+ }
+
+ Profile* profile = Profile::FromWebUI(web_ui());
+ PrefService* prefs = profile->GetPrefs();
+ TranslatePrefs translate_prefs(prefs);
+ translate_prefs.UpdateLanguageList(languages);
+}
+
void LanguageOptionsHandlerCommon::RetrySpellcheckDictionaryDownload(
const ListValue* args) {
GetHunspellDictionary()->RetryDownloadDictionary(

Powered by Google App Engine
This is Rietveld 408576698