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.
|
|
|
|
|
|
|
|
#include "atom/renderer/renderer_client_base.h"
|
|
|
|
|
2018-09-13 00:25:56 +00:00
|
|
|
#include <memory>
|
2017-03-27 21:19:34 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "atom/common/color_util.h"
|
|
|
|
#include "atom/common/native_mate_converters/value_converter.h"
|
|
|
|
#include "atom/common/options_switches.h"
|
2017-05-19 19:35:13 +00:00
|
|
|
#include "atom/renderer/atom_autofill_agent.h"
|
2017-04-08 14:54:58 +00:00
|
|
|
#include "atom/renderer/atom_render_frame_observer.h"
|
2017-03-27 21:19:34 +00:00
|
|
|
#include "atom/renderer/content_settings_observer.h"
|
2019-04-02 22:38:16 +00:00
|
|
|
#include "atom/renderer/electron_api_service_impl.h"
|
2017-03-27 21:19:34 +00:00
|
|
|
#include "atom/renderer/preferences_manager.h"
|
|
|
|
#include "base/command_line.h"
|
|
|
|
#include "base/strings/string_split.h"
|
2018-07-19 04:29:47 +00:00
|
|
|
#include "base/strings/stringprintf.h"
|
2019-04-19 19:55:20 +00:00
|
|
|
#include "content/common/buildflags.h"
|
2017-03-27 21:19:34 +00:00
|
|
|
#include "content/public/common/content_constants.h"
|
2018-09-11 18:18:10 +00:00
|
|
|
#include "content/public/common/content_switches.h"
|
2018-08-16 22:57:40 +00:00
|
|
|
#include "content/public/renderer/render_frame.h"
|
2017-03-27 21:19:34 +00:00
|
|
|
#include "content/public/renderer/render_view.h"
|
2018-10-01 20:00:53 +00:00
|
|
|
#include "electron/buildflags/buildflags.h"
|
2017-03-27 21:19:34 +00:00
|
|
|
#include "native_mate/dictionary.h"
|
2018-10-13 01:57:04 +00:00
|
|
|
#include "printing/buildflags/buildflags.h"
|
2019-04-02 22:38:16 +00:00
|
|
|
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
2018-07-20 16:08:18 +00:00
|
|
|
#include "third_party/blink/public/web/blink.h"
|
|
|
|
#include "third_party/blink/public/web/web_custom_element.h" // NOLINT(build/include_alpha)
|
|
|
|
#include "third_party/blink/public/web/web_frame_widget.h"
|
|
|
|
#include "third_party/blink/public/web/web_plugin_params.h"
|
|
|
|
#include "third_party/blink/public/web/web_script_source.h"
|
|
|
|
#include "third_party/blink/public/web/web_security_policy.h"
|
2019-01-21 20:43:17 +00:00
|
|
|
#include "third_party/blink/public/web/web_view.h"
|
2019-03-05 05:08:55 +00:00
|
|
|
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h" // nogncheck
|
2017-03-27 21:19:34 +00:00
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
#include "base/strings/sys_string_conversions.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include <shlobj.h>
|
|
|
|
#endif
|
|
|
|
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
2018-03-15 08:51:48 +00:00
|
|
|
#include "atom/common/atom_constants.h"
|
2018-10-01 20:00:53 +00:00
|
|
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
2018-03-15 08:51:48 +00:00
|
|
|
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
2018-06-20 00:44:24 +00:00
|
|
|
#include "chrome/renderer/pepper/pepper_helper.h"
|
2018-10-01 20:00:53 +00:00
|
|
|
#endif // BUILDFLAG(ENABLE_PEPPER_FLASH)
|
2018-06-20 00:44:24 +00:00
|
|
|
|
2018-10-11 13:52:12 +00:00
|
|
|
#if BUILDFLAG(ENABLE_TTS)
|
|
|
|
#include "chrome/renderer/tts_dispatcher.h"
|
|
|
|
#endif // BUILDFLAG(ENABLE_TTS)
|
|
|
|
|
2018-10-13 01:57:04 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
2018-11-09 03:42:34 +00:00
|
|
|
#include "atom/renderer/printing/print_render_frame_helper_delegate.h"
|
2018-10-13 01:57:04 +00:00
|
|
|
#include "components/printing/renderer/print_render_frame_helper.h"
|
2019-01-22 07:24:36 +00:00
|
|
|
#include "printing/print_settings.h"
|
2018-10-13 01:57:04 +00:00
|
|
|
#endif // BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
|
2017-03-27 21:19:34 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
v8::Local<v8::Value> GetRenderProcessPreferences(
|
2018-04-18 01:55:30 +00:00
|
|
|
const PreferencesManager* preferences_manager,
|
|
|
|
v8::Isolate* isolate) {
|
2017-03-27 21:19:34 +00:00
|
|
|
if (preferences_manager->preferences())
|
|
|
|
return mate::ConvertToV8(isolate, *preferences_manager->preferences());
|
|
|
|
else
|
|
|
|
return v8::Null(isolate);
|
|
|
|
}
|
|
|
|
|
2018-09-11 18:18:10 +00:00
|
|
|
std::vector<std::string> ParseSchemesCLISwitch(base::CommandLine* command_line,
|
|
|
|
const char* switch_name) {
|
2017-03-27 21:19:34 +00:00
|
|
|
std::string custom_schemes = command_line->GetSwitchValueASCII(switch_name);
|
2018-04-18 01:55:30 +00:00
|
|
|
return base::SplitString(custom_schemes, ",", base::TRIM_WHITESPACE,
|
|
|
|
base::SPLIT_WANT_NONEMPTY);
|
2017-03-27 21:19:34 +00:00
|
|
|
}
|
|
|
|
|
2018-10-13 17:50:07 +00:00
|
|
|
void SetHiddenValue(v8::Handle<v8::Context> context,
|
|
|
|
const base::StringPiece& key,
|
|
|
|
v8::Local<v8::Value> value) {
|
|
|
|
v8::Isolate* isolate = context->GetIsolate();
|
|
|
|
v8::Local<v8::Private> privateKey =
|
|
|
|
v8::Private::ForApi(isolate, mate::StringToV8(isolate, key));
|
|
|
|
context->Global()->SetPrivate(context, privateKey, value);
|
|
|
|
}
|
|
|
|
|
2017-03-27 21:19:34 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
RendererClientBase::RendererClientBase() {
|
2018-09-11 18:18:10 +00:00
|
|
|
auto* command_line = base::CommandLine::ForCurrentProcess();
|
2017-03-27 21:19:34 +00:00
|
|
|
// Parse --standard-schemes=scheme1,scheme2
|
|
|
|
std::vector<std::string> standard_schemes_list =
|
2018-09-11 18:18:10 +00:00
|
|
|
ParseSchemesCLISwitch(command_line, switches::kStandardSchemes);
|
2017-03-27 21:19:34 +00:00
|
|
|
for (const std::string& scheme : standard_schemes_list)
|
2018-07-21 15:40:06 +00:00
|
|
|
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITH_HOST);
|
2018-04-18 01:55:30 +00:00
|
|
|
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
|
|
|
switches::kContextIsolation);
|
2018-09-11 18:18:10 +00:00
|
|
|
// We rely on the unique process host id which is notified to the
|
|
|
|
// renderer process via command line switch from the content layer,
|
|
|
|
// if this switch is removed from the content layer for some reason,
|
|
|
|
// we should define our own.
|
|
|
|
DCHECK(command_line->HasSwitch(::switches::kRendererClientId));
|
|
|
|
renderer_client_id_ =
|
|
|
|
command_line->GetSwitchValueASCII(::switches::kRendererClientId);
|
2017-03-27 21:19:34 +00:00
|
|
|
}
|
|
|
|
|
2018-04-18 01:55:30 +00:00
|
|
|
RendererClientBase::~RendererClientBase() {}
|
2017-03-27 21:19:34 +00:00
|
|
|
|
2018-07-19 04:29:47 +00:00
|
|
|
void RendererClientBase::DidCreateScriptContext(
|
|
|
|
v8::Handle<v8::Context> context,
|
|
|
|
content::RenderFrame* render_frame) {
|
2018-09-11 18:18:10 +00:00
|
|
|
// global.setHidden("contextId", `${processHostId}-${++next_context_id_}`)
|
|
|
|
auto context_id = base::StringPrintf(
|
|
|
|
"%s-%" PRId64, renderer_client_id_.c_str(), ++next_context_id_);
|
2018-07-19 04:29:47 +00:00
|
|
|
v8::Isolate* isolate = context->GetIsolate();
|
2018-10-13 17:50:07 +00:00
|
|
|
SetHiddenValue(context, "contextId", mate::ConvertToV8(isolate, context_id));
|
|
|
|
|
|
|
|
auto* command_line = base::CommandLine::ForCurrentProcess();
|
|
|
|
bool enableRemoteModule =
|
|
|
|
!command_line->HasSwitch(switches::kDisableRemoteModule);
|
|
|
|
SetHiddenValue(context, "enableRemoteModule",
|
|
|
|
mate::ConvertToV8(isolate, enableRemoteModule));
|
2018-07-19 04:29:47 +00:00
|
|
|
}
|
|
|
|
|
2017-03-27 21:19:34 +00:00
|
|
|
void RendererClientBase::AddRenderBindings(
|
|
|
|
v8::Isolate* isolate,
|
|
|
|
v8::Local<v8::Object> binding_object) {
|
|
|
|
mate::Dictionary dict(isolate, binding_object);
|
2019-04-30 00:40:39 +00:00
|
|
|
dict.SetMethod("getRenderProcessPreferences",
|
|
|
|
base::BindRepeating(GetRenderProcessPreferences,
|
|
|
|
preferences_manager_.get()));
|
2017-03-27 21:19:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RendererClientBase::RenderThreadStarted() {
|
2018-09-11 18:18:10 +00:00
|
|
|
auto* command_line = base::CommandLine::ForCurrentProcess();
|
|
|
|
|
2019-04-19 19:55:20 +00:00
|
|
|
#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
|
|
|
|
// On macOS, popup menus are rendered by the main process by default.
|
|
|
|
// This causes problems in OSR, since when the popup is rendered separately,
|
|
|
|
// it won't be captured in the rendered image.
|
|
|
|
if (command_line->HasSwitch(options::kOffscreen)) {
|
|
|
|
blink::WebView::SetUseExternalPopupMenus(false);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-06-16 20:42:33 +00:00
|
|
|
blink::WebCustomElement::AddEmbedderCustomElementName("webview");
|
|
|
|
blink::WebCustomElement::AddEmbedderCustomElementName("browserplugin");
|
2017-03-27 21:19:34 +00:00
|
|
|
|
2017-09-15 07:48:55 +00:00
|
|
|
WTF::String extension_scheme("chrome-extension");
|
|
|
|
// Extension resources are HTTP-like and safe to expose to the fetch API. The
|
|
|
|
// rules for the fetch API are consistent with XHR.
|
|
|
|
blink::SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI(
|
|
|
|
extension_scheme);
|
|
|
|
// Extension resources, when loaded as the top-level document, should bypass
|
|
|
|
// Blink's strict first-party origin checks.
|
|
|
|
blink::SchemeRegistry::RegisterURLSchemeAsFirstPartyWhenTopLevel(
|
|
|
|
extension_scheme);
|
|
|
|
// In Chrome we should set extension's origins to match the pages they can
|
|
|
|
// work on, but in Electron currently we just let extensions do anything.
|
|
|
|
blink::SchemeRegistry::RegisterURLSchemeAsSecure(extension_scheme);
|
|
|
|
blink::SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(
|
|
|
|
extension_scheme);
|
|
|
|
|
2017-04-20 08:44:25 +00:00
|
|
|
// Parse --secure-schemes=scheme1,scheme2
|
|
|
|
std::vector<std::string> secure_schemes_list =
|
2018-09-11 18:18:10 +00:00
|
|
|
ParseSchemesCLISwitch(command_line, switches::kSecureSchemes);
|
2017-04-20 08:44:25 +00:00
|
|
|
for (const std::string& scheme : secure_schemes_list)
|
2017-06-16 20:42:33 +00:00
|
|
|
blink::SchemeRegistry::RegisterURLSchemeAsSecure(
|
|
|
|
WTF::String::FromUTF8(scheme.data(), scheme.length()));
|
2017-04-20 08:44:25 +00:00
|
|
|
|
2019-01-29 07:11:01 +00:00
|
|
|
std::vector<std::string> fetch_enabled_schemes =
|
|
|
|
ParseSchemesCLISwitch(command_line, switches::kFetchSchemes);
|
|
|
|
for (const std::string& scheme : fetch_enabled_schemes) {
|
|
|
|
blink::WebSecurityPolicy::RegisterURLSchemeAsSupportingFetchAPI(
|
|
|
|
blink::WebString::FromASCII(scheme));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> service_worker_schemes =
|
|
|
|
ParseSchemesCLISwitch(command_line, switches::kServiceWorkerSchemes);
|
|
|
|
for (const std::string& scheme : service_worker_schemes)
|
|
|
|
blink::WebSecurityPolicy::RegisterURLSchemeAsAllowingServiceWorkers(
|
|
|
|
blink::WebString::FromASCII(scheme));
|
|
|
|
|
|
|
|
std::vector<std::string> csp_bypassing_schemes =
|
|
|
|
ParseSchemesCLISwitch(command_line, switches::kBypassCSPSchemes);
|
|
|
|
for (const std::string& scheme : csp_bypassing_schemes)
|
|
|
|
blink::SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy(
|
|
|
|
WTF::String::FromUTF8(scheme.data(), scheme.length()));
|
|
|
|
|
2017-12-17 20:56:53 +00:00
|
|
|
// Allow file scheme to handle service worker by default.
|
|
|
|
// FIXME(zcbenz): Can this be moved elsewhere?
|
|
|
|
blink::WebSecurityPolicy::RegisterURLSchemeAsAllowingServiceWorkers("file");
|
2017-12-18 09:29:28 +00:00
|
|
|
blink::SchemeRegistry::RegisterURLSchemeAsSupportingFetchAPI("file");
|
2017-12-17 20:56:53 +00:00
|
|
|
|
2017-03-27 21:19:34 +00:00
|
|
|
preferences_manager_.reset(new PreferencesManager);
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
// Set ApplicationUserModelID in renderer process.
|
|
|
|
base::string16 app_id =
|
|
|
|
command_line->GetSwitchValueNative(switches::kAppUserModelId);
|
|
|
|
if (!app_id.empty()) {
|
|
|
|
SetCurrentProcessExplicitAppUserModelID(app_id.c_str());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void RendererClientBase::RenderFrameCreated(
|
|
|
|
content::RenderFrame* render_frame) {
|
2018-04-05 00:53:51 +00:00
|
|
|
#if defined(TOOLKIT_VIEWS)
|
2017-05-19 19:35:13 +00:00
|
|
|
new AutofillAgent(render_frame);
|
2018-04-05 00:53:51 +00:00
|
|
|
#endif
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PEPPER_FLASH)
|
2017-03-27 21:19:34 +00:00
|
|
|
new PepperHelper(render_frame);
|
2018-06-20 00:44:24 +00:00
|
|
|
#endif
|
2017-03-27 21:19:34 +00:00
|
|
|
new ContentSettingsObserver(render_frame);
|
2018-10-13 01:57:04 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
new printing::PrintRenderFrameHelper(
|
2018-11-09 03:42:34 +00:00
|
|
|
render_frame, std::make_unique<atom::PrintRenderFrameHelperDelegate>());
|
2018-10-13 01:57:04 +00:00
|
|
|
#endif
|
2017-03-27 21:19:34 +00:00
|
|
|
|
2019-04-02 22:38:16 +00:00
|
|
|
// TODO(nornagon): it might be possible for an IPC message sent to this
|
|
|
|
// service to trigger v8 context creation before the page has begun loading.
|
|
|
|
// However, it's unclear whether such a timing is possible to trigger, and we
|
|
|
|
// don't have any test to confirm it. Add a test that confirms that a
|
|
|
|
// main->renderer IPC can't cause the preload script to be executed twice. If
|
|
|
|
// it is possible to trigger the preload script before the document is ready
|
|
|
|
// through this interface, we should delay adding it to the registry until
|
|
|
|
// the document is ready.
|
|
|
|
render_frame->GetAssociatedInterfaceRegistry()->AddInterface(
|
|
|
|
base::BindRepeating(&ElectronApiServiceImpl::CreateMojoService,
|
|
|
|
render_frame, this));
|
|
|
|
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
2017-03-27 21:19:34 +00:00
|
|
|
// Allow access to file scheme from pdf viewer.
|
2017-06-16 20:42:33 +00:00
|
|
|
blink::WebSecurityPolicy::AddOriginAccessWhitelistEntry(
|
2017-03-27 21:19:34 +00:00
|
|
|
GURL(kPdfViewerUIOrigin), "file", "", true);
|
2018-10-01 20:00:53 +00:00
|
|
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
2018-10-14 17:59:47 +00:00
|
|
|
|
|
|
|
content::RenderView* render_view = render_frame->GetRenderView();
|
|
|
|
if (render_frame->IsMainFrame() && render_view) {
|
2019-01-21 20:43:17 +00:00
|
|
|
blink::WebView* webview = render_view->GetWebView();
|
|
|
|
if (webview) {
|
2018-10-14 17:59:47 +00:00
|
|
|
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
|
|
|
|
if (cmd->HasSwitch(switches::kGuestInstanceID)) { // webview.
|
2019-01-21 20:43:17 +00:00
|
|
|
webview->SetBaseBackgroundColor(SK_ColorTRANSPARENT);
|
2018-10-14 17:59:47 +00:00
|
|
|
} else { // normal window.
|
|
|
|
std::string name = cmd->GetSwitchValueASCII(switches::kBackgroundColor);
|
|
|
|
SkColor color =
|
|
|
|
name.empty() ? SK_ColorTRANSPARENT : ParseHexColor(name);
|
2019-01-21 20:43:17 +00:00
|
|
|
webview->SetBaseBackgroundColor(color);
|
2018-10-14 17:59:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-27 21:19:34 +00:00
|
|
|
}
|
|
|
|
|
2017-04-08 13:43:19 +00:00
|
|
|
void RendererClientBase::DidClearWindowObject(
|
|
|
|
content::RenderFrame* render_frame) {
|
|
|
|
// Make sure every page will get a script context created.
|
2017-06-16 20:42:33 +00:00
|
|
|
render_frame->GetWebFrame()->ExecuteScript(blink::WebScriptSource("void 0"));
|
2017-04-08 13:43:19 +00:00
|
|
|
}
|
|
|
|
|
2017-08-04 17:41:34 +00:00
|
|
|
std::unique_ptr<blink::WebSpeechSynthesizer>
|
|
|
|
RendererClientBase::OverrideSpeechSynthesizer(
|
2017-03-27 21:19:34 +00:00
|
|
|
blink::WebSpeechSynthesizerClient* client) {
|
2018-10-11 13:52:12 +00:00
|
|
|
#if BUILDFLAG(ENABLE_TTS)
|
2018-04-12 12:48:32 +00:00
|
|
|
return std::make_unique<TtsDispatcher>(client);
|
2018-10-11 13:52:12 +00:00
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
2017-03-27 21:19:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RendererClientBase::OverrideCreatePlugin(
|
|
|
|
content::RenderFrame* render_frame,
|
|
|
|
const blink::WebPluginParams& params,
|
|
|
|
blink::WebPlugin** plugin) {
|
|
|
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
2017-06-16 20:42:33 +00:00
|
|
|
if (params.mime_type.Utf8() == content::kBrowserPluginMimeType ||
|
2018-10-01 20:00:53 +00:00
|
|
|
#if BUILDFLAG(ENABLE_PDF_VIEWER)
|
2017-06-16 20:42:33 +00:00
|
|
|
params.mime_type.Utf8() == kPdfPluginMimeType ||
|
2018-10-01 20:00:53 +00:00
|
|
|
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
2017-03-27 21:19:34 +00:00
|
|
|
command_line->HasSwitch(switches::kEnablePlugins))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
*plugin = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RendererClientBase::AddSupportedKeySystems(
|
|
|
|
std::vector<std::unique_ptr<::media::KeySystemProperties>>* key_systems) {
|
2018-09-09 20:14:16 +00:00
|
|
|
#if defined(WIDEVINE_CDM_AVAILABLE)
|
2018-09-05 21:00:37 +00:00
|
|
|
key_systems_provider_.AddSupportedKeySystems(key_systems);
|
2018-09-09 20:14:16 +00:00
|
|
|
#endif
|
2018-09-05 21:00:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RendererClientBase::IsKeySystemsUpdateNeeded() {
|
2018-09-09 20:14:16 +00:00
|
|
|
#if defined(WIDEVINE_CDM_AVAILABLE)
|
2018-09-05 21:00:37 +00:00
|
|
|
return key_systems_provider_.IsKeySystemsUpdateNeeded();
|
2018-09-09 20:14:16 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2017-03-27 21:19:34 +00:00
|
|
|
}
|
|
|
|
|
2019-01-22 07:24:36 +00:00
|
|
|
void RendererClientBase::DidSetUserAgent(const std::string& user_agent) {
|
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
|
|
|
printing::SetAgent(user_agent);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-07-28 00:08:24 +00:00
|
|
|
v8::Local<v8::Context> RendererClientBase::GetContext(
|
2018-04-18 01:55:30 +00:00
|
|
|
blink::WebLocalFrame* frame,
|
2018-05-05 06:39:54 +00:00
|
|
|
v8::Isolate* isolate) const {
|
2017-08-09 00:10:44 +00:00
|
|
|
if (isolated_world())
|
2017-08-24 21:31:25 +00:00
|
|
|
return frame->WorldScriptContext(isolate, World::ISOLATED_WORLD);
|
2017-08-09 00:10:44 +00:00
|
|
|
else
|
2017-08-24 21:31:25 +00:00
|
|
|
return frame->MainWorldScriptContext();
|
2017-07-28 00:08:24 +00:00
|
|
|
}
|
|
|
|
|
2018-11-29 01:55:03 +00:00
|
|
|
v8::Local<v8::Value> RendererClientBase::RunScript(
|
|
|
|
v8::Local<v8::Context> context,
|
|
|
|
v8::Local<v8::String> source) {
|
2018-10-25 15:29:13 +00:00
|
|
|
auto maybe_script = v8::Script::Compile(context, source);
|
|
|
|
v8::Local<v8::Script> script;
|
|
|
|
if (!maybe_script.ToLocal(&script))
|
|
|
|
return v8::Local<v8::Value>();
|
|
|
|
return script->Run(context).ToLocalChecked();
|
|
|
|
}
|
|
|
|
|
2017-03-27 21:19:34 +00:00
|
|
|
} // namespace atom
|