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.
|
2019-06-19 20:56:58 +00:00
|
|
|
#ifndef SHELL_RENDERER_ATOM_SANDBOXED_RENDERER_CLIENT_H_
|
|
|
|
#define SHELL_RENDERER_ATOM_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>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-08-21 18:05:45 +00:00
|
|
|
#include "base/process/process_metrics.h"
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/renderer/renderer_client_base.h"
|
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
|
|
|
|
2017-03-27 21:31:18 +00:00
|
|
|
class AtomSandboxedRendererClient : public RendererClientBase {
|
2016-08-19 11:47:32 +00:00
|
|
|
public:
|
|
|
|
AtomSandboxedRendererClient();
|
2018-04-17 23:03:51 +00:00
|
|
|
~AtomSandboxedRendererClient() override;
|
2016-08-19 11:47:32 +00:00
|
|
|
|
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,
|
|
|
|
bool is_main_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;
|
2018-12-13 21:25:12 +00:00
|
|
|
void SetupMainWorldOverrides(v8::Handle<v8::Context> context,
|
2019-01-22 01:08:16 +00:00
|
|
|
content::RenderFrame* render_frame) override;
|
2019-03-11 23:27:57 +00:00
|
|
|
void SetupExtensionWorldOverrides(v8::Handle<v8::Context> context,
|
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
int world_id) override;
|
2016-08-21 10:30:21 +00:00
|
|
|
// content::ContentRendererClient:
|
|
|
|
void RenderFrameCreated(content::RenderFrame*) override;
|
|
|
|
void RenderViewCreated(content::RenderView*) 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
|
|
|
DISALLOW_COPY_AND_ASSIGN(AtomSandboxedRendererClient);
|
|
|
|
};
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|
2016-08-19 11:47:32 +00:00
|
|
|
|
2019-06-19 20:56:58 +00:00
|
|
|
#endif // SHELL_RENDERER_ATOM_SANDBOXED_RENDERER_CLIENT_H_
|