| 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/common/spellcheck_common.h" |    5 #include "chrome/common/spellcheck_common.h" | 
|    6  |    6  | 
 |    7 #include "base/command_line.h" | 
|    7 #include "base/files/file_path.h" |    8 #include "base/files/file_path.h" | 
|    8 #include "base/logging.h" |    9 #include "base/logging.h" | 
 |   10 #include "base/prefs/pref_service.h" | 
 |   11 #include "base/strings/string_split.h" | 
 |   12 #include "chrome/common/chrome_switches.h" | 
 |   13 #include "chrome/common/pref_names.h" | 
|    9 #include "third_party/icu/source/common/unicode/uloc.h" |   14 #include "third_party/icu/source/common/unicode/uloc.h" | 
|   10  |   15  | 
|   11 namespace chrome { |   16 namespace chrome { | 
|   12 namespace spellcheck_common { |   17 namespace spellcheck_common { | 
|   13  |   18  | 
|   14 struct LanguageRegion { |   19 struct LanguageRegion { | 
|   15   const char* language;  // The language. |   20   const char* language;  // The language. | 
|   16   const char* language_region;  // language & region, used by dictionaries. |   21   const char* language_region;  // language & region, used by dictionaries. | 
|   17 }; |   22 }; | 
|   18  |   23  | 
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  171     char id[ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY]; |  176     char id[ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY]; | 
|  172     uloc_addLikelySubtags(locale.c_str(), id, arraysize(id), &error); |  177     uloc_addLikelySubtags(locale.c_str(), id, arraysize(id), &error); | 
|  173     error = U_ZERO_ERROR; |  178     error = U_ZERO_ERROR; | 
|  174     uloc_getLanguage(id, language, arraysize(language), &error); |  179     uloc_getLanguage(id, language, arraysize(language), &error); | 
|  175     country = uloc_getISO3Country(id); |  180     country = uloc_getISO3Country(id); | 
|  176   } |  181   } | 
|  177   *language_code = std::string(language); |  182   *language_code = std::string(language); | 
|  178   *country_code = std::string(country); |  183   *country_code = std::string(country); | 
|  179 } |  184 } | 
|  180  |  185  | 
 |  186 std::vector<std::string> GetDictionaryLanguagesPref(PrefService* prefs) { | 
 |  187   const base::CommandLine* command_line = | 
 |  188       base::CommandLine::ForCurrentProcess(); | 
 |  189  | 
 |  190   std::vector<std::string> dictionary_languages; | 
 |  191   if (command_line->HasSwitch(switches::kEnableMultilingualSpellChecker)) { | 
 |  192     base::SplitString(prefs->GetString(prefs::kSpellCheckDictionaries), | 
 |  193                       kDictionaryLanguagesSeparator, &dictionary_languages); | 
 |  194   } else { | 
 |  195     dictionary_languages.push_back( | 
 |  196         prefs->GetString(prefs::kSpellCheckDictionary)); | 
 |  197   } | 
 |  198  | 
 |  199   auto empty_strings_begin = | 
 |  200       std::partition(dictionary_languages.begin(), dictionary_languages.end(), | 
 |  201                      [](const std::string& language) { | 
 |  202         DCHECK(!language.empty()); | 
 |  203         return language.length() > 0; | 
 |  204       }); | 
 |  205   dictionary_languages.erase(empty_strings_begin, dictionary_languages.end()); | 
 |  206  | 
 |  207   return dictionary_languages; | 
 |  208 } | 
 |  209  | 
|  181 }  // namespace spellcheck_common |  210 }  // namespace spellcheck_common | 
|  182 }  // namespace chrome |  211 }  // namespace chrome | 
| OLD | NEW |