Merge remote-tracking branch 'origin/master' into roller/chromium/master
This commit is contained in:
commit
39e3576c48
68 changed files with 578 additions and 182 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
|
@ -25,6 +26,12 @@
|
|||
#include "third_party/blink/public/web/web_element.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
|
||||
namespace features {
|
||||
|
||||
const base::Feature kContextBridgeMutability{"ContextBridgeMutability",
|
||||
base::FEATURE_DISABLED_BY_DEFAULT};
|
||||
}
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
@ -554,6 +561,12 @@ void ExposeAPIInMainWorld(v8::Isolate* isolate,
|
|||
if (maybe_proxy.IsEmpty())
|
||||
return;
|
||||
auto proxy = maybe_proxy.ToLocalChecked();
|
||||
|
||||
if (base::FeatureList::IsEnabled(features::kContextBridgeMutability)) {
|
||||
global.Set(key, proxy);
|
||||
return;
|
||||
}
|
||||
|
||||
if (proxy->IsObject() && !proxy->IsTypedArray() &&
|
||||
!DeepFreeze(v8::Local<v8::Object>::Cast(proxy), main_context))
|
||||
return;
|
||||
|
|
|
@ -146,9 +146,8 @@ void ElectronRendererClient::DidCreateScriptContext(
|
|||
|
||||
// Add Electron extended APIs.
|
||||
electron_bindings_->BindTo(env->isolate(), env->process_object());
|
||||
AddRenderBindings(env->isolate(), env->process_object());
|
||||
gin_helper::Dictionary process_dict(env->isolate(), env->process_object());
|
||||
process_dict.SetReadOnly("isMainFrame", render_frame->IsMainFrame());
|
||||
BindProcess(env->isolate(), &process_dict, render_frame);
|
||||
|
||||
// Load everything.
|
||||
node_bindings_->LoadEnvironment(env);
|
||||
|
|
|
@ -131,7 +131,7 @@ ElectronSandboxedRendererClient::~ElectronSandboxedRendererClient() = default;
|
|||
void ElectronSandboxedRendererClient::InitializeBindings(
|
||||
v8::Local<v8::Object> binding,
|
||||
v8::Local<v8::Context> context,
|
||||
bool is_main_frame) {
|
||||
content::RenderFrame* render_frame) {
|
||||
auto* isolate = context->GetIsolate();
|
||||
gin_helper::Dictionary b(isolate, binding);
|
||||
b.SetMethod("get", GetBinding);
|
||||
|
@ -141,13 +141,13 @@ void ElectronSandboxedRendererClient::InitializeBindings(
|
|||
b.Set("process", process);
|
||||
|
||||
ElectronBindings::BindProcess(isolate, &process, metrics_.get());
|
||||
BindProcess(isolate, &process, render_frame);
|
||||
|
||||
process.SetMethod("uptime", Uptime);
|
||||
process.Set("argv", base::CommandLine::ForCurrentProcess()->argv());
|
||||
process.SetReadOnly("pid", base::GetCurrentProcId());
|
||||
process.SetReadOnly("sandboxed", true);
|
||||
process.SetReadOnly("type", "renderer");
|
||||
process.SetReadOnly("isMainFrame", is_main_frame);
|
||||
}
|
||||
|
||||
void ElectronSandboxedRendererClient::RenderFrameCreated(
|
||||
|
@ -218,8 +218,7 @@ void ElectronSandboxedRendererClient::DidCreateScriptContext(
|
|||
// argument.
|
||||
auto* isolate = context->GetIsolate();
|
||||
auto binding = v8::Object::New(isolate);
|
||||
InitializeBindings(binding, context, render_frame->IsMainFrame());
|
||||
AddRenderBindings(isolate, binding);
|
||||
InitializeBindings(binding, context, render_frame);
|
||||
|
||||
std::vector<v8::Local<v8::String>> sandbox_preload_bundle_params = {
|
||||
node::FIXED_ONE_BYTE_STRING(isolate, "binding")};
|
||||
|
|
|
@ -21,7 +21,7 @@ class ElectronSandboxedRendererClient : public RendererClientBase {
|
|||
|
||||
void InitializeBindings(v8::Local<v8::Object> binding,
|
||||
v8::Local<v8::Context> context,
|
||||
bool is_main_frame);
|
||||
content::RenderFrame* render_frame);
|
||||
// electron::RendererClientBase:
|
||||
void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
||||
content::RenderFrame* render_frame) override;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
#include "extensions/common/constants.h"
|
||||
#include "extensions/renderer/guest_view/mime_handler_view/post_message_support.h"
|
||||
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
|
||||
namespace electron {
|
||||
|
@ -50,6 +51,20 @@ bool PrintRenderFrameHelperDelegate::IsPrintPreviewEnabled() {
|
|||
|
||||
bool PrintRenderFrameHelperDelegate::OverridePrint(
|
||||
blink::WebLocalFrame* frame) {
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
auto* post_message_support =
|
||||
extensions::PostMessageSupport::FromWebLocalFrame(frame);
|
||||
if (post_message_support) {
|
||||
// This message is handled in chrome/browser/resources/pdf/pdf_viewer.js and
|
||||
// instructs the PDF plugin to print. This is to make window.print() on a
|
||||
// PDF plugin document correctly print the PDF. See
|
||||
// https://crbug.com/448720.
|
||||
base::DictionaryValue message;
|
||||
message.SetString("type", "print");
|
||||
post_message_support->PostMessageFromValue(message);
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,9 +137,13 @@ void RendererClientBase::DidCreateScriptContext(
|
|||
global.SetHidden("contextId", context_id);
|
||||
}
|
||||
|
||||
void RendererClientBase::AddRenderBindings(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> binding_object) {}
|
||||
void RendererClientBase::BindProcess(v8::Isolate* isolate,
|
||||
gin_helper::Dictionary* process,
|
||||
content::RenderFrame* render_frame) {
|
||||
process->SetReadOnly("isMainFrame", render_frame->IsMainFrame());
|
||||
process->SetReadOnly("contextIsolated",
|
||||
render_frame->GetBlinkPreferences().context_isolation);
|
||||
}
|
||||
|
||||
void RendererClientBase::RenderThreadStarted() {
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "content/public/renderer/content_renderer_client.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
// In SHARED_INTERMEDIATE_DIR.
|
||||
#include "widevine_cdm_version.h" // NOLINT(build/include_directory)
|
||||
|
@ -92,8 +93,9 @@ class RendererClientBase : public content::ContentRendererClient
|
|||
#endif
|
||||
|
||||
protected:
|
||||
void AddRenderBindings(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> binding_object);
|
||||
void BindProcess(v8::Isolate* isolate,
|
||||
gin_helper::Dictionary* process,
|
||||
content::RenderFrame* render_frame);
|
||||
|
||||
// content::ContentRendererClient:
|
||||
void RenderThreadStarted() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue