build: add enable_remote_module build flag (#19821)
This commit is contained in:
parent
8bf74164e2
commit
11cd0db86b
32 changed files with 585 additions and 497 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/web_preferences.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/filename_util.h"
|
||||
#include "services/service_manager/sandbox/switches.h"
|
||||
|
@ -170,7 +171,9 @@ WebContentsPreferences::~WebContentsPreferences() {
|
|||
}
|
||||
|
||||
void WebContentsPreferences::SetDefaults() {
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
SetDefaultBoolIfUndefined(options::kEnableRemoteModule, true);
|
||||
#endif
|
||||
|
||||
if (IsEnabled(options::kSandbox)) {
|
||||
SetBool(options::kNativeWindowOpen, true);
|
||||
|
@ -323,9 +326,11 @@ void WebContentsPreferences::AppendCommandLineSwitches(
|
|||
}
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
// Whether to enable the remote module
|
||||
if (IsEnabled(options::kEnableRemoteModule))
|
||||
command_line->AppendSwitch(switches::kEnableRemoteModule);
|
||||
#endif
|
||||
|
||||
// Run Electron APIs and preload script in isolated world
|
||||
if (IsEnabled(options::kContextIsolation))
|
||||
|
|
|
@ -6,16 +6,20 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/hash/hash.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "shell/common/api/atom_api_key_weak_map.h"
|
||||
#include "shell/common/api/remote_callback_freer.h"
|
||||
#include "shell/common/api/remote_object_freer.h"
|
||||
#include "shell/common/native_mate_converters/content_converter.h"
|
||||
#include "shell/common/native_mate_converters/gurl_converter.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "url/origin.h"
|
||||
#include "v8/include/v8-profiler.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
#include "shell/common/api/atom_api_key_weak_map.h"
|
||||
#include "shell/common/api/remote/remote_callback_freer.h"
|
||||
#include "shell/common/api/remote/remote_object_freer.h"
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
|
||||
// The hash function used by DoubleIDWeakMap.
|
||||
|
@ -117,6 +121,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
dict.SetMethod("deleteHiddenValue", &DeleteHiddenValue);
|
||||
dict.SetMethod("getObjectHash", &GetObjectHash);
|
||||
dict.SetMethod("takeHeapSnapshot", &TakeHeapSnapshot);
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
dict.SetMethod("setRemoteCallbackFreer",
|
||||
&electron::RemoteCallbackFreer::BindTo);
|
||||
dict.SetMethod("setRemoteObjectFreer", &electron::RemoteObjectFreer::BindTo);
|
||||
|
@ -126,6 +131,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
dict.SetMethod(
|
||||
"createDoubleIDWeakMap",
|
||||
&electron::api::KeyWeakMap<std::pair<std::string, int32_t>>::Create);
|
||||
#endif
|
||||
dict.SetMethod("requestGarbageCollectionForTesting",
|
||||
&RequestGarbageCollectionForTesting);
|
||||
dict.SetMethod("isSameOrigin", &IsSameOrigin);
|
||||
|
|
|
@ -17,6 +17,10 @@ bool IsOffscreenRenderingEnabled() {
|
|||
return BUILDFLAG(ENABLE_OSR);
|
||||
}
|
||||
|
||||
bool IsRemoteModuleEnabled() {
|
||||
return BUILDFLAG(ENABLE_REMOTE_MODULE);
|
||||
}
|
||||
|
||||
bool IsPDFViewerEnabled() {
|
||||
return BUILDFLAG(ENABLE_PDF_VIEWER);
|
||||
}
|
||||
|
@ -64,6 +68,7 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||
dict.SetMethod("isDesktopCapturerEnabled", &IsDesktopCapturerEnabled);
|
||||
dict.SetMethod("isOffscreenRenderingEnabled", &IsOffscreenRenderingEnabled);
|
||||
dict.SetMethod("isRemoteModuleEnabled", &IsRemoteModuleEnabled);
|
||||
dict.SetMethod("isPDFViewerEnabled", &IsPDFViewerEnabled);
|
||||
dict.SetMethod("isRunAsNodeEnabled", &IsRunAsNodeEnabled);
|
||||
dict.SetMethod("isFakeLocationProviderEnabled",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/api/object_life_monitor.h"
|
||||
#include "shell/common/api/remote/object_life_monitor.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/message_loop/message_loop.h"
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_
|
||||
#define SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_
|
||||
#ifndef SHELL_COMMON_API_REMOTE_OBJECT_LIFE_MONITOR_H_
|
||||
#define SHELL_COMMON_API_REMOTE_OBJECT_LIFE_MONITOR_H_
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
@ -31,4 +31,4 @@ class ObjectLifeMonitor {
|
|||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_COMMON_API_OBJECT_LIFE_MONITOR_H_
|
||||
#endif // SHELL_COMMON_API_REMOTE_OBJECT_LIFE_MONITOR_H_
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/api/remote_callback_freer.h"
|
||||
#include "shell/common/api/remote/remote_callback_freer.h"
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
|
@ -2,13 +2,13 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_COMMON_API_REMOTE_CALLBACK_FREER_H_
|
||||
#define SHELL_COMMON_API_REMOTE_CALLBACK_FREER_H_
|
||||
#ifndef SHELL_COMMON_API_REMOTE_REMOTE_CALLBACK_FREER_H_
|
||||
#define SHELL_COMMON_API_REMOTE_REMOTE_CALLBACK_FREER_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "shell/common/api/object_life_monitor.h"
|
||||
#include "shell/common/api/remote/object_life_monitor.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -43,4 +43,4 @@ class RemoteCallbackFreer : public ObjectLifeMonitor,
|
|||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_COMMON_API_REMOTE_CALLBACK_FREER_H_
|
||||
#endif // SHELL_COMMON_API_REMOTE_REMOTE_CALLBACK_FREER_H_
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/api/remote_object_freer.h"
|
||||
#include "shell/common/api/remote/remote_object_freer.h"
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/values.h"
|
|
@ -2,13 +2,13 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_COMMON_API_REMOTE_OBJECT_FREER_H_
|
||||
#define SHELL_COMMON_API_REMOTE_OBJECT_FREER_H_
|
||||
#ifndef SHELL_COMMON_API_REMOTE_REMOTE_OBJECT_FREER_H_
|
||||
#define SHELL_COMMON_API_REMOTE_REMOTE_OBJECT_FREER_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "shell/common/api/object_life_monitor.h"
|
||||
#include "shell/common/api/remote/object_life_monitor.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
|
@ -42,4 +42,4 @@ class RemoteObjectFreer : public ObjectLifeMonitor {
|
|||
|
||||
} // namespace electron
|
||||
|
||||
#endif // SHELL_COMMON_API_REMOTE_OBJECT_FREER_H_
|
||||
#endif // SHELL_COMMON_API_REMOTE_REMOTE_OBJECT_FREER_H_
|
|
@ -110,9 +110,6 @@ const char kPreloadURL[] = "preloadURL";
|
|||
// Enable the node integration.
|
||||
const char kNodeIntegration[] = "nodeIntegration";
|
||||
|
||||
// Enable the remote module
|
||||
const char kEnableRemoteModule[] = "enableRemoteModule";
|
||||
|
||||
// Enable context isolation of Electron APIs and preload script
|
||||
const char kContextIsolation[] = "contextIsolation";
|
||||
|
||||
|
@ -176,6 +173,10 @@ const char kWebGL[] = "webgl";
|
|||
// navigation.
|
||||
const char kNavigateOnDragDrop[] = "navigateOnDragDrop";
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
const char kEnableRemoteModule[] = "enableRemoteModule";
|
||||
#endif
|
||||
|
||||
} // namespace options
|
||||
|
||||
namespace switches {
|
||||
|
@ -224,7 +225,6 @@ const char kBackgroundColor[] = "background-color";
|
|||
const char kPreloadScript[] = "preload";
|
||||
const char kPreloadScripts[] = "preload-scripts";
|
||||
const char kNodeIntegration[] = "node-integration";
|
||||
const char kEnableRemoteModule[] = "enable-remote-module";
|
||||
const char kContextIsolation[] = "context-isolation";
|
||||
const char kGuestInstanceID[] = "guest-instance-id";
|
||||
const char kOpenerID[] = "opener-id";
|
||||
|
@ -265,6 +265,10 @@ const char kAuthNegotiateDelegateWhitelist[] =
|
|||
// If set, include the port in generated Kerberos SPNs.
|
||||
const char kEnableAuthNegotiatePort[] = "enable-auth-negotiate-port";
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
const char kEnableRemoteModule[] = "enable-remote-module";
|
||||
#endif
|
||||
|
||||
} // namespace switches
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#ifndef SHELL_COMMON_OPTIONS_SWITCHES_H_
|
||||
#define SHELL_COMMON_OPTIONS_SWITCHES_H_
|
||||
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace options {
|
||||
|
@ -58,7 +60,6 @@ extern const char kZoomFactor[];
|
|||
extern const char kPreloadScript[];
|
||||
extern const char kPreloadURL[];
|
||||
extern const char kNodeIntegration[];
|
||||
extern const char kEnableRemoteModule[];
|
||||
extern const char kContextIsolation[];
|
||||
extern const char kGuestInstanceID[];
|
||||
extern const char kExperimentalFeatures[];
|
||||
|
@ -83,6 +84,10 @@ extern const char kTextAreasAreResizable[];
|
|||
extern const char kWebGL[];
|
||||
extern const char kNavigateOnDragDrop[];
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
extern const char kEnableRemoteModule[];
|
||||
#endif
|
||||
|
||||
} // namespace options
|
||||
|
||||
// Following are actually command line switches, should be moved to other files.
|
||||
|
@ -107,7 +112,6 @@ extern const char kBackgroundColor[];
|
|||
extern const char kPreloadScript[];
|
||||
extern const char kPreloadScripts[];
|
||||
extern const char kNodeIntegration[];
|
||||
extern const char kEnableRemoteModule[];
|
||||
extern const char kContextIsolation[];
|
||||
extern const char kGuestInstanceID[];
|
||||
extern const char kOpenerID[];
|
||||
|
@ -129,6 +133,10 @@ extern const char kAuthServerWhitelist[];
|
|||
extern const char kAuthNegotiateDelegateWhitelist[];
|
||||
extern const char kEnableAuthNegotiatePort[];
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
extern const char kEnableRemoteModule[];
|
||||
#endif
|
||||
|
||||
} // namespace switches
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -117,10 +117,12 @@ void RendererClientBase::DidCreateScriptContext(
|
|||
gin_helper::Dictionary global(context->GetIsolate(), context->Global());
|
||||
global.SetHidden("contextId", context_id);
|
||||
|
||||
#if BUILDFLAG(ENABLE_REMOTE_MODULE)
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
bool enableRemoteModule =
|
||||
command_line->HasSwitch(switches::kEnableRemoteModule);
|
||||
global.SetHidden("enableRemoteModule", enableRemoteModule);
|
||||
#endif
|
||||
}
|
||||
|
||||
void RendererClientBase::AddRenderBindings(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue