feat: add session.removeWordFromSpellCheckerDictionary API (#22039)
* feat: add session.removeWordFromSpellCheckerDictionary API * rebase fixup
This commit is contained in:
parent
8ca4e761fd
commit
17abeca8b7
3 changed files with 26 additions and 0 deletions
|
@ -495,6 +495,14 @@ Returns `Boolean` - Whether the word was successfully written to the custom dict
|
||||||
|
|
||||||
**Note:** On macOS and Windows 10 this word will be written to the OS custom dictionary as well
|
**Note:** On macOS and Windows 10 this word will be written to the OS custom dictionary as well
|
||||||
|
|
||||||
|
#### `ses.removeWordFromSpellCheckerDictionary(word)`
|
||||||
|
|
||||||
|
* `word` String - The word you want to remove from the dictionary
|
||||||
|
|
||||||
|
Returns `Boolean` - Whether the word was successfully removed from the custom dictionary.
|
||||||
|
|
||||||
|
**Note:** On macOS and Windows 10 this word will be removed from the OS custom dictionary as well
|
||||||
|
|
||||||
#### `ses.loadExtension(path)`
|
#### `ses.loadExtension(path)`
|
||||||
|
|
||||||
* `path` String - Path to a directory containing an unpacked Chrome extension
|
* `path` String - Path to a directory containing an unpacked Chrome extension
|
||||||
|
|
|
@ -785,6 +785,21 @@ bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
|
||||||
#endif
|
#endif
|
||||||
return service->GetCustomDictionary()->AddWord(word);
|
return service->GetCustomDictionary()->AddWord(word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {
|
||||||
|
SpellcheckService* service =
|
||||||
|
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
||||||
|
if (!service)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
|
||||||
|
if (spellcheck::UseBrowserSpellChecker()) {
|
||||||
|
spellcheck_platform::RemoveWord(service->platform_spell_checker(),
|
||||||
|
base::UTF8ToUTF16(word));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return service->GetCustomDictionary()->RemoveWord(word);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -873,6 +888,8 @@ void Session::BuildPrototype(v8::Isolate* isolate,
|
||||||
&SetSpellCheckerDictionaryDownloadURL)
|
&SetSpellCheckerDictionaryDownloadURL)
|
||||||
.SetMethod("addWordToSpellCheckerDictionary",
|
.SetMethod("addWordToSpellCheckerDictionary",
|
||||||
&Session::AddWordToSpellCheckerDictionary)
|
&Session::AddWordToSpellCheckerDictionary)
|
||||||
|
.SetMethod("removeWordFromSpellCheckerDictionary",
|
||||||
|
&Session::RemoveWordFromSpellCheckerDictionary)
|
||||||
#endif
|
#endif
|
||||||
.SetMethod("preconnect", &Session::Preconnect)
|
.SetMethod("preconnect", &Session::Preconnect)
|
||||||
.SetProperty("cookies", &Session::Cookies)
|
.SetProperty("cookies", &Session::Cookies)
|
||||||
|
|
|
@ -96,6 +96,7 @@ class Session : public gin_helper::TrackableObject<Session>,
|
||||||
void SetSpellCheckerLanguages(gin_helper::ErrorThrower thrower,
|
void SetSpellCheckerLanguages(gin_helper::ErrorThrower thrower,
|
||||||
const std::vector<std::string>& languages);
|
const std::vector<std::string>& languages);
|
||||||
bool AddWordToSpellCheckerDictionary(const std::string& word);
|
bool AddWordToSpellCheckerDictionary(const std::string& word);
|
||||||
|
bool RemoveWordFromSpellCheckerDictionary(const std::string& word);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue