2017-03-27 21:19:34 +00:00
|
|
|
// Copyright (c) 2017 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_RENDERER_RENDERER_CLIENT_BASE_H_
|
|
|
|
#define ATOM_RENDERER_RENDERER_CLIENT_BASE_H_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2018-09-05 21:00:37 +00:00
|
|
|
#include "chrome/renderer/media/chrome_key_systems_provider.h"
|
2017-03-27 21:19:34 +00:00
|
|
|
#include "content/public/renderer/content_renderer_client.h"
|
2018-07-20 16:08:18 +00:00
|
|
|
#include "third_party/blink/public/web/web_local_frame.h"
|
2017-03-27 21:19:34 +00:00
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
class PreferencesManager;
|
|
|
|
|
|
|
|
class RendererClientBase : public content::ContentRendererClient {
|
|
|
|
public:
|
|
|
|
RendererClientBase();
|
2018-04-17 23:03:51 +00:00
|
|
|
~RendererClientBase() override;
|
2017-03-27 21:19:34 +00:00
|
|
|
|
2018-04-18 01:44:10 +00:00
|
|
|
virtual void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
2018-07-19 04:29:47 +00:00
|
|
|
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;
|
2017-04-08 13:43:19 +00:00
|
|
|
virtual void DidClearWindowObject(content::RenderFrame* render_frame);
|
2017-04-08 14:12:18 +00:00
|
|
|
virtual void SetupMainWorldOverrides(v8::Handle<v8::Context> context) = 0;
|
2017-07-28 00:08:24 +00:00
|
|
|
|
2018-05-05 06:39:54 +00:00
|
|
|
bool isolated_world() const { return isolated_world_; }
|
2017-07-28 00:08:24 +00:00
|
|
|
|
|
|
|
// 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,
|
2018-05-05 06:39:54 +00:00
|
|
|
v8::Isolate* isolate) const;
|
2017-04-08 13:43:19 +00:00
|
|
|
|
2017-03-27 21:19:34 +00:00
|
|
|
protected:
|
|
|
|
void AddRenderBindings(v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Object> binding_object);
|
|
|
|
|
|
|
|
// content::ContentRendererClient:
|
|
|
|
void RenderThreadStarted() override;
|
|
|
|
void RenderFrameCreated(content::RenderFrame*) override;
|
|
|
|
void RenderViewCreated(content::RenderView*) override;
|
2017-08-04 17:41:34 +00:00
|
|
|
std::unique_ptr<blink::WebSpeechSynthesizer> OverrideSpeechSynthesizer(
|
2017-03-27 21:19:34 +00:00
|
|
|
blink::WebSpeechSynthesizerClient* client) 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;
|
2018-09-05 21:00:37 +00:00
|
|
|
bool IsKeySystemsUpdateNeeded() override;
|
2017-03-27 21:19:34 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<PreferencesManager> preferences_manager_;
|
2018-09-05 21:00:37 +00:00
|
|
|
ChromeKeySystemsProvider key_systems_provider_;
|
2017-07-28 00:08:24 +00:00
|
|
|
bool isolated_world_;
|
2018-09-11 18:18:10 +00:00
|
|
|
std::string renderer_client_id_;
|
2018-07-24 07:21:38 +00:00
|
|
|
// An increasing ID used for indentifying an V8 context in this process.
|
2018-09-11 18:18:10 +00:00
|
|
|
int64_t next_context_id_ = 0;
|
2017-03-27 21:19:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_RENDERER_RENDERER_CLIENT_BASE_H_
|