I tried calling this after CefBrowserHost::CreateBrowser()
- Code: Select all
void BrowserDisableSpellCheck()
{
if (!CefCurrentlyOn(TID_UI))
{
CefPostTask(TID_UI, base::Bind(&BrowserDisableSpellCheck));
return;
}
CefRefPtr<CefRequestContext> context = CefRequestContext::GetGlobalContext();
const char kEnableSpellcheck[] = "browser.enable_spellchecking";
CefString errtext;
CefRefPtr<CefValue> pval = CefValue::Create();
pval->SetBool(false);
bool pset = context->SetPreference(kEnableSpellcheck, pval, errtext);
}
And this just before using browser->LoadURL to navigate the first browser to a website
- Code: Select all
void BrowserDisableSpellCheck2(CefRefPtr<CefBrowser> browser)
{
if (!CefCurrentlyOn(TID_UI))
{
CefPostTask(TID_UI, base::Bind(&BrowserDisableSpellCheck2, browser));
return;
}
CefRefPtr<CefRequestContext> context = browser->GetHost()->GetRequestContext();
const char kEnableSpellcheck[] = "browser.enable_spellchecking";
CefString errtext;
CefRefPtr<CefValue> pval = CefValue::Create();
pval->SetBool(false);
bool pset = context->SetPreference(kEnableSpellcheck, pval, errtext);
}
The code is running in the UI thread and for both functions SetPreference returns success. I also checked with GetPreference() that the value of browser.enable_spellchecking is now false.
But if I type something like "wronk wrods" both still get the red underlines. Can anyone see what I'm doing wrong?