-
Bruce Long authored
Spellcheck languages that have Windows platform support but not Hunspell support (Arabic, Finnish, ...) cannot be disabled or forced enabled by enterprise policy. This is because of the use of spellcheck::GetCorrespondingSpellCheckLanguage in SpellcheckLanguageBlacklistPolicyHandler::SortBlacklistedLanguages and SpellcheckLanguagePolicyHandler::SortForcedLanguages, a method that only recognizes Hunspell languages. The fix is to instead check if a language with policy being enforced is on the list of supported accept languages, as these are what are used to populate the language list on the language settings page. Note that in the upcoming implementation of support for non-Hunspell languages, we will only allow Windows platform spellchecking for these accept languages (if they have a Windows spellcheck dictionary). Instead of just searching for the accept language within the tag, the algorithm first tries for an exact match (so "en-CA" would be found), then searches for an exact match for the language without locale info, that is, what's to the left of the hyphen in a language tag (so "ar" would be found for "ar-SA"). Also adds unit test coverage for the spellcheck policy handlers, which previously had none. Note that there is an interplay between forced and blocked languages, as well as the spellcheck-enabled policy: 1) If a language is both forced and blocked, forced wins. 2) If spellcheck is disabled by policy, the forced/blocked languages policy has no effect. Test cases cover this interplay. Bug: 1056850 Change-Id: Iec54a851d38f00a7aa7597449f7acc30f3dd2de3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080450Reviewed-by:
Rouslan Solomakhin <rouslan@chromium.org> Reviewed-by:
Avi Drissman <avi@chromium.org> Commit-Queue: Bruce Long <brlong@microsoft.com> Cr-Commit-Position: refs/heads/master@{#757107}
1527cb7a