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

Unified Diff: chrome/common/spellcheck_common.cc

Issue 1937203002: Fixed hasty language selection in GetCorrespondingSpellCheckLanguage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added another unit test Created 4 years, 8 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 | « chrome/browser/spellchecker/spellcheck_service_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/spellcheck_common.cc
diff --git a/chrome/common/spellcheck_common.cc b/chrome/common/spellcheck_common.cc
index 58c334674b9ab331584d0b08c86eaa3d560d0e25..a539a117eb37b0f076d00c3fc823ee9fdd8a781f 100644
--- a/chrome/common/spellcheck_common.cc
+++ b/chrome/common/spellcheck_common.cc
@@ -140,6 +140,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) {
@@ -152,12 +153,14 @@ std::string GetCorrespondingSpellCheckLanguage(const std::string& language) {
// Next, look for exact match in the language_region part of the list.
std::string spellcheck_language_region(
g_supported_spellchecker_languages[i].language_region);
- if (spellcheck_language_region == language)
- return g_supported_spellchecker_languages[i].language;
+ if (spellcheck_language_region == language) {
groby-ooo-7-16 2016/05/02 19:07:48 What specific behavior does this fix? Is this _jus
+ if (best_match.empty())
+ best_match = g_supported_spellchecker_languages[i].language;
+ }
}
- // No match found - return blank.
- return std::string();
+ // No match found - return best match, if any.
+ return best_match;
}
void SpellCheckLanguages(std::vector<std::string>* languages) {
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698