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.
|
2020-02-04 20:19:40 +00:00
|
|
|
#ifndef SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_
|
|
|
|
#define 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>
|
|
|
|
#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
|
|
|
|
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
|
|
|
|
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;
|
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;
|
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;
|
2020-02-21 19:08:26 +00:00
|
|
|
bool ShouldFork(blink::WebLocalFrame* frame,
|
|
|
|
const GURL& url,
|
|
|
|
const std::string& http_method,
|
|
|
|
bool is_server_redirect) 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_;
|
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(ElectronSandboxedRendererClient);
|
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
|
|
|
|
2020-02-04 20:19:40 +00:00
|
|
|
#endif // SHELL_RENDERER_ELECTRON_SANDBOXED_RENDERER_CLIENT_H_
|