Index: chrome/browser/spellchecker/spellcheck_service.cc |
diff --git a/chrome/browser/spellchecker/spellcheck_service.cc b/chrome/browser/spellchecker/spellcheck_service.cc |
index f40924e8c18e3ff48c2c981a1514e2ff5b7ce827..d961cec9fe6037e170358eaa7c727f78a05965e9 100644 |
--- a/chrome/browser/spellchecker/spellcheck_service.cc |
+++ b/chrome/browser/spellchecker/spellcheck_service.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/spellchecker/spellcheck_service.h" |
+#include "base/command_line.h" |
#include "base/prefs/pref_member.h" |
#include "base/prefs/pref_service.h" |
#include "base/strings/string_split.h" |
@@ -13,6 +14,7 @@ |
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" |
#include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
#include "chrome/browser/spellchecker/spelling_service_client.h" |
+#include "chrome/common/chrome_switches.h" |
#include "chrome/common/pref_names.h" |
#include "chrome/common/spellcheck_messages.h" |
#include "components/user_prefs/user_prefs.h" |
@@ -75,19 +77,29 @@ SpellcheckService::~SpellcheckService() { |
} |
// static |
-int SpellcheckService::GetSpellCheckLanguages( |
- content::BrowserContext* context, |
- std::vector<std::string>* languages) { |
+std::set<int> SpellcheckService::GetSpellCheckLanguages( |
+ content::BrowserContext* context, |
+ std::vector<std::string>* languages) { |
PrefService* prefs = user_prefs::UserPrefs::Get(context); |
- StringPrefMember accept_languages_pref; |
- StringPrefMember dictionary_language_pref; |
- accept_languages_pref.Init(prefs::kAcceptLanguages, prefs); |
- dictionary_language_pref.Init(prefs::kSpellCheckDictionary, prefs); |
- std::string dictionary_language = dictionary_language_pref.GetValue(); |
+ std::vector<std::string> dictionary_languages; |
+ |
+ const base::CommandLine* command_line = |
+ base::CommandLine::ForCurrentProcess(); |
+ |
+ StringPrefMember dictionary_languages_pref; |
+ if (command_line->HasSwitch(switches::kEnableMultilingualSpellChecker)) { |
+ dictionary_languages_pref.Init(prefs::kSpellCheckDictionaries, prefs); |
+ base::SplitString(dictionary_languages_pref.GetValue(), |
+ chrome::spellcheck_common::kDictionaryLanguagesSeparator, |
+ &dictionary_languages); |
+ } else { |
+ dictionary_languages_pref.Init(prefs::kSpellCheckDictionary, prefs); |
+ dictionary_languages.push_back(dictionary_languages_pref.GetValue()); |
+ } |
- // Now scan through the list of accept languages, and find possible mappings |
- // from this list to the existing list of spell check languages. |
std::vector<std::string> accept_languages; |
+ StringPrefMember accept_languages_pref; |
+ accept_languages_pref.Init(prefs::kAcceptLanguages, prefs); |
#if defined(OS_MACOSX) |
if (spellcheck_mac::SpellCheckerAvailable()) |
@@ -98,23 +110,22 @@ int SpellcheckService::GetSpellCheckLanguages( |
base::SplitString(accept_languages_pref.GetValue(), ',', &accept_languages); |
#endif // !OS_MACOSX |
- GetSpellCheckLanguagesFromAcceptLanguages( |
- accept_languages, dictionary_language, languages); |
+ *languages = dictionary_languages; |
+ GetSpellCheckLanguagesFromAcceptLanguages(accept_languages, languages); |
- for (size_t i = 0; i < languages->size(); ++i) { |
- if ((*languages)[i] == dictionary_language) |
- return i; |
- } |
- return -1; |
+ // |languages| vector begins with the entries from |dictionary_languages|, |
+ // therefore these indices are correct. |
+ std::set<int> selected_language_indices; |
+ for (size_t i = 0; i < dictionary_languages.size(); ++i) |
+ selected_language_indices.insert(i); |
+ |
+ return selected_language_indices; |
} |
// static |
void SpellcheckService::GetSpellCheckLanguagesFromAcceptLanguages( |
const std::vector<std::string>& accept_languages, |
- const std::string& dictionary_language, |
std::vector<std::string>* languages) { |
- // The current dictionary language should be there. |
- languages->push_back(dictionary_language); |
for (std::vector<std::string>::const_iterator i = accept_languages.begin(); |
i != accept_languages.end(); ++i) { |