Commit 23f84f86 authored by My Nguyen's avatar My Nguyen Committed by Commit Bot

[OsSettingsLanguages] Update spellingservice pref in spellcheck_service

As part of moving spell check settings to OS settings in Chrome OS,
updating spelling service pref when spell check pref changed is
identified to be better dealt with in spellcheck_service.

Related CL: https://crrev.com/c/2360093

Bug: 1113439
Change-Id: I0532d28d92912e5437ef729bd84b4916ffc55af8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387912Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Commit-Queue: My Nguyen <myy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804535}
parent 84bbccb4
......@@ -683,17 +683,6 @@ Polymer({
this.spellCheckLanguages_[0].language.code,
!!this.getPref('browser.enable_spellchecking').value);
}
// <if expr="_google_chrome">
// When spell check is disabled, automatically disable using the spelling
// service. This resets the spell check option to 'Use basic spell check'
// when spell check is turned off. This check is in an observer so that it
// can also correct any users who land on the Settings page and happen
// to have spelling service enabled but spell check disabled.
if (!this.getPref('browser.enable_spellchecking').value) {
this.setPrefValue('spellcheck.use_spelling_service', false);
}
// </if>
},
/**
......
......@@ -391,6 +391,10 @@ void SpellcheckService::InitForRenderer(content::RenderProcessHost* host) {
custom_words.assign(custom_dictionary_->GetWords().begin(),
custom_dictionary_->GetWords().end());
} else {
// Disabling spell check should also disable spelling service.
user_prefs::UserPrefs::Get(context)->SetBoolean(
spellcheck::prefs::kSpellCheckUseSpellingService, false);
}
GetSpellCheckerForProcess(host)->Initialize(std::move(dictionaries),
......
......@@ -323,6 +323,18 @@ class SpellcheckServiceHostBrowserTest : public SpellcheckServiceBrowserTest {
DISALLOW_COPY_AND_ASSIGN(SpellcheckServiceHostBrowserTest);
};
// Disable spell check should disable spelling service
IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest,
DisableSpellcheckDisableSpellingService) {
InitSpellcheck(true, "", "en-US");
GetPrefs()->SetBoolean(spellcheck::prefs::kSpellCheckUseSpellingService,
true);
EnableSpellcheck(false);
EXPECT_FALSE(
GetPrefs()->GetBoolean(spellcheck::prefs::kSpellCheckUseSpellingService));
}
// Removing a spellcheck language from accept languages should remove it from
// spellcheck languages list as well.
IN_PROC_BROWSER_TEST_F(SpellcheckServiceBrowserTest,
......
......@@ -741,14 +741,5 @@ suite('languages page', function() {
previousValue,
languagesPage.prefs.spellcheck.use_spelling_service.value);
});
test('disabling spell check turns off spelling service', () => {
languageHelper.setPrefValue('browser.enable_spellchecking', true);
languageHelper.setPrefValue('spellcheck.use_spelling_service', true);
languagesPage.$.enableSpellcheckingToggle.click();
flush();
assertFalse(
languageHelper.getPref('spellcheck.use_spelling_service').value);
});
});
});
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