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
26
shell/browser/api/content_tracing.idl
Normal file
26
shell/browser/api/content_tracing.idl
Normal file
|
@ -0,0 +1,26 @@
|
|||
enum RecordingMode { "record-until-full", "record-continuously", "record-as-much-as-possible", "trace-to-console" };
|
||||
|
||||
dictionary TraceConfig {
|
||||
Recordingmode recording_mode;
|
||||
unsigned long trace_buffer_size_in_kb;
|
||||
unsigned long trace_buffer_size_in_events;
|
||||
boolean enable_argument_filter;
|
||||
sequence<DOMString> included_categories;
|
||||
sequence<DOMString> excluded_categories;
|
||||
sequence<unsigned short> included_process_ids;
|
||||
sequence<DOMString> histogram_names;
|
||||
object memory_dump_config;
|
||||
};
|
||||
|
||||
dictionary TraceCategoriesAndOptions {
|
||||
DOMString categoryFilter;
|
||||
DOMString traceOptions;
|
||||
};
|
||||
|
||||
interface ContentTracing {
|
||||
Promise<sequence<DOMString>> getCategories();
|
||||
Promise<void> startRecording(TraceConfig config);
|
||||
Promise<void> startRecording(TraceCategoriesAndOptions categoriesAndOptions);
|
||||
Promise<DOMString> stopRecording(optional DOMString resultFilePath);
|
||||
Promise<TraceBufferUsage> getTraceBufferUsage();
|
||||
};
|
|
@ -1114,6 +1114,8 @@ int32_t BaseWindow::GetID() const {
|
|||
}
|
||||
|
||||
void BaseWindow::ResetBrowserViews() {
|
||||
v8::HandleScope scope(isolate());
|
||||
|
||||
for (auto& item : browser_views_) {
|
||||
gin::Handle<BrowserView> browser_view;
|
||||
if (gin::ConvertFromV8(isolate(),
|
||||
|
|
|
@ -162,6 +162,9 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
|||
v8::Locker locker(isolate);
|
||||
v8::HandleScope scope(isolate);
|
||||
gin_helper::CallMethod(this, "_onerror", "Failed to get sources.");
|
||||
|
||||
Unpin();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -195,12 +198,19 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
|||
v8::Locker locker(isolate);
|
||||
v8::HandleScope scope(isolate);
|
||||
gin_helper::CallMethod(this, "_onfinished", captured_sources_);
|
||||
|
||||
Unpin();
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) {
|
||||
return gin::CreateHandle(isolate, new DesktopCapturer(isolate));
|
||||
auto handle = gin::CreateHandle(isolate, new DesktopCapturer(isolate));
|
||||
|
||||
// Keep reference alive until capturing has finished.
|
||||
handle->Pin(isolate);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
gin::ObjectTemplateBuilder DesktopCapturer::GetObjectTemplateBuilder(
|
||||
|
|
|
@ -13,12 +13,14 @@
|
|||
#include "chrome/browser/media/webrtc/native_desktop_media_list.h"
|
||||
#include "gin/handle.h"
|
||||
#include "gin/wrappable.h"
|
||||
#include "shell/common/gin_helper/pinnable.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
|
||||
public gin_helper::Pinnable<DesktopCapturer>,
|
||||
public DesktopMediaListObserver {
|
||||
public:
|
||||
struct Source {
|
||||
|
|
|
@ -88,7 +88,7 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
|||
}
|
||||
|
||||
// If no preferred item is specified, try to show all of the menu items.
|
||||
if (!positioning_item) {
|
||||
if (!item) {
|
||||
CGFloat windowBottom = CGRectGetMinY([view window].frame);
|
||||
CGFloat lowestMenuPoint = windowBottom + position.y - [menu size].height;
|
||||
CGFloat screenBottom = CGRectGetMinY([view window].screen.frame);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "base/command_line.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "content/common/url_schemes.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "shell/browser/browser.h"
|
||||
|
@ -124,6 +125,13 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
|
|||
}
|
||||
if (custom_scheme.options.allowServiceWorkers) {
|
||||
service_worker_schemes.push_back(custom_scheme.scheme);
|
||||
// There is no API to add service worker scheme, but there is an API to
|
||||
// return const reference to the schemes vector.
|
||||
// If in future the API is changed to return a copy instead of reference,
|
||||
// the compilation will fail, and we should add a patch at that time.
|
||||
auto& mutable_schemes = const_cast<std::vector<std::string>&>(
|
||||
content::GetServiceWorkerSchemes());
|
||||
mutable_schemes.push_back(custom_scheme.scheme);
|
||||
}
|
||||
if (custom_scheme.options.stream) {
|
||||
g_streaming_schemes.push_back(custom_scheme.scheme);
|
||||
|
|
|
@ -915,6 +915,7 @@ WebContents::~WebContents() {
|
|||
return;
|
||||
}
|
||||
|
||||
inspectable_web_contents_->GetView()->SetDelegate(nullptr);
|
||||
if (guest_delegate_)
|
||||
guest_delegate_->WillDestroy();
|
||||
|
||||
|
@ -1761,6 +1762,7 @@ void WebContents::DevToolsOpened() {
|
|||
v8::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
DCHECK(inspectable_web_contents_);
|
||||
DCHECK(inspectable_web_contents_->GetDevToolsWebContents());
|
||||
auto handle = FromOrCreate(
|
||||
isolate, inspectable_web_contents_->GetDevToolsWebContents());
|
||||
devtools_web_contents_.Reset(isolate, handle.ToV8());
|
||||
|
|
|
@ -1363,22 +1363,26 @@ void ElectronBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
|
|||
int render_process_id,
|
||||
int render_frame_id,
|
||||
NonNetworkURLLoaderFactoryMap* factories) {
|
||||
content::RenderFrameHost* frame_host =
|
||||
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(frame_host);
|
||||
auto* render_process_host =
|
||||
content::RenderProcessHost::FromID(render_process_id);
|
||||
DCHECK(render_process_host);
|
||||
if (!render_process_host || !render_process_host->GetBrowserContext())
|
||||
return;
|
||||
|
||||
ProtocolRegistry::FromBrowserContext(render_process_host->GetBrowserContext())
|
||||
->RegisterURLLoaderFactories(URLLoaderFactoryType::kDocumentSubResource,
|
||||
factories);
|
||||
|
||||
if (web_contents) {
|
||||
ProtocolRegistry::FromBrowserContext(web_contents->GetBrowserContext())
|
||||
->RegisterURLLoaderFactories(URLLoaderFactoryType::kDocumentSubResource,
|
||||
factories);
|
||||
}
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
auto factory = extensions::CreateExtensionURLLoaderFactory(render_process_id,
|
||||
render_frame_id);
|
||||
if (factory)
|
||||
factories->emplace(extensions::kExtensionScheme, std::move(factory));
|
||||
|
||||
content::RenderFrameHost* frame_host =
|
||||
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(frame_host);
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
|
|
|
@ -317,8 +317,9 @@ void NativeBrowserViewMac::UpdateDraggableRegions(
|
|||
const auto window_content_view_height = NSHeight(window_content_view.bounds);
|
||||
for (const auto& rect : drag_exclude_rects) {
|
||||
const auto x = rect.x() + offset.x();
|
||||
const auto y = window_content_view_height - rect.bottom() + offset.y();
|
||||
const auto y = window_content_view_height - (rect.bottom() + offset.y());
|
||||
const auto exclude_rect = NSMakeRect(x, y, rect.width(), rect.height());
|
||||
|
||||
const auto drag_region_view_exclude_rect =
|
||||
[window_content_view convertRect:exclude_rect toView:drag_region_view];
|
||||
|
||||
|
|
|
@ -206,6 +206,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual void SetTrafficLightPosition(base::Optional<gfx::Point> position) = 0;
|
||||
virtual base::Optional<gfx::Point> GetTrafficLightPosition() const = 0;
|
||||
virtual void RedrawTrafficLights() = 0;
|
||||
virtual void UpdateFrame() = 0;
|
||||
#endif
|
||||
|
||||
// Touchbar API
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "shell/browser/native_window.h"
|
||||
#include "ui/display/display_observer.h"
|
||||
#include "ui/native_theme/native_theme_observer.h"
|
||||
#include "ui/views/controls/native/native_view_host.h"
|
||||
|
||||
|
@ -27,7 +28,9 @@ namespace electron {
|
|||
|
||||
class RootViewMac;
|
||||
|
||||
class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
|
||||
class NativeWindowMac : public NativeWindow,
|
||||
public ui::NativeThemeObserver,
|
||||
public display::DisplayObserver {
|
||||
public:
|
||||
NativeWindowMac(const gin_helper::Dictionary& options, NativeWindow* parent);
|
||||
~NativeWindowMac() override;
|
||||
|
@ -124,6 +127,7 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
|
|||
void SetTrafficLightPosition(base::Optional<gfx::Point> position) override;
|
||||
base::Optional<gfx::Point> GetTrafficLightPosition() const override;
|
||||
void RedrawTrafficLights() override;
|
||||
void UpdateFrame() override;
|
||||
void SetTouchBar(
|
||||
std::vector<gin_helper::PersistentDictionary> items) override;
|
||||
void RefreshTouchBarItem(const std::string& item_id) override;
|
||||
|
@ -188,6 +192,10 @@ class NativeWindowMac : public NativeWindow, public ui::NativeThemeObserver {
|
|||
// ui::NativeThemeObserver:
|
||||
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
||||
|
||||
// display::DisplayObserver:
|
||||
void OnDisplayMetricsChanged(const display::Display& display,
|
||||
uint32_t changed_metrics) override;
|
||||
|
||||
private:
|
||||
// Add custom layers to the content view.
|
||||
void AddContentViewLayers();
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "shell/common/process_util.h"
|
||||
#include "skia/ext/skia_utils_mac.h"
|
||||
#include "third_party/webrtc/modules/desktop_capture/mac/window_list_utils.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/gfx/skia_util.h"
|
||||
#include "ui/gl/gpu_switching_manager.h"
|
||||
#include "ui/views/background.h"
|
||||
|
@ -258,6 +259,7 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options,
|
|||
NativeWindow* parent)
|
||||
: NativeWindow(options, parent), root_view_(new RootViewMac(this)) {
|
||||
ui::NativeTheme::GetInstanceForNativeUi()->AddObserver(this);
|
||||
display::Screen::GetScreen()->AddObserver(this);
|
||||
|
||||
int width = 800, height = 600;
|
||||
options.Get(options::kWidth, &width);
|
||||
|
@ -882,6 +884,17 @@ void NativeWindowMac::SetExcludedFromShownWindowsMenu(bool excluded) {
|
|||
[window setExcludedFromWindowsMenu:excluded];
|
||||
}
|
||||
|
||||
void NativeWindowMac::OnDisplayMetricsChanged(const display::Display& display,
|
||||
uint32_t changed_metrics) {
|
||||
// We only want to force screen recalibration if we're in simpleFullscreen
|
||||
// mode.
|
||||
if (!is_simple_fullscreen_)
|
||||
return;
|
||||
|
||||
base::PostTask(FROM_HERE, {content::BrowserThread::UI},
|
||||
base::BindOnce(&NativeWindow::UpdateFrame, GetWeakPtr()));
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetSimpleFullScreen(bool simple_fullscreen) {
|
||||
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
||||
|
||||
|
@ -1396,6 +1409,13 @@ void NativeWindowMac::RedrawTrafficLights() {
|
|||
[buttons_view_ setNeedsDisplayForButtons];
|
||||
}
|
||||
|
||||
// In simpleFullScreen mode, update the frame for new bounds.
|
||||
void NativeWindowMac::UpdateFrame() {
|
||||
NSWindow* window = GetNativeWindow().GetNativeNSWindow();
|
||||
NSRect fullscreenFrame = [window.screen frame];
|
||||
[window setFrame:fullscreenFrame display:YES animate:YES];
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetTouchBar(
|
||||
std::vector<gin_helper::PersistentDictionary> items) {
|
||||
if (@available(macOS 10.12.2, *)) {
|
||||
|
@ -1551,6 +1571,7 @@ void NativeWindowMac::NotifyWindowWillLeaveFullScreen() {
|
|||
void NativeWindowMac::Cleanup() {
|
||||
DCHECK(!IsClosed());
|
||||
ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this);
|
||||
display::Screen::GetScreen()->RemoveObserver(this);
|
||||
[NSEvent removeMonitor:wheel_event_monitor_];
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 14,0,0,20210315
|
||||
PRODUCTVERSION 14,0,0,20210315
|
||||
FILEVERSION 14,0,0,20210323
|
||||
PRODUCTVERSION 14,0,0,20210323
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
|
|
@ -201,12 +201,6 @@ class InspectableWebContents
|
|||
void AddDevToolsExtensionsToClient();
|
||||
#endif
|
||||
|
||||
bool frontend_loaded_ = false;
|
||||
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
||||
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
|
||||
std::unique_ptr<DevToolsEmbedderMessageDispatcher>
|
||||
embedder_message_dispatcher_;
|
||||
|
||||
DevToolsContentsResizingStrategy contents_resizing_strategy_;
|
||||
gfx::Rect devtools_bounds_;
|
||||
bool can_dock_ = true;
|
||||
|
@ -228,6 +222,12 @@ class InspectableWebContents
|
|||
bool is_guest_;
|
||||
std::unique_ptr<InspectableWebContentsView> view_;
|
||||
|
||||
bool frontend_loaded_ = false;
|
||||
scoped_refptr<content::DevToolsAgentHost> agent_host_;
|
||||
std::unique_ptr<content::DevToolsFrontendHost> frontend_host_;
|
||||
std::unique_ptr<DevToolsEmbedderMessageDispatcher>
|
||||
embedder_message_dispatcher_;
|
||||
|
||||
class NetworkResourceLoader;
|
||||
std::set<std::unique_ptr<NetworkResourceLoader>, base::UniquePtrComparator>
|
||||
loaders_;
|
||||
|
|
|
@ -363,21 +363,22 @@ void NodeBindings::Initialize() {
|
|||
// Parse and set Node.js cli flags.
|
||||
SetNodeCliFlags();
|
||||
|
||||
// pass non-null program name to argv so it doesn't crash
|
||||
// trying to index into a nullptr
|
||||
int argc = 1;
|
||||
int exec_argc = 0;
|
||||
const char* prog_name = "electron";
|
||||
const char** argv = &prog_name;
|
||||
const char** exec_argv = nullptr;
|
||||
|
||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||
SetNodeOptions(env.get());
|
||||
|
||||
// TODO(codebytere): this is going to be deprecated in the near future
|
||||
// in favor of Init(std::vector<std::string>* argv,
|
||||
// std::vector<std::string>* exec_argv)
|
||||
node::Init(&argc, argv, &exec_argc, &exec_argv);
|
||||
std::vector<std::string> argv = {"electron"};
|
||||
std::vector<std::string> exec_argv;
|
||||
std::vector<std::string> errors;
|
||||
|
||||
int exit_code = node::InitializeNodeWithArgs(&argv, &exec_argv, &errors);
|
||||
|
||||
for (const std::string& error : errors) {
|
||||
fprintf(stderr, "%s: %s\n", argv[0].c_str(), error.c_str());
|
||||
}
|
||||
|
||||
if (exit_code != 0) {
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// uv_init overrides error mode to suppress the default crash dialog, bring
|
||||
|
@ -533,15 +534,13 @@ void NodeBindings::LoadEnvironment(node::Environment* env) {
|
|||
void NodeBindings::PrepareMessageLoop() {
|
||||
#if !defined(OS_WIN)
|
||||
int handle = uv_backend_fd(uv_loop_);
|
||||
#else
|
||||
HANDLE handle = uv_loop_->iocp;
|
||||
#endif
|
||||
|
||||
// If the backend fd hasn't changed, don't proceed.
|
||||
if (handle == handle_)
|
||||
return;
|
||||
|
||||
handle_ = handle;
|
||||
#endif
|
||||
|
||||
// Add dummy handle for libuv, otherwise libuv would quit when there is
|
||||
// nothing to do.
|
||||
|
|
|
@ -159,9 +159,7 @@ class NodeBindings {
|
|||
// Isolate data used in creating the environment
|
||||
node::IsolateData* isolate_data_ = nullptr;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
HANDLE handle_;
|
||||
#else
|
||||
#if !defined(OS_WIN)
|
||||
int handle_ = -1;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "base/win/windows_version.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/escape.h"
|
||||
#include "shell/common/electron_paths.h"
|
||||
#include "ui/base/win/shell.h"
|
||||
#include "url/gurl.h"
|
||||
|
@ -241,7 +242,8 @@ std::string OpenExternalOnWorkerThread(
|
|||
// Quote the input scheme to be sure that the command does not have
|
||||
// parameters unexpected by the external program. This url should already
|
||||
// have been escaped.
|
||||
std::wstring escaped_url = L"\"" + base::UTF8ToWide(url.spec()) + L"\"";
|
||||
std::wstring escaped_url =
|
||||
L"\"" + base::UTF8ToWide(net::EscapeExternalHandlerValue(url.spec())) +
|
||||
std::wstring working_dir = options.working_dir.value();
|
||||
|
||||
if (reinterpret_cast<ULONG_PTR>(
|
||||
|
|
|
@ -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