build: fix build without built-in spellchecker (#22608)

This commit is contained in:
Alexey Kuzmin
2020-03-10 08:59:51 +01:00
committed by GitHub
parent 647299fa9f
commit a0431e1265
2 changed files with 20 additions and 7 deletions

View File

@@ -71,9 +71,8 @@
#endif
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" // nogncheck
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "chrome/browser/spellchecker/spellcheck_factory.h" // nogncheck
#include "chrome/browser/spellchecker/spellcheck_service.h" // nogncheck
#include "components/spellcheck/browser/pref_names.h"
#include "components/spellcheck/common/spellcheck_common.h"
@@ -238,22 +237,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.
@@ -282,6 +286,7 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
}
}
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
void Session::OnHunspellDictionaryInitialized(const std::string& language) {
Emit("spellcheck-dictionary-initialized", language);
}
@@ -294,6 +299,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(mate::Arguments* args) {
v8::Isolate* isolate = args->isolate();
@@ -754,7 +760,7 @@ bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
return spellcheck->GetCustomDictionary()->AddWord(word);
}
#endif
#endif // BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
// static
mate::Handle<Session> Session::CreateFrom(

View File

@@ -9,7 +9,6 @@
#include <vector>
#include "base/values.h"
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
#include "content/public/browser/download_manager.h"
#include "electron/buildflags/buildflags.h"
#include "native_mate/handle.h"
@@ -17,6 +16,10 @@
#include "shell/browser/net/resolve_proxy_helper.h"
#include "shell/common/promise_util.h"
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
#include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" // nogncheck
#endif
class GURL;
namespace base {
@@ -39,8 +42,10 @@ class ElectronBrowserContext;
namespace api {
class Session : public mate::TrackableObject<Session>,
public content::DownloadManager::Observer,
public SpellcheckHunspellDictionary::Observer {
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
public SpellcheckHunspellDictionary::Observer,
#endif
public content::DownloadManager::Observer {
public:
// Gets or creates Session from the |browser_context|.
static mate::Handle<Session> CreateFrom(
@@ -111,6 +116,7 @@ class Session : public mate::TrackableObject<Session>,
void OnDownloadCreated(content::DownloadManager* manager,
download::DownloadItem* item) override;
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
// SpellcheckHunspellDictionary::Observer
void OnHunspellDictionaryInitialized(const std::string& language) override;
void OnHunspellDictionaryDownloadBegin(const std::string& language) override;
@@ -118,6 +124,7 @@ class Session : public mate::TrackableObject<Session>,
const std::string& language) override;
void OnHunspellDictionaryDownloadFailure(
const std::string& language) override;
#endif
private:
// Cached mate::Wrappable objects.