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

Unified Diff: chrome/common/spellcheck_common.cc

Issue 1156473007: Enables the user to select multiple languages for spellchecking (UI) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments, clarified code. Created 5 years, 6 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/common/spellcheck_common.cc
diff --git a/chrome/common/spellcheck_common.cc b/chrome/common/spellcheck_common.cc
index 372c106b17652d694856978ff1a64df01cba5322..6971728c97dc8ebe0cc1b512cc6a97517bf3f9a1 100644
--- a/chrome/common/spellcheck_common.cc
+++ b/chrome/common/spellcheck_common.cc
@@ -4,9 +4,14 @@
#include "chrome/common/spellcheck_common.h"
+#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/prefs/pref_service.h"
+#include "base/strings/string_split.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
#include "third_party/icu/source/common/unicode/uloc.h"
#include "third_party/icu/source/common/unicode/urename.h"
#include "third_party/icu/source/common/unicode/utypes.h"
@@ -181,5 +186,35 @@ void GetISOLanguageCountryCodeFromLocale(const std::string& locale,
*country_code = std::string(country);
}
+std::vector<std::string> GetDictionaryLanguagesPref(PrefService* prefs) {
+ const base::CommandLine* command_line =
+ base::CommandLine::ForCurrentProcess();
+
+ std::vector<std::string> dictionary_languages;
+ if (command_line->HasSwitch(switches::kEnableMultilingualSpellChecker)) {
+ base::SplitString(prefs->GetString(prefs::kSpellCheckDictionaries),
+ kDictionaryLanguagesSeparator, &dictionary_languages);
+ } else {
+ dictionary_languages.push_back(
+ prefs->GetString(prefs::kSpellCheckDictionary));
+ }
+
+ auto empty_strings_begin =
please use gerrit instead 2015/06/05 17:50:05 Inline this variable into the next statement. Don'
Julius 2015/06/05 21:38:33 Done.
+ std::partition(dictionary_languages.begin(), dictionary_languages.end(),
+ [](const std::string& language) {
+ DCHECK(!language.empty());
+ return language.length() > 0;
+ });
+ dictionary_languages.erase(empty_strings_begin, dictionary_languages.end());
+
+ return dictionary_languages;
+}
+
+bool MultilingualSpellcheckIsEnabled() {
+ const base::CommandLine* command_line =
please use gerrit instead 2015/06/05 17:50:05 Inline this variable into the next statement. Agai
Julius 2015/06/05 21:38:33 Done.
+ base::CommandLine::ForCurrentProcess();
+ return command_line->HasSwitch(switches::kEnableMultilingualSpellChecker);
+}
+
} // namespace spellcheck_common
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698