fix: prevent in-memory sessions from writing to custom spellchecker dictionary (#22157) (#22683)

* fix: prevent in-memory sessions from writing to custom dictionary

* docs

* spec
This commit is contained in:
Erick Zhao
2020-03-17 08:50:00 -07:00
committed by GitHub
parent b798e1ff54
commit d32e1f8d97
3 changed files with 23 additions and 2 deletions

View File

@@ -876,6 +876,12 @@ v8::Local<v8::Promise> Session::ListWordsInSpellCheckerDictionary() {
}
bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
// don't let in-memory sessions add spellchecker words
// because files will persist unintentionally
bool is_in_memory = browser_context_->IsOffTheRecord();
if (is_in_memory)
return false;
SpellcheckService* spellcheck =
SpellcheckServiceFactory::GetForContext(browser_context_.get());
if (!spellcheck)
@@ -892,6 +898,12 @@ bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
}
bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {
// don't let in-memory sessions remove spellchecker words
// because files will persist unintentionally
bool is_in_memory = browser_context_->IsOffTheRecord();
if (is_in_memory)
return false;
SpellcheckService* service =
SpellcheckServiceFactory::GetForContext(browser_context_.get());
if (!service)