Commit f93e9831 authored by My Nguyen's avatar My Nguyen Committed by Chromium LUCI CQ

[Inclusive] Migrate spell check pref

Bug: 1157309, 1161062
Change-Id: I9c3cb7c1b77cef27df29117c49e9ae23db12a5bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598085
Commit-Queue: My Nguyen <myy@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Reviewed-by: default avatarJosh Simmons <jds@google.com>
Cr-Commit-Position: refs/heads/master@{#839005}
parent 9ceca1ad
......@@ -299,7 +299,7 @@ Polymer({
*/
getIndicatorPrefForManagedSpellcheckLanguage_(isEnabled) {
return isEnabled ? this.getPref('spellcheck.forced_dictionaries') :
this.getPref('spellcheck.blacklisted_dictionaries');
this.getPref('spellcheck.blocked_dictionaries');
},
/**
......
......@@ -156,7 +156,7 @@ Polymer({
'spellCheckDictionariesPrefChanged_(' +
'prefs.spellcheck.dictionaries.value.*, ' +
'prefs.spellcheck.forced_dictionaries.value.*, ' +
'prefs.spellcheck.blacklisted_dictionaries.value.*, languages)',
'prefs.spellcheck.blocked_dictionaries.value.*, languages)',
'translateLanguagesPrefChanged_(' +
'prefs.translate_blocked_languages.value.*, languages)',
'updateRemovableLanguages_(' +
......@@ -370,7 +370,7 @@ Polymer({
this.getPref('spellcheck.forced_dictionaries').value));
const spellCheckBlacklistedSet =
this.makeSetFromArray_(/** @type {!Array<string>} */ (
this.getPref('spellcheck.blacklisted_dictionaries').value));
this.getPref('spellcheck.blocked_dictionaries').value));
for (let i = 0; i < this.languages.enabled.length; i++) {
const languageState = this.languages.enabled[i];
......@@ -525,7 +525,7 @@ Polymer({
const spellCheckPref = this.getPref('spellcheck.dictionaries');
const spellCheckForcedPref = this.getPref('spellcheck.forced_dictionaries');
const spellCheckBlacklistedPref =
this.getPref('spellcheck.blacklisted_dictionaries');
this.getPref('spellcheck.blocked_dictionaries');
const spellCheckSet = this.makeSetFromArray_(
/** @type {!Array<string>} */ (
spellCheckPref.value.concat(spellCheckForcedPref.value)));
......
......@@ -596,9 +596,8 @@ Polymer({
* @param {boolean} isEnabled Whether the language is enabled or not.
*/
getIndicatorPrefForManagedSpellcheckLanguage_(isEnabled) {
return isEnabled ?
this.get('spellcheck.forced_dictionaries', this.prefs) :
this.get('spellcheck.blacklisted_dictionaries', this.prefs);
return isEnabled ? this.get('spellcheck.forced_dictionaries', this.prefs) :
this.get('spellcheck.blocked_dictionaries', this.prefs);
},
/**
......
......@@ -51,6 +51,11 @@ void SpellcheckServiceFactory::RegisterProfilePrefs(
user_prefs->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries);
user_prefs->RegisterListPref(
spellcheck::prefs::kSpellCheckForcedDictionaries);
// Continue registering kSpellCheckBlacklistedDictionaries for
// preference migration.
// TODO(crbug/1161062): Remove after M91.
user_prefs->RegisterListPref(
spellcheck::prefs::kSpellCheckBlacklistedDictionaries);
user_prefs->RegisterListPref(
spellcheck::prefs::kSpellCheckBlocklistedDictionaries);
// Continue registering kSpellCheckDictionary for preference migration.
......
......@@ -121,6 +121,22 @@ SpellcheckService::SpellcheckService(content::BrowserContext* context)
}
#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER)
// Migrating kSpellCheckBlacklistedDictionaries preference to
// kSpellCheckBlocklistedDictionaries.
// TODO(crbug/1161062): Remove after M91.
StringListPrefMember old_blocked_dict_pref;
old_blocked_dict_pref.Init(
spellcheck::prefs::kSpellCheckBlacklistedDictionaries, prefs);
StringListPrefMember blocked_dict_pref;
blocked_dict_pref.Init(spellcheck::prefs::kSpellCheckBlocklistedDictionaries,
prefs);
if (blocked_dict_pref.GetValue().empty() &&
!old_blocked_dict_pref.GetValue().empty()) {
blocked_dict_pref.SetValue(old_blocked_dict_pref.GetValue());
old_blocked_dict_pref.SetValue(std::vector<std::string>());
}
pref_change_registrar_.Add(
spellcheck::prefs::kSpellCheckDictionaries,
base::BindRepeating(&SpellcheckService::OnSpellCheckDictionariesChanged,
......
......@@ -1477,7 +1477,7 @@
"policy_pref_mapping_tests": [
{
"policies": { "SpellcheckLanguageBlacklist": ["fr"]},
"prefs": { "spellcheck.blacklisted_dictionaries": {} }
"prefs": { "spellcheck.blocked_dictionaries": {} }
}
]
},
......@@ -1487,7 +1487,7 @@
"policy_pref_mapping_tests": [
{
"policies": { "SpellcheckLanguageBlocklist": ["fr"]},
"prefs": { "spellcheck.blacklisted_dictionaries": {} }
"prefs": { "spellcheck.blocked_dictionaries": {} }
}
]
},
......
......@@ -546,7 +546,7 @@ suite('input page', () => {
() => {
// Force-disable a language via policy.
languageHelper.setPrefValue(
'spellcheck.blacklisted_dictionaries', ['nb']);
'spellcheck.blocked_dictionaries', ['nb']);
Polymer.dom.flush();
const newSpellCheckList =
spellCheckListContainer.querySelectorAll('.list-item');
......@@ -555,8 +555,7 @@ suite('input page', () => {
test('shows force-off spell check when language is enabled', () => {
// Force-disable a language via policy.
languageHelper.setPrefValue(
'spellcheck.blacklisted_dictionaries', ['nb']);
languageHelper.setPrefValue('spellcheck.blocked_dictionaries', ['nb']);
languageHelper.enableLanguage('nb');
Polymer.dom.flush();
......
......@@ -460,7 +460,7 @@ cr.define('settings', function() {
value: 'en-US,sw',
},
{
key: 'spellcheck.blacklisted_dictionaries',
key: 'spellcheck.blocked_dictionaries',
type: chrome.settingsPrivate.PrefType.LIST,
value: [],
},
......
......@@ -575,8 +575,7 @@ suite('languages page', function() {
// Force-disable the same language via policy.
languageHelper.setPrefValue('spellcheck.forced_dictionaries', []);
languageHelper.setPrefValue(
'spellcheck.blacklisted_dictionaries', ['nb']);
languageHelper.setPrefValue('spellcheck.blocked_dictionaries', ['nb']);
languageHelper.enableLanguage('nb');
flush();
const forceDisabledNbLanguageRow =
......
......@@ -21,12 +21,20 @@ const char kSpellCheckDictionaries[] = "spellcheck.dictionaries";
// force-enabled in our spell-checker due to the SpellcheckLanguage policy.
const char kSpellCheckForcedDictionaries[] = "spellcheck.forced_dictionaries";
// DEPRECATED, replaced by kSpellCheckBlocklistedDictionaries below.
// TODO(crbug/1161062): Remove after M91.
// List of strings representing the dictionary names for languages that are
// force-disabled in our spell-checker due to the SpellcheckLanguageBlocklist
// policy.
const char kSpellCheckBlocklistedDictionaries[] =
const char kSpellCheckBlacklistedDictionaries[] =
"spellcheck.blacklisted_dictionaries";
// List of strings representing the dictionary names for languages that are
// force-disabled in our spell-checker due to the SpellcheckLanguageBlocklist
// policy.
const char kSpellCheckBlocklistedDictionaries[] =
"spellcheck.blocked_dictionaries";
// String which represents whether we use the spelling service.
const char kSpellCheckUseSpellingService[] = "spellcheck.use_spelling_service";
......
......@@ -11,6 +11,7 @@ namespace prefs {
extern const char kSpellCheckEnable[];
extern const char kSpellCheckDictionaries[];
extern const char kSpellCheckForcedDictionaries[];
extern const char kSpellCheckBlacklistedDictionaries[];
extern const char kSpellCheckBlocklistedDictionaries[];
extern const char kSpellCheckDictionary[];
extern const char kSpellCheckUseSpellingService[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment