Add nodeIntegrationInWorker option
This commit is contained in:
parent
e496e18f6e
commit
a49af26e39
4 changed files with 20 additions and 2 deletions
|
@ -97,6 +97,10 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
|||
command_line->AppendSwitchASCII(switches::kNodeIntegration,
|
||||
node_integration ? "true" : "false");
|
||||
|
||||
// Whether to enable node integration in Worker.
|
||||
if (web_preferences.GetBoolean(options::kNodeIntegrationInWorker, &b) && b)
|
||||
command_line->AppendSwitch(switches::kNodeIntegrationInWorker);
|
||||
|
||||
// If the `sandbox` option was passed to the BrowserWindow's webPreferences,
|
||||
// pass `--enable-sandbox` to the renderer so it won't have any node.js
|
||||
// integration.
|
||||
|
|
|
@ -122,6 +122,9 @@ const char kBlinkFeatures[] = "blinkFeatures";
|
|||
// Disable blink features.
|
||||
const char kDisableBlinkFeatures[] = "disableBlinkFeatures";
|
||||
|
||||
// Enable the node integration in WebWorker.
|
||||
const char kNodeIntegrationInWorker[] = "nodeIntegrationInWorker";
|
||||
|
||||
} // namespace options
|
||||
|
||||
namespace switches {
|
||||
|
@ -164,6 +167,9 @@ const char kOpenerID[] = "opener-id";
|
|||
const char kScrollBounce[] = "scroll-bounce";
|
||||
const char kHiddenPage[] = "hidden-page";
|
||||
|
||||
// Command switch passed to renderer process to control nodeIntegration.
|
||||
const char kNodeIntegrationInWorker[] = "node-integration-in-worker";
|
||||
|
||||
// Widevine options
|
||||
// Path to Widevine CDM binaries.
|
||||
const char kWidevineCdmPath[] = "widevine-cdm-path";
|
||||
|
|
|
@ -62,6 +62,7 @@ extern const char kOpenerID[];
|
|||
extern const char kScrollBounce[];
|
||||
extern const char kBlinkFeatures[];
|
||||
extern const char kDisableBlinkFeatures[];
|
||||
extern const char kNodeIntegrationInWorker[];
|
||||
|
||||
} // namespace options
|
||||
|
||||
|
@ -89,6 +90,7 @@ extern const char kGuestInstanceID[];
|
|||
extern const char kOpenerID[];
|
||||
extern const char kScrollBounce[];
|
||||
extern const char kHiddenPage[];
|
||||
extern const char kNodeIntegrationInWorker[];
|
||||
|
||||
extern const char kWidevineCdmPath[];
|
||||
extern const char kWidevineCdmVersion[];
|
||||
|
|
|
@ -441,12 +441,18 @@ void AtomRendererClient::AddSupportedKeySystems(
|
|||
|
||||
void AtomRendererClient::DidInitializeWorkerContextOnWorkerThread(
|
||||
v8::Local<v8::Context> context) {
|
||||
WebWorkerObserver::GetCurrent()->ContextCreated(context);
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kNodeIntegrationInWorker)) {
|
||||
WebWorkerObserver::GetCurrent()->ContextCreated(context);
|
||||
}
|
||||
}
|
||||
|
||||
void AtomRendererClient::WillDestroyWorkerContextOnWorkerThread(
|
||||
v8::Local<v8::Context> context) {
|
||||
WebWorkerObserver::GetCurrent()->ContextWillDestroy(context);
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kNodeIntegrationInWorker)) {
|
||||
WebWorkerObserver::GetCurrent()->ContextWillDestroy(context);
|
||||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Context> AtomRendererClient::GetContext(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue