feat: enable builtin spellchecker (#20692)
* chore: add code required to use chromes spellchecker * chore: fix linting * chore: manifests needs buildflags now * chore: add dictionarySuggestions to the context menu event when the spellchecker is active * chore: enable by default for windows builds * chore: add patch to remove incognito usage in the spellchecker * chore: add dependencies on spellcheck common and flags * chore: conditionally include spell check panel impl * chore: fix deps for spellcheck feature flags * chore: add patch for electron resources * chore: add dependency on //components/language/core/browser * chore: patches to make hunspell work on windows * build: collect hunspell dictionaries into a zip file and publish * chore: clean up patches * chore: add docs and set spell checker url method * chore: fix error handling * chore: fix hash logic * build: update hunspell filename generator * fix: default spellchecker list to the current system locale if we can * docs: document the language getter * chore: patch IDS_ resources for linux builds * feat: add spellcheck webpref flag to disable the builtin spellchecker * chore: fix docs typo * chore: clean up spellchecker impl as per feedback * remove unneeded deps
This commit is contained in:
parent
23ca7e3733
commit
6bcf67e051
34 changed files with 560 additions and 10 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
|
@ -45,6 +46,11 @@
|
|||
#include <shlobj.h>
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
#include "components/spellcheck/renderer/spellcheck.h"
|
||||
#include "components/spellcheck/renderer/spellcheck_provider.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
#include "shell/common/atom_constants.h"
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
@ -148,6 +154,11 @@ void RendererClientBase::RenderThreadStarted() {
|
|||
thread->AddObserver(extensions_renderer_client_->GetDispatcher());
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
if (command_line->HasSwitch(switches::kEnableSpellcheck))
|
||||
spellcheck_ = std::make_unique<SpellCheck>(®istry_, this);
|
||||
#endif
|
||||
|
||||
blink::WebCustomElement::AddEmbedderCustomElementName("webview");
|
||||
blink::WebCustomElement::AddEmbedderCustomElementName("browserplugin");
|
||||
|
||||
|
@ -262,8 +273,37 @@ void RendererClientBase::RenderFrameCreated(
|
|||
|
||||
dispatcher->OnRenderFrameCreated(render_frame);
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kEnableSpellcheck))
|
||||
new SpellCheckProvider(render_frame, spellcheck_.get(), this);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
void RendererClientBase::BindReceiverOnMainThread(
|
||||
mojo::GenericPendingReceiver receiver) {
|
||||
// TODO(crbug.com/977637): Get rid of the use of BinderRegistry here. This is
|
||||
// only used to bind a spellcheck interface.
|
||||
std::string interface_name = *receiver.interface_name();
|
||||
auto pipe = receiver.PassPipe();
|
||||
registry_.TryBindInterface(interface_name, &pipe);
|
||||
}
|
||||
|
||||
void RendererClientBase::GetInterface(
|
||||
const std::string& interface_name,
|
||||
mojo::ScopedMessagePipeHandle interface_pipe) {
|
||||
// TODO(crbug.com/977637): Get rid of the use of this implementation of
|
||||
// |service_manager::LocalInterfaceProvider|. This was done only to avoid
|
||||
// churning spellcheck code while eliminating the "chrome" and
|
||||
// "chrome_renderer" services. Spellcheck is (and should remain) the only
|
||||
// consumer of this implementation.
|
||||
content::RenderThread::Get()->BindHostReceiver(
|
||||
mojo::GenericPendingReceiver(interface_name, std::move(interface_pipe)));
|
||||
}
|
||||
#endif
|
||||
|
||||
void RendererClientBase::DidClearWindowObject(
|
||||
content::RenderFrame* render_frame) {
|
||||
// Make sure every page will get a script context created.
|
||||
|
|
|
@ -19,6 +19,13 @@
|
|||
#include "chrome/renderer/media/chrome_key_systems_provider.h" // nogncheck
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
#include "services/service_manager/public/cpp/binder_registry.h"
|
||||
#include "services/service_manager/public/cpp/local_interface_provider.h"
|
||||
|
||||
class SpellCheck;
|
||||
#endif
|
||||
|
||||
namespace network_hints {
|
||||
class PrescientNetworkingDispatcher;
|
||||
}
|
||||
|
@ -35,11 +42,24 @@ namespace electron {
|
|||
class AtomExtensionsRendererClient;
|
||||
#endif
|
||||
|
||||
class RendererClientBase : public content::ContentRendererClient {
|
||||
class RendererClientBase : public content::ContentRendererClient
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
,
|
||||
public service_manager::LocalInterfaceProvider
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
RendererClientBase();
|
||||
~RendererClientBase() override;
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
// service_manager::LocalInterfaceProvider implementation.
|
||||
void GetInterface(const std::string& name,
|
||||
mojo::ScopedMessagePipeHandle request_handle) override;
|
||||
|
||||
void BindReceiverOnMainThread(mojo::GenericPendingReceiver receiver) override;
|
||||
#endif
|
||||
|
||||
virtual void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
||||
content::RenderFrame* render_frame);
|
||||
virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context,
|
||||
|
@ -108,6 +128,11 @@ class RendererClientBase : public content::ContentRendererClient {
|
|||
std::string renderer_client_id_;
|
||||
// An increasing ID used for indentifying an V8 context in this process.
|
||||
int64_t next_context_id_ = 0;
|
||||
|
||||
#if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER)
|
||||
std::unique_ptr<SpellCheck> spellcheck_;
|
||||
service_manager::BinderRegistry registry_;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue