2016-08-19 11:47:32 +00:00
|
|
|
// Copyright (c) 2016 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_
|
|
|
|
#define ELECTRON_SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_
|
2016-08-19 11:47:32 +00:00
|
|
|
|
2018-09-13 00:25:56 +00:00
|
|
|
#include <memory>
|
2019-03-08 00:00:28 +00:00
|
|
|
#include <set>
|
2016-08-21 10:30:21 +00:00
|
|
|
#include <string>
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/renderer/renderer_client_base.h"
|
2016-08-19 11:47:32 +00:00
|
|
|
|
2021-07-02 00:51:37 +00:00
|
|
|
namespace base {
|
|
|
|
class ProcessMetrics;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace blink {
|
|
|
|
class WebLocalFrame;
|
|
|
|
}
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2016-08-19 11:47:32 +00:00
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
class ElectronSandboxedRendererClient : public RendererClientBase {
|
2016-08-19 11:47:32 +00:00
|
|
|
public:
|
2020-02-04 20:19:40 +00:00
|
|
|
ElectronSandboxedRendererClient();
|
|
|
|
~ElectronSandboxedRendererClient() override;
|
2016-08-19 11:47:32 +00:00
|
|
|
|
2021-11-03 11:41:45 +00:00
|
|
|
// disable copy
|
|
|
|
ElectronSandboxedRendererClient(const ElectronSandboxedRendererClient&) =
|
|
|
|
delete;
|
|
|
|
ElectronSandboxedRendererClient& operator=(
|
|
|
|
const ElectronSandboxedRendererClient&) = delete;
|
|
|
|
|
2018-08-21 18:05:45 +00:00
|
|
|
void InitializeBindings(v8::Local<v8::Object> binding,
|
2019-01-22 19:24:46 +00:00
|
|
|
v8::Local<v8::Context> context,
|
2021-03-17 18:23:29 +00:00
|
|
|
content::RenderFrame* render_frame);
|
2019-06-19 21:23:04 +00:00
|
|
|
// electron::RendererClientBase:
|
2018-04-18 01:44:10 +00:00
|
|
|
void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
|
|
|
content::RenderFrame* render_frame) override;
|
|
|
|
void WillReleaseScriptContext(v8::Handle<v8::Context> context,
|
|
|
|
content::RenderFrame* render_frame) override;
|
2016-08-21 10:30:21 +00:00
|
|
|
// content::ContentRendererClient:
|
|
|
|
void RenderFrameCreated(content::RenderFrame*) override;
|
2019-03-08 00:00:28 +00:00
|
|
|
void RunScriptsAtDocumentStart(content::RenderFrame* render_frame) override;
|
|
|
|
void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame) override;
|
2016-08-21 10:30:21 +00:00
|
|
|
|
2016-08-19 11:47:32 +00:00
|
|
|
private:
|
2018-08-21 18:05:45 +00:00
|
|
|
std::unique_ptr<base::ProcessMetrics> metrics_;
|
|
|
|
|
2019-03-08 00:00:28 +00:00
|
|
|
// 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.
|
|
|
|
std::set<content::RenderFrame*> injected_frames_;
|
2016-08-19 11:47:32 +00:00
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2016-08-19 11:47:32 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_
|