0090616f7b
* feat: add a new contextBridge module * chore: fix docs linting * feat: add support for function arguments being proxied * chore: ensure that contextBridge can only be used when contextIsolation is enabled * docs: getReverseBinding can be null * docs: fix broken links in md file * feat: add support for promises in function parameters * fix: linting failure for explicit constructor * Update atom_api_context_bridge.cc * chore: update docs and API design as per feedback * refactor: remove reverse bindings and handle GC'able functions across the bridge * chore: only expose debugGC in testing builds * fix: do not proxy promises as objects * spec: add complete spec coverage for contextBridge * spec: add tests for null/undefined and the anti-overwrite logic * chore: fix linting * spec: add complex nested back-and-forth function calling * fix: expose contextBridge in sandboxed renderers * refactor: improve security of default_app using the new contextBridge module * s/bindAPIInMainWorld/exposeInMainWorld * chore: sorry for this commit, its a big one, I fixed like everything and refactored a lot * chore: remove PassedValueCache as it is unused now Values transferred from context A to context B are now cachde in the RenderFramePersistenceStore * chore: move to anonymous namespace * refactor: remove PassValueToOtherContextWithCache * chore: remove commented unused code blocks * chore: remove .only * chore: remote commented code * refactor: extract RenderFramePersistenceStore * spec: ensure it works with numbered keys * fix: handle number keys correctly * fix: sort out the linter * spec: update default_app asar spec for removed file * refactor: change signatures to return v8 objects directly rather than the mate dictionary handle * refactor: use the v8 serializer to support cloneable buffers and other object types * chore: fix linting * fix: handle hash collisions with a linked list in the map * fix: enforce a recursion limit on the context bridge * chore: fix linting * chore: remove TODO * chore: adapt for PR feedback * chore: remove .only * chore: clean up docs and clean up the proxy map when objects are released * chore: ensure we cache object values that are cloned through the V8 serializer
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// Copyright (c) 2019 Slack Technologies, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef SHELL_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
|
|
#define SHELL_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <tuple>
|
|
|
|
#include "content/public/renderer/render_frame.h"
|
|
#include "content/public/renderer/render_frame_observer.h"
|
|
#include "native_mate/converter.h"
|
|
#include "native_mate/dictionary.h"
|
|
#include "shell/common/node_includes.h"
|
|
#include "shell/renderer/api/context_bridge/render_frame_context_bridge_store.h"
|
|
#include "shell/renderer/atom_render_frame_observer.h"
|
|
#include "third_party/blink/public/web/web_local_frame.h"
|
|
|
|
namespace electron {
|
|
|
|
namespace api {
|
|
|
|
v8::Local<v8::Value> ProxyFunctionWrapper(
|
|
context_bridge::RenderFramePersistenceStore* store,
|
|
size_t func_id,
|
|
mate::Arguments* args);
|
|
|
|
v8::MaybeLocal<v8::Object> CreateProxyForAPI(
|
|
const v8::Local<v8::Object>& api_object,
|
|
const v8::Local<v8::Context>& source_context,
|
|
const v8::Local<v8::Context>& target_context,
|
|
context_bridge::RenderFramePersistenceStore* store,
|
|
int recursion_depth);
|
|
|
|
} // namespace api
|
|
|
|
} // namespace electron
|
|
|
|
#endif // SHELL_RENDERER_API_ATOM_API_CONTEXT_BRIDGE_H_
|