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

Unified Diff: components/spellcheck/common/spellcheck_common.cc

Issue 2177343002: Componentize spellcheck [2]: move common/ files to component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix mac bots a bit more Created 4 years, 5 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
« no previous file with comments | « components/spellcheck/common/spellcheck_common.h ('k') | components/spellcheck/common/spellcheck_marker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/spellcheck/common/spellcheck_common.cc
diff --git a/chrome/common/spellcheck_common.cc b/components/spellcheck/common/spellcheck_common.cc
similarity index 71%
rename from chrome/common/spellcheck_common.cc
rename to components/spellcheck/common/spellcheck_common.cc
index bebbb7c0ed85e1eb23397a2a0888c1e0d3b4090c..f62a80cbbc6bb60747104f29d6e890509f464cbe 100644
--- a/chrome/common/spellcheck_common.cc
+++ b/components/spellcheck/common/spellcheck_common.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/spellcheck_common.h"
+#include "components/spellcheck/common/spellcheck_common.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
@@ -10,16 +10,14 @@
#include "base/macros.h"
#include "base/metrics/field_trial.h"
#include "base/strings/string_util.h"
-#include "chrome/common/chrome_switches.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"
-namespace chrome {
-namespace spellcheck_common {
+namespace spellcheck {
struct LanguageRegion {
- const char* language; // The language.
+ const char* language; // The language.
const char* language_region; // language & region, used by dictionaries.
};
@@ -29,61 +27,28 @@ struct LanguageVersion {
};
static const LanguageRegion g_supported_spellchecker_languages[] = {
- // Several languages are not to be included in the spellchecker list:
- // th-TH, vi-VI.
- {"af", "af-ZA"},
- {"bg", "bg-BG"},
- {"ca", "ca-ES"},
- {"cs", "cs-CZ"},
- {"da", "da-DK"},
- {"de", "de-DE"},
- {"el", "el-GR"},
- {"en-AU", "en-GB"},
- {"en-CA", "en-CA"},
- {"en-GB", "en-GB"},
- {"en-US", "en-US"},
- {"es", "es-ES"},
- {"es-419", "es-ES"},
- {"es-AR", "es-ES"},
- {"es-ES", "es-ES"},
- {"es-MX", "es-ES"},
- {"es-US", "es-ES"},
- {"et", "et-EE"},
- {"fa", "fa-IR"},
- {"fo", "fo-FO"},
- {"fr", "fr-FR"},
- {"he", "he-IL"},
- {"hi", "hi-IN"},
- {"hr", "hr-HR"},
- {"hu", "hu-HU"},
- {"id", "id-ID"},
- {"it", "it-IT"},
- {"ko", "ko"},
- {"lt", "lt-LT"},
- {"lv", "lv-LV"},
- {"nb", "nb-NO"},
- {"nl", "nl-NL"},
- {"pl", "pl-PL"},
- {"pt-BR", "pt-BR"},
- {"pt-PT", "pt-PT"},
- {"ro", "ro-RO"},
- {"ru", "ru-RU"},
- {"sh", "sh"},
- {"sk", "sk-SK"},
- {"sl", "sl-SI"},
- {"sq", "sq"},
- {"sr", "sr"},
- {"sv", "sv-SE"},
- {"ta", "ta-IN"},
- {"tg", "tg-TG"},
- {"tr", "tr-TR"},
- {"uk", "uk-UA"},
- {"vi", "vi-VN"},
+ // Several languages are not to be included in the spellchecker list:
+ // th-TH, vi-VI.
+ {"af", "af-ZA"}, {"bg", "bg-BG"}, {"ca", "ca-ES"},
groby-ooo-7-16 2016/07/26 21:33:31 Please don't reformat this. Even if clang thinks i
timvolodine 2016/07/27 14:10:34 Done.
+ {"cs", "cs-CZ"}, {"da", "da-DK"}, {"de", "de-DE"},
+ {"el", "el-GR"}, {"en-AU", "en-GB"}, {"en-CA", "en-CA"},
+ {"en-GB", "en-GB"}, {"en-US", "en-US"}, {"es", "es-ES"},
+ {"es-419", "es-ES"}, {"es-AR", "es-ES"}, {"es-ES", "es-ES"},
+ {"es-MX", "es-ES"}, {"es-US", "es-ES"}, {"et", "et-EE"},
+ {"fa", "fa-IR"}, {"fo", "fo-FO"}, {"fr", "fr-FR"},
+ {"he", "he-IL"}, {"hi", "hi-IN"}, {"hr", "hr-HR"},
+ {"hu", "hu-HU"}, {"id", "id-ID"}, {"it", "it-IT"},
+ {"ko", "ko"}, {"lt", "lt-LT"}, {"lv", "lv-LV"},
+ {"nb", "nb-NO"}, {"nl", "nl-NL"}, {"pl", "pl-PL"},
+ {"pt-BR", "pt-BR"}, {"pt-PT", "pt-PT"}, {"ro", "ro-RO"},
+ {"ru", "ru-RU"}, {"sh", "sh"}, {"sk", "sk-SK"},
+ {"sl", "sl-SI"}, {"sq", "sq"}, {"sr", "sr"},
+ {"sv", "sv-SE"}, {"ta", "ta-IN"}, {"tg", "tg-TG"},
+ {"tr", "tr-TR"}, {"uk", "uk-UA"}, {"vi", "vi-VN"},
};
bool IsValidRegion(const std::string& region) {
- for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
- ++i) {
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages); ++i) {
if (g_supported_spellchecker_languages[i].language_region == region)
return true;
}
@@ -93,11 +58,9 @@ bool IsValidRegion(const std::string& region) {
// This function returns the language-region version of language name.
// e.g. returns hi-IN for hi.
std::string GetSpellCheckLanguageRegion(const std::string& input_language) {
- for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
- ++i) {
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages); ++i) {
if (g_supported_spellchecker_languages[i].language == input_language) {
- return std::string(
- g_supported_spellchecker_languages[i].language_region);
+ return std::string(g_supported_spellchecker_languages[i].language_region);
}
}
@@ -115,17 +78,18 @@ base::FilePath GetVersionedFileName(const std::string& input_language,
// number if you're updating either dic or aff files. Increment the minor
// version number if you're updating only dic_delta files.
static LanguageVersion special_version_string[] = {
- {"tr-TR", "-4-0"}, // Jan 9, 2013: Add "FLAG num" to aff to avoid heapcheck
- // crash.
- {"tg-TG", "-5-0"}, // Mar 4, 2014: Add Tajik dictionary.
-
- // April 2016: Local fixes
- {"en-CA", "-7-1"},
- {"en-GB", "-7-1"},
- {"en-US", "-7-1"},
-
- // March 2016: Initial check-in of Persian
- {"fa-IR", "-7-0"},
+ {"tr-TR",
groby-ooo-7-16 2016/07/26 21:33:31 Please don't reformat.
timvolodine 2016/07/27 14:10:34 Done.
+ "-4-0"}, // Jan 9, 2013: Add "FLAG num" to aff to avoid heapcheck
+ // crash.
+ {"tg-TG", "-5-0"}, // Mar 4, 2014: Add Tajik dictionary.
+
+ // April 2016: Local fixes
+ {"en-CA", "-7-1"},
+ {"en-GB", "-7-1"},
+ {"en-US", "-7-1"},
+
+ // March 2016: Initial check-in of Persian
+ {"fa-IR", "-7-0"},
};
// Generate the bdict file name using default version string or special
@@ -147,8 +111,7 @@ base::FilePath GetVersionedFileName(const std::string& input_language,
std::string GetCorrespondingSpellCheckLanguage(const std::string& language) {
std::string best_match;
// Look for exact match in the Spell Check language list.
- for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
- ++i) {
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages); ++i) {
// First look for exact match in the language region of the list.
std::string spellcheck_language(
g_supported_spellchecker_languages[i].language);
@@ -169,8 +132,7 @@ std::string GetCorrespondingSpellCheckLanguage(const std::string& language) {
}
void SpellCheckLanguages(std::vector<std::string>* languages) {
- for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages);
- ++i) {
+ for (size_t i = 0; i < arraysize(g_supported_spellchecker_languages); ++i) {
languages->push_back(g_supported_spellchecker_languages[i].language);
}
}
@@ -194,5 +156,4 @@ void GetISOLanguageCountryCodeFromLocale(const std::string& locale,
*country_code = std::string(country);
}
-} // namespace spellcheck_common
-} // namespace chrome
+} // namespace spellcheck
« no previous file with comments | « components/spellcheck/common/spellcheck_common.h ('k') | components/spellcheck/common/spellcheck_marker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698