electron/shell/renderer/electron_sandboxed_renderer_client.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.8 KiB
C
Raw Normal View History

// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_
#define ELECTRON_SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_
#include <memory>
#include "shell/renderer/renderer_client_base.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_set.h"
namespace base {
class ProcessMetrics;
}
namespace blink {
class WebLocalFrame;
}
namespace electron {
class ElectronSandboxedRendererClient : public RendererClientBase {
public:
ElectronSandboxedRendererClient();
~ElectronSandboxedRendererClient() override;
// disable copy
ElectronSandboxedRendererClient(const ElectronSandboxedRendererClient&) =
delete;
ElectronSandboxedRendererClient& operator=(
const ElectronSandboxedRendererClient&) = delete;
void InitializeBindings(v8::Local<v8::Object> binding,
refactor: avoid deprecated v8::Context::GetIsolate() calls pt 3 context get isolate pt 3 (#47910) * refactor: add a v8::Isolate* arg to RendererClientBase::IsWebViewFrame() Needed for creating gin dictionaries refactor: add a v8::Isolate* arg to ShouldLoadPreload() Needed for calling IsWebViewFrame() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to electron::util::CompileAndCall() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to OnCreatePreloadableV8Context() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to InvokeEmitProcessEvent() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to ServiceWorkerData's constructor Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to RendererClientBase::SetupMainWorldOverrides() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to RendererClientBase::WilLReleaseScriptContext() Co-authored-by: Charles Kerr <charles@charleskerr.com> * docs: update docs to avoid v8::Context::GetIsolate() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to ElectronSandboxedRendererClient::InitializeBindings() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: avoid v8::Context::GetIsolate() call in PromiseBase::SettleScope::~SettleScope() Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-07-31 14:19:10 -05:00
v8::Isolate* isolate,
v8::Local<v8::Context> context,
content::RenderFrame* render_frame);
// electron::RendererClientBase:
void DidCreateScriptContext(v8::Isolate* isolate,
v8::Local<v8::Context> context,
2018-04-17 21:44:10 -04:00
content::RenderFrame* render_frame) override;
refactor: avoid deprecated v8::Context::GetIsolate() calls pt 3 context get isolate pt 3 (#47910) * refactor: add a v8::Isolate* arg to RendererClientBase::IsWebViewFrame() Needed for creating gin dictionaries refactor: add a v8::Isolate* arg to ShouldLoadPreload() Needed for calling IsWebViewFrame() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to electron::util::CompileAndCall() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to OnCreatePreloadableV8Context() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to InvokeEmitProcessEvent() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to ServiceWorkerData's constructor Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to RendererClientBase::SetupMainWorldOverrides() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to RendererClientBase::WilLReleaseScriptContext() Co-authored-by: Charles Kerr <charles@charleskerr.com> * docs: update docs to avoid v8::Context::GetIsolate() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: add a v8::Isolate* arg to ElectronSandboxedRendererClient::InitializeBindings() Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: avoid v8::Context::GetIsolate() call in PromiseBase::SettleScope::~SettleScope() Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-07-31 14:19:10 -05:00
void WillReleaseScriptContext(v8::Isolate* isolate,
v8::Local<v8::Context> context,
2018-04-17 21:44:10 -04:00
content::RenderFrame* render_frame) override;
// content::ContentRendererClient:
void RenderFrameCreated(content::RenderFrame*) override;
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
void WillEvaluateServiceWorkerOnWorkerThread(
blink::WebServiceWorkerContextProxy* context_proxy,
v8::Local<v8::Context> v8_context,
int64_t service_worker_version_id,
const GURL& service_worker_scope,
const GURL& script_url,
const blink::ServiceWorkerToken& service_worker_token) override;
void WillDestroyServiceWorkerContextOnWorkerThread(
v8::Local<v8::Context> context,
int64_t service_worker_version_id,
const GURL& service_worker_scope,
const GURL& script_url) override;
private:
void EmitProcessEvent(content::RenderFrame* render_frame,
const char* event_name);
std::unique_ptr<base::ProcessMetrics> metrics_;
// Getting main script context from web frame would lazily initializes
// its script context. Doing so in a web page without scripts would trigger
// assertion, so we have to keep a book of injected web frames.
absl::flat_hash_set<content::RenderFrame*> injected_frames_;
};
} // namespace electron
#endif // ELECTRON_SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_