electron/shell/renderer/renderer_client_base.h

141 lines
5 KiB
C
Raw Normal View History

// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
2019-06-19 20:56:58 +00:00
#ifndef SHELL_RENDERER_RENDERER_CLIENT_BASE_H_
#define SHELL_RENDERER_RENDERER_CLIENT_BASE_H_
#include <memory>
#include <string>
#include <vector>
#include "content/public/renderer/content_renderer_client.h"
#include "electron/buildflags/buildflags.h"
#include "third_party/blink/public/web/web_local_frame.h"
// In SHARED_INTERMEDIATE_DIR.
#include "widevine_cdm_version.h" // NOLINT(build/include)
#if defined(WIDEVINE_CDM_AVAILABLE)
#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 {
chore: bump chromium to f30828899e4cd7161f6dc6507023f (master) (#20824) * chore: bump chromium in DEPS to 0476932294da8809a19189b9f54cee11d50cc512 * update chromium patches (#20838) * chore: bump chromium in DEPS to 838863f5ec9e8a12132a10bb47be8382ad9756a7 * IsRendererTransferNeededForNavigation went away https://chromium-review.googlesource.com/c/chromium/src/+/1867031 * [arraybuffer] Move the ArrayBuffer implementation from wtf to core https://chromium-review.googlesource.com/c/chromium/src/+/1875731 * URLLoaderRequest new mojo types * context menu enums moved around https://chromium-review.googlesource.com/c/chromium/src/+/1872004 https://chromium-review.googlesource.com/c/chromium/src/+/1876088 https://chromium-review.googlesource.com/c/chromium/src/+/1866520 * chore: bump chromium in DEPS to dc9525d251bf30828899e4cd7161f6dc6507023f * update chromium patches * [WIP] Convert network hints IPC to Mojo https://chromium-review.googlesource.com/c/chromium/src/+/1881967 * jumbo build is no longer supported https://chromium-review.googlesource.com/c/chromium/src/+/1881967 * fix disable-color-correct-rendering * [FIXME] fix printing patch compiles but prob doesn't work * explicitly include ax_enums https://chromium-review.googlesource.com/c/chromium/src/+/1759821 * fixup! [WIP] Convert network hints IPC to Mojo * fix base::span * fix AsarURLLoader to not double-std::move * fix debug build * fix msstl patch * lint * more fix msstl * mooooore fix msstl * fix compile * update backport_fix_msstl_compat_in_ui_events.patch * update msstl compat patch * don't try to build chrome's prefetch predictor * build: fix compilation on windows * Fixup patches for MAS build * Free up disk space for mac debug builds * fix: apply custom site instance only for main frame * Fixup from rebase * Try not generating symbols for mac debug builds * Remove double entry of patch * FIx compile errors * Trigger CI * Set symbol_level to 1 for mac debug builds
2019-11-05 23:41:20 +00:00
class WebPrescientNetworkingImpl;
}
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
namespace extensions {
class ExtensionsClient;
}
#endif
namespace electron {
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
class AtomExtensionsRendererClient;
#endif
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
2018-04-18 01:44:10 +00:00
virtual void DidCreateScriptContext(v8::Handle<v8::Context> context,
content::RenderFrame* render_frame);
2018-04-18 01:44:10 +00:00
virtual void WillReleaseScriptContext(v8::Handle<v8::Context> context,
content::RenderFrame* render_frame) = 0;
virtual void DidClearWindowObject(content::RenderFrame* render_frame);
virtual void SetupMainWorldOverrides(v8::Handle<v8::Context> context,
content::RenderFrame* render_frame) = 0;
virtual void SetupExtensionWorldOverrides(v8::Handle<v8::Context> context,
content::RenderFrame* render_frame,
int world_id) = 0;
blink::WebPrescientNetworking* GetPrescientNetworking() override;
bool isolated_world() const { return isolated_world_; }
// Get the context that the Electron API is running in.
2018-04-18 01:44:10 +00:00
v8::Local<v8::Context> GetContext(blink::WebLocalFrame* frame,
v8::Isolate* isolate) const;
// Executes a given v8 Script
2018-11-29 01:55:03 +00:00
static v8::Local<v8::Value> RunScript(v8::Local<v8::Context> context,
v8::Local<v8::String> source);
// v8Util.getHiddenValue(window.frameElement, 'internal')
bool IsWebViewFrame(v8::Handle<v8::Context> context,
content::RenderFrame* render_frame) const;
protected:
void AddRenderBindings(v8::Isolate* isolate,
v8::Local<v8::Object> binding_object);
// content::ContentRendererClient:
void RenderThreadStarted() override;
void RenderFrameCreated(content::RenderFrame*) override;
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
const blink::WebPluginParams& params,
blink::WebPlugin** plugin) override;
void AddSupportedKeySystems(
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems)
override;
bool IsKeySystemsUpdateNeeded() override;
void DidSetUserAgent(const std::string& user_agent) override;
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentIdle(content::RenderFrame* render_frame) override;
protected:
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
// app_shell embedders may need custom extensions client interfaces.
// This class takes ownership of the returned object.
virtual extensions::ExtensionsClient* CreateExtensionsClient();
#endif
private:
chore: bump chromium to f30828899e4cd7161f6dc6507023f (master) (#20824) * chore: bump chromium in DEPS to 0476932294da8809a19189b9f54cee11d50cc512 * update chromium patches (#20838) * chore: bump chromium in DEPS to 838863f5ec9e8a12132a10bb47be8382ad9756a7 * IsRendererTransferNeededForNavigation went away https://chromium-review.googlesource.com/c/chromium/src/+/1867031 * [arraybuffer] Move the ArrayBuffer implementation from wtf to core https://chromium-review.googlesource.com/c/chromium/src/+/1875731 * URLLoaderRequest new mojo types * context menu enums moved around https://chromium-review.googlesource.com/c/chromium/src/+/1872004 https://chromium-review.googlesource.com/c/chromium/src/+/1876088 https://chromium-review.googlesource.com/c/chromium/src/+/1866520 * chore: bump chromium in DEPS to dc9525d251bf30828899e4cd7161f6dc6507023f * update chromium patches * [WIP] Convert network hints IPC to Mojo https://chromium-review.googlesource.com/c/chromium/src/+/1881967 * jumbo build is no longer supported https://chromium-review.googlesource.com/c/chromium/src/+/1881967 * fix disable-color-correct-rendering * [FIXME] fix printing patch compiles but prob doesn't work * explicitly include ax_enums https://chromium-review.googlesource.com/c/chromium/src/+/1759821 * fixup! [WIP] Convert network hints IPC to Mojo * fix base::span * fix AsarURLLoader to not double-std::move * fix debug build * fix msstl patch * lint * more fix msstl * mooooore fix msstl * fix compile * update backport_fix_msstl_compat_in_ui_events.patch * update msstl compat patch * don't try to build chrome's prefetch predictor * build: fix compilation on windows * Fixup patches for MAS build * Free up disk space for mac debug builds * fix: apply custom site instance only for main frame * Fixup from rebase * Try not generating symbols for mac debug builds * Remove double entry of patch * FIx compile errors * Trigger CI * Set symbol_level to 1 for mac debug builds
2019-11-05 23:41:20 +00:00
std::unique_ptr<network_hints::WebPrescientNetworkingImpl>
web_prescient_networking_impl_;
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
std::unique_ptr<AtomExtensionsRendererClient> extensions_renderer_client_;
#endif
#if defined(WIDEVINE_CDM_AVAILABLE)
ChromeKeySystemsProvider key_systems_provider_;
#endif
bool isolated_world_;
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
2019-06-19 20:56:58 +00:00
#endif // SHELL_RENDERER_RENDERER_CLIENT_BASE_H_