summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/spellchecker.cc13
-rw-r--r--chrome/browser/spellchecker.h5
-rw-r--r--chrome/browser/views/options/languages_page_view.cc29
3 files changed, 47 insertions, 0 deletions
diff --git a/chrome/browser/spellchecker.cc b/chrome/browser/spellchecker.cc
index 5cd32a6..62cff23 100644
--- a/chrome/browser/spellchecker.cc
+++ b/chrome/browser/spellchecker.cc
@@ -96,6 +96,19 @@ SpellChecker::Language SpellChecker::GetSpellCheckLanguageRegion(
return input_language;
}
+
+SpellChecker::Language SpellChecker::GetLanguageFromLanguageRegion(
+ Language input_language) {
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(g_supported_spellchecker_languages);
+ ++i) {
+ Language language(g_supported_spellchecker_languages[i].language_region);
+ if (language == input_language)
+ return Language(g_supported_spellchecker_languages[i].language);
+ }
+
+ return input_language;
+}
+
SpellChecker::Language SpellChecker::GetCorrespondingSpellCheckLanguage(
const Language& language) {
// Look for exact match in the Spell Check language list.
diff --git a/chrome/browser/spellchecker.h b/chrome/browser/spellchecker.h
index 6d59a2d..42279c2 100644
--- a/chrome/browser/spellchecker.h
+++ b/chrome/browser/spellchecker.h
@@ -92,6 +92,11 @@ class SpellChecker : public base::RefCountedThreadSafe<SpellChecker> {
// spell check language. For example, for hi, it returns hi-IN.
static Language GetSpellCheckLanguageRegion(Language input_language);
+ // This function returns ll (language code) from ll-RR where 'RR' (region
+ // code) is redundant. However, if the region code matters, it's preserved.
+ // That is, it returns 'hi' and 'en-GB' for 'hi-IN' and 'en-GB' respectively.
+ static Language GetLanguageFromLanguageRegion(Language input_language);
+
private:
// Download dictionary files when required.
class DictionaryDownloadController;
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index b28d4cf..62bcf81 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -678,6 +678,33 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kSpellCheckDictionary) {
int index = dictionary_language_model_->GetSelectedLanguageIndex(
prefs::kSpellCheckDictionary);
+
+ // If the index for the current language cannot be found, it is due to
+ // the fact that the pref-member value for the last dictionary language
+ // set by the user still uses the old format; i.e. language-region, even
+ // when region is not necessary. For example, if the user sets the
+ // dictionary language to be French, the pref-member value in the user
+ // profile is "fr-FR", whereas we now use only "fr". To resolve this issue,
+ // if "fr-FR" is read from the pref, the language code ("fr" here) is
+ // extracted, and re-written in the pref, so that the pref-member value for
+ // dictionary language in the user profile now correctly stores "fr"
+ // instead of "fr-FR".
+ if (index < 0) {
+ PrefService* local_state;
+ if (!profile())
+ local_state = g_browser_process->local_state();
+ else
+ local_state = profile()->GetPrefs();
+
+ DCHECK(local_state);
+ const std::wstring& lang_region = local_state->GetString(
+ prefs::kSpellCheckDictionary);
+ dictionary_language_.SetValue(
+ SpellChecker::GetLanguageFromLanguageRegion(lang_region));
+ index = dictionary_language_model_->GetSelectedLanguageIndex(
+ prefs::kSpellCheckDictionary);
+ }
+
change_dictionary_language_combobox_->SetSelectedItem(index);
spellcheck_language_index_selected_ = -1;
}
@@ -705,6 +732,8 @@ void LanguagesPageView::ItemChanged(views::ComboBox* sender,
}
} else if (sender == change_dictionary_language_combobox_) {
spellcheck_language_index_selected_ = new_index;
+ OnAddLanguage(dictionary_language_model_->GetLocaleFromIndex(new_index));
+ language_table_edited_ = true;
}
}