Skip to content

Commit 3cb9216

Browse files
Implement Electron 5.0.1 compatibility
1 parent aea2c7a commit 3cb9216

File tree

14 files changed

+59
-42
lines changed

14 files changed

+59
-42
lines changed

Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ElectronNET.CLI:
1111

1212
ElectronNET.API:
1313

14-
* Implement Electron 5.0.1 support
14+
* Implement Electron 5.0.1 support, but not all new features
1515
* Implement HostHook-API for execute own TypeScript/JavaScript code
1616
* Fixed bug: 'X and Y options to not work on Windows 10' [\#193](https://github.com/ElectronNET/Electron.NET/issues/193)
1717
* Merged pull request: Fix BrowserWindow::SetMenu [\#231](https://github.com/ElectronNET/Electron.NET/pull/231) thanks (thanks [CodeKenpachi](https://github.com/CodeKenpachi))

ElectronNET.API/App.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,14 +1414,6 @@ public void CommandLineAppendArgument(string value)
14141414
BridgeConnector.Socket.Emit("appCommandLineAppendArgument", value);
14151415
}
14161416

1417-
/// <summary>
1418-
/// Enables mixed sandbox mode on the app. This method can only be called before app is ready.
1419-
/// </summary>
1420-
public void EnableMixedSandbox()
1421-
{
1422-
BridgeConnector.Socket.Emit("appEnableMixedSandbox");
1423-
}
1424-
14251417
/// <summary>
14261418
/// When critical is passed, the dock icon will bounce until either the application
14271419
/// becomes active or the request is canceled.When informational is passed, the

ElectronNET.API/Entities/WebPreferences.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ public class WebPreferences
185185
/// Context' entry in the combo box at the top of the Console tab. This option is
186186
/// currently experimental and may change or be removed in future Electron releases.
187187
/// </summary>
188-
public bool ContextIsolation { get; set; }
188+
[DefaultValue(true)]
189+
public bool ContextIsolation { get; set; } = true;
189190

190191
/// <summary>
191192
/// Whether to use native window.open(). Defaults to false. This option is currently experimental.
@@ -203,6 +204,7 @@ public class WebPreferences
203204
/// <value>
204205
/// <c>true</c> if [webview tag]; otherwise, <c>false</c>.
205206
/// </value>
206-
public bool WebviewTag { get; set; }
207+
[DefaultValue(false)]
208+
public bool WebviewTag { get; set; } = false;
207209
}
208210
}

ElectronNET.API/Shell.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ public Task<bool> OpenExternalAsync(string url, OpenExternalOptions options)
132132
/// </summary>
133133
/// <param name="url"></param>
134134
/// <param name="options">macOS only</param>
135-
/// <param name="action">macOS only</param>
135+
/// <param name="errorAction">Action to get the error message.</param>
136136
/// <returns>Whether an application was available to open the URL.
137137
/// If callback is specified, always returns true.</returns>
138-
public Task<bool> OpenExternalAsync(string url, OpenExternalOptions options, Action<Error> action)
138+
public Task<bool> OpenExternalAsync(string url, OpenExternalOptions options, Action<Error> errorAction)
139139
{
140140
var taskCompletionSource = new TaskCompletionSource<bool>();
141141

@@ -157,7 +157,7 @@ public Task<bool> OpenExternalAsync(string url, OpenExternalOptions options, Act
157157
}
158158
});
159159

160-
_openExternalCallbacks.Add(url, action);
160+
_openExternalCallbacks.Add(url, errorAction);
161161

162162
BridgeConnector.Socket.Emit("shell-openExternal", url, JObject.FromObject(options, _jsonSerializer), true);
163163

ElectronNET.Host/api/app.js

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/app.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,6 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
268268
app.commandLine.appendArgument(value);
269269
});
270270

271-
socket.on('appEnableMixedSandbox', () => {
272-
app.enableMixedSandbox();
273-
});
274-
275271
socket.on('appDockBounce', (type) => {
276272
const id = app.dock.bounce(type);
277273
electronSocket.emit('appDockBounceCompleted', id);

ElectronNET.Host/api/browserWindows.js

Lines changed: 14 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,22 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
185185
});
186186
});
187187

188+
function hasOwnChildreen(obj, ...childNames) {
189+
for (let i = 0; i < childNames.length; i++) {
190+
if (!obj || !obj.hasOwnProperty(childNames[i])) {
191+
return false;
192+
}
193+
obj = obj[childNames[i]];
194+
}
195+
196+
return true;
197+
}
198+
188199
socket.on('createBrowserWindow', (options, loadUrl) => {
200+
if (!hasOwnChildreen(options, 'webPreferences', 'nodeIntegration')) {
201+
options = { ...options, webPreferences: { nodeIntegration: true } };
202+
}
203+
189204
window = new BrowserWindow(options);
190205
lastOptions = options;
191206

0 commit comments

Comments
 (0)