Skip to content
This repository was archived by the owner on Sep 17, 2020. It is now read-only.

Commit e5af56c

Browse files
committed
app webview: catch new-window message from webview (from openning url in new window) and open in the player window instead
cmdline check: check that command line is exactly 2 arguments to avoid opening treating Electron dev mode cmdline as a warc
1 parent 42804a9 commit e5af56c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/main.dev.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ const createWindow = function () {
216216

217217
if (openNextFile) {
218218
openWarc(openNextFile);
219-
} else if (process.argv.length > 1 && !process.argv[1].startsWith('-psn')) {
219+
} else if (process.argv.length == 2 && !process.argv[1].startsWith('-psn')) {
220220
openWarc(process.argv[1]);
221221
}
222222

@@ -275,6 +275,17 @@ app.on('window-all-closed', () => {
275275
app.quit();
276276
});
277277

278+
// Ensure new-window urls are just opened directly in the webview
279+
app.on('web-contents-created', (e, contents) => {
280+
if (contents.getType() == 'webview') {
281+
// Listen for any new window events on the webview
282+
contents.on('new-window', (e, url) => {
283+
e.preventDefault();
284+
contents.loadURL(url);
285+
})
286+
}
287+
})
288+
278289

279290
app.on('will-finish-launching', function() {
280291
app.on('open-file', function(event, filePath) {

0 commit comments

Comments
 (0)