build: fix build without built-in spellchecker (#22594)
This commit is contained in:
parent
3ff98e15d0
commit
bf75e5a91f
5 changed files with 30 additions and 7 deletions
|
@ -76,7 +76,6 @@
|
|||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
#include "chrome/browser/spellchecker/spellcheck_factory.h" // nogncheck
|
||||
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" // nogncheck
|
||||
#include "chrome/browser/spellchecker/spellcheck_service.h" // nogncheck
|
||||
#include "components/spellcheck/browser/pref_names.h"
|
||||
#include "components/spellcheck/common/spellcheck_common.h"
|
||||
|
@ -228,6 +227,7 @@ void DestroyGlobalHandle(v8::Isolate* isolate,
|
|||
}
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
class DictionaryObserver final : public SpellcheckCustomDictionary::Observer {
|
||||
private:
|
||||
std::unique_ptr<gin_helper::Promise<std::set<std::string>>> promise_;
|
||||
|
@ -263,6 +263,7 @@ class DictionaryObserver final : public SpellcheckCustomDictionary::Observer {
|
|||
// noop
|
||||
}
|
||||
};
|
||||
#endif // BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -280,22 +281,27 @@ Session::Session(v8::Isolate* isolate, ElectronBrowserContext* browser_context)
|
|||
Init(isolate);
|
||||
AttachAsUserData(browser_context);
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
SpellcheckService* service =
|
||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
||||
if (service) {
|
||||
service->SetHunspellObserver(this);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Session::~Session() {
|
||||
content::BrowserContext::GetDownloadManager(browser_context())
|
||||
->RemoveObserver(this);
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
SpellcheckService* service =
|
||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
||||
if (service) {
|
||||
service->SetHunspellObserver(nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO(zcbenz): Now since URLRequestContextGetter is gone, is this still
|
||||
// needed?
|
||||
// Refs https://github.com/electron/electron/pull/12305.
|
||||
|
@ -324,6 +330,7 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
|
|||
}
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
void Session::OnHunspellDictionaryInitialized(const std::string& language) {
|
||||
Emit("spellcheck-dictionary-initialized", language);
|
||||
}
|
||||
|
@ -336,6 +343,7 @@ void Session::OnHunspellDictionaryDownloadSuccess(const std::string& language) {
|
|||
void Session::OnHunspellDictionaryDownloadFailure(const std::string& language) {
|
||||
Emit("spellcheck-dictionary-download-failure", language);
|
||||
}
|
||||
#endif
|
||||
|
||||
v8::Local<v8::Promise> Session::ResolveProxy(gin_helper::Arguments* args) {
|
||||
v8::Isolate* isolate = args->isolate();
|
||||
|
@ -908,7 +916,7 @@ bool Session::RemoveWordFromSpellCheckerDictionary(const std::string& word) {
|
|||
#endif
|
||||
return service->GetCustomDictionary()->RemoveWord(word);
|
||||
}
|
||||
#endif
|
||||
#endif // BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
|
||||
// static
|
||||
gin::Handle<Session> Session::CreateFrom(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue