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({ ...@@ -299,7 +299,7 @@ Polymer({
*/ */
getIndicatorPrefForManagedSpellcheckLanguage_(isEnabled) { getIndicatorPrefForManagedSpellcheckLanguage_(isEnabled) {
return isEnabled ? this.getPref('spellcheck.forced_dictionaries') : return isEnabled ? this.getPref('spellcheck.forced_dictionaries') :
this.getPref('spellcheck.blacklisted_dictionaries'); this.getPref('spellcheck.blocked_dictionaries');
}, },
/** /**
......
...@@ -156,7 +156,7 @@ Polymer({ ...@@ -156,7 +156,7 @@ Polymer({
'spellCheckDictionariesPrefChanged_(' + 'spellCheckDictionariesPrefChanged_(' +
'prefs.spellcheck.dictionaries.value.*, ' + 'prefs.spellcheck.dictionaries.value.*, ' +
'prefs.spellcheck.forced_dictionaries.value.*, ' + 'prefs.spellcheck.forced_dictionaries.value.*, ' +
'prefs.spellcheck.blacklisted_dictionaries.value.*, languages)', 'prefs.spellcheck.blocked_dictionaries.value.*, languages)',
'translateLanguagesPrefChanged_(' + 'translateLanguagesPrefChanged_(' +
'prefs.translate_blocked_languages.value.*, languages)', 'prefs.translate_blocked_languages.value.*, languages)',
'updateRemovableLanguages_(' + 'updateRemovableLanguages_(' +
...@@ -370,7 +370,7 @@ Polymer({ ...@@ -370,7 +370,7 @@ Polymer({
this.getPref('spellcheck.forced_dictionaries').value)); this.getPref('spellcheck.forced_dictionaries').value));
const spellCheckBlacklistedSet = const spellCheckBlacklistedSet =
this.makeSetFromArray_(/** @type {!Array<string>} */ ( 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++) { for (let i = 0; i < this.languages.enabled.length; i++) {
const languageState = this.languages.enabled[i]; const languageState = this.languages.enabled[i];
...@@ -525,7 +525,7 @@ Polymer({ ...@@ -525,7 +525,7 @@ Polymer({
const spellCheckPref = this.getPref('spellcheck.dictionaries'); const spellCheckPref = this.getPref('spellcheck.dictionaries');
const spellCheckForcedPref = this.getPref('spellcheck.forced_dictionaries'); const spellCheckForcedPref = this.getPref('spellcheck.forced_dictionaries');
const spellCheckBlacklistedPref = const spellCheckBlacklistedPref =
this.getPref('spellcheck.blacklisted_dictionaries'); this.getPref('spellcheck.blocked_dictionaries');
const spellCheckSet = this.makeSetFromArray_( const spellCheckSet = this.makeSetFromArray_(
/** @type {!Array<string>} */ ( /** @type {!Array<string>} */ (
spellCheckPref.value.concat(spellCheckForcedPref.value))); spellCheckPref.value.concat(spellCheckForcedPref.value)));
......
...@@ -596,9 +596,8 @@ Polymer({ ...@@ -596,9 +596,8 @@ Polymer({
* @param {boolean} isEnabled Whether the language is enabled or not. * @param {boolean} isEnabled Whether the language is enabled or not.
*/ */
getIndicatorPrefForManagedSpellcheckLanguage_(isEnabled) { getIndicatorPrefForManagedSpellcheckLanguage_(isEnabled) {
return isEnabled ? return isEnabled ? this.get('spellcheck.forced_dictionaries', this.prefs) :
this.get('spellcheck.forced_dictionaries', this.prefs) : this.get('spellcheck.blocked_dictionaries', this.prefs);
this.get('spellcheck.blacklisted_dictionaries', this.prefs);
}, },
/** /**
......
...@@ -51,6 +51,11 @@ void SpellcheckServiceFactory::RegisterProfilePrefs( ...@@ -51,6 +51,11 @@ void SpellcheckServiceFactory::RegisterProfilePrefs(
user_prefs->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries); user_prefs->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries);
user_prefs->RegisterListPref( user_prefs->RegisterListPref(
spellcheck::prefs::kSpellCheckForcedDictionaries); spellcheck::prefs::kSpellCheckForcedDictionaries);
// Continue registering kSpellCheckBlacklistedDictionaries for
// preference migration.
// TODO(crbug/1161062): Remove after M91.
user_prefs->RegisterListPref(
spellcheck::prefs::kSpellCheckBlacklistedDictionaries);
user_prefs->RegisterListPref( user_prefs->RegisterListPref(
spellcheck::prefs::kSpellCheckBlocklistedDictionaries); spellcheck::prefs::kSpellCheckBlocklistedDictionaries);
// Continue registering kSpellCheckDictionary for preference migration. // Continue registering kSpellCheckDictionary for preference migration.
......
...@@ -121,6 +121,22 @@ SpellcheckService::SpellcheckService(content::BrowserContext* context) ...@@ -121,6 +121,22 @@ SpellcheckService::SpellcheckService(content::BrowserContext* context)
} }
#endif // defined(OS_WIN) && BUILDFLAG(USE_BROWSER_SPELLCHECKER) #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( pref_change_registrar_.Add(
spellcheck::prefs::kSpellCheckDictionaries, spellcheck::prefs::kSpellCheckDictionaries,
base::BindRepeating(&SpellcheckService::OnSpellCheckDictionariesChanged, base::BindRepeating(&SpellcheckService::OnSpellCheckDictionariesChanged,
......
...@@ -1477,7 +1477,7 @@ ...@@ -1477,7 +1477,7 @@
"policy_pref_mapping_tests": [ "policy_pref_mapping_tests": [
{ {
"policies": { "SpellcheckLanguageBlacklist": ["fr"]}, "policies": { "SpellcheckLanguageBlacklist": ["fr"]},
"prefs": { "spellcheck.blacklisted_dictionaries": {} } "prefs": { "spellcheck.blocked_dictionaries": {} }
} }
] ]
}, },
...@@ -1487,7 +1487,7 @@ ...@@ -1487,7 +1487,7 @@
"policy_pref_mapping_tests": [ "policy_pref_mapping_tests": [
{ {
"policies": { "SpellcheckLanguageBlocklist": ["fr"]}, "policies": { "SpellcheckLanguageBlocklist": ["fr"]},
"prefs": { "spellcheck.blacklisted_dictionaries": {} } "prefs": { "spellcheck.blocked_dictionaries": {} }
} }
] ]
}, },
......
...@@ -546,7 +546,7 @@ suite('input page', () => { ...@@ -546,7 +546,7 @@ suite('input page', () => {
() => { () => {
// Force-disable a language via policy. // Force-disable a language via policy.
languageHelper.setPrefValue( languageHelper.setPrefValue(
'spellcheck.blacklisted_dictionaries', ['nb']); 'spellcheck.blocked_dictionaries', ['nb']);
Polymer.dom.flush(); Polymer.dom.flush();
const newSpellCheckList = const newSpellCheckList =
spellCheckListContainer.querySelectorAll('.list-item'); spellCheckListContainer.querySelectorAll('.list-item');
...@@ -555,8 +555,7 @@ suite('input page', () => { ...@@ -555,8 +555,7 @@ suite('input page', () => {
test('shows force-off spell check when language is enabled', () => { test('shows force-off spell check when language is enabled', () => {
// Force-disable a language via policy. // Force-disable a language via policy.
languageHelper.setPrefValue( languageHelper.setPrefValue('spellcheck.blocked_dictionaries', ['nb']);
'spellcheck.blacklisted_dictionaries', ['nb']);
languageHelper.enableLanguage('nb'); languageHelper.enableLanguage('nb');
Polymer.dom.flush(); Polymer.dom.flush();
......
...@@ -460,7 +460,7 @@ cr.define('settings', function() { ...@@ -460,7 +460,7 @@ cr.define('settings', function() {
value: 'en-US,sw', value: 'en-US,sw',
}, },
{ {
key: 'spellcheck.blacklisted_dictionaries', key: 'spellcheck.blocked_dictionaries',
type: chrome.settingsPrivate.PrefType.LIST, type: chrome.settingsPrivate.PrefType.LIST,
value: [], value: [],
}, },
......
...@@ -575,8 +575,7 @@ suite('languages page', function() { ...@@ -575,8 +575,7 @@ suite('languages page', function() {
// Force-disable the same language via policy. // Force-disable the same language via policy.
languageHelper.setPrefValue('spellcheck.forced_dictionaries', []); languageHelper.setPrefValue('spellcheck.forced_dictionaries', []);
languageHelper.setPrefValue( languageHelper.setPrefValue('spellcheck.blocked_dictionaries', ['nb']);
'spellcheck.blacklisted_dictionaries', ['nb']);
languageHelper.enableLanguage('nb'); languageHelper.enableLanguage('nb');
flush(); flush();
const forceDisabledNbLanguageRow = const forceDisabledNbLanguageRow =
......
...@@ -21,12 +21,20 @@ const char kSpellCheckDictionaries[] = "spellcheck.dictionaries"; ...@@ -21,12 +21,20 @@ const char kSpellCheckDictionaries[] = "spellcheck.dictionaries";
// force-enabled in our spell-checker due to the SpellcheckLanguage policy. // force-enabled in our spell-checker due to the SpellcheckLanguage policy.
const char kSpellCheckForcedDictionaries[] = "spellcheck.forced_dictionaries"; 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 // List of strings representing the dictionary names for languages that are
// force-disabled in our spell-checker due to the SpellcheckLanguageBlocklist // force-disabled in our spell-checker due to the SpellcheckLanguageBlocklist
// policy. // policy.
const char kSpellCheckBlocklistedDictionaries[] = const char kSpellCheckBlacklistedDictionaries[] =
"spellcheck.blacklisted_dictionaries"; "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. // String which represents whether we use the spelling service.
const char kSpellCheckUseSpellingService[] = "spellcheck.use_spelling_service"; const char kSpellCheckUseSpellingService[] = "spellcheck.use_spelling_service";
......
...@@ -11,6 +11,7 @@ namespace prefs { ...@@ -11,6 +11,7 @@ namespace prefs {
extern const char kSpellCheckEnable[]; extern const char kSpellCheckEnable[];
extern const char kSpellCheckDictionaries[]; extern const char kSpellCheckDictionaries[];
extern const char kSpellCheckForcedDictionaries[]; extern const char kSpellCheckForcedDictionaries[];
extern const char kSpellCheckBlacklistedDictionaries[];
extern const char kSpellCheckBlocklistedDictionaries[]; extern const char kSpellCheckBlocklistedDictionaries[];
extern const char kSpellCheckDictionary[]; extern const char kSpellCheckDictionary[];
extern const char kSpellCheckUseSpellingService[]; 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