}, (error) => {
if (error) console.error('Failed to register protocol: ' + error);
});
-
- session.fromPartition('persist:private').protocol.registerFileProtocol('my', (request, callback) => {
- const parsed = url.parse(request.url);
-
- if (parsed.hostname.endsWith('.css') || parsed.hostname.endsWith('.js')) {
- return callback({
- path: path.join(app.getAppPath(), 'pages', parsed.hostname),
- });
- } else {
- return callback({
- path: path.join(app.getAppPath(), 'pages', `${parsed.hostname}.html`),
- });
- }
- }, (error) => {
- if (error) console.error('Failed to register protocol: ' + error);
- });
}
registerProtocolWithPrivateMode = (windowId) => {
- session.fromPartition(`persist:${windowId}`).protocol.registerFileProtocol('my', (request, callback) => {
+ session.fromPartition(windowId).protocol.registerFileProtocol('my', (request, callback) => {
const parsed = url.parse(request.url);
if (parsed.hostname.endsWith('.css') || parsed.hostname.endsWith('.js')) {
experimentalFeatures: true,
safeDialogs: true,
safeDialogsMessage: '今後このページではダイアログを表示しない',
- ...(String(windowId).startsWith('private') && { partition: `persist:${windowId}` }),
+ ...(String(windowId).startsWith('private') && { partition: windowId }),
preload: require.resolve('./Preload')
}
});
}
view.webContents.on('did-start-loading', () => {
+ if (view.isDestroyed()) return;
+
window.webContents.send(`browserview-start-loading-${windowId}`, { id: id });
});
view.webContents.on('did-stop-loading', () => {
+ if (view.isDestroyed()) return;
+
window.webContents.send(`browserview-stop-loading-${windowId}`, { id: id });
});
view.webContents.on('did-finish-load', (e) => {
+ if (view.isDestroyed()) return;
+
window.setTitle(view.webContents.getTitle());
window.webContents.send(`browserview-load-${windowId}`, { id: id, title: view.webContents.getTitle(), url: view.webContents.getURL() });
});
view.webContents.on('did-start-navigation', (e) => {
+ if (view.isDestroyed()) return;
+
const url = view.webContents.getURL();
if (config.get('adBlocker'))
});
view.webContents.on('page-title-updated', (e) => {
+ if (view.isDestroyed()) return;
+
window.setTitle(view.webContents.getTitle());
window.webContents.send(`browserview-load-${windowId}`, { id: id, title: view.webContents.getTitle(), url: view.webContents.getURL() });
});
view.webContents.on('page-favicon-updated', (e, favicons) => {
+ if (view.isDestroyed()) return;
+
window.setTitle(view.webContents.getTitle());
if (favicons.length > 0) {
window.webContents.send(`browserview-load-${windowId}`, { id: id, title: view.webContents.getTitle(), url: view.webContents.getURL(), favicon: favicons[0] });
});
view.webContents.on('did-change-theme-color', (e, color) => {
+ if (view.isDestroyed()) return;
+
window.setTitle(view.webContents.getTitle());
window.webContents.send(`browserview-load-${windowId}`, { id: id, title: view.webContents.getTitle(), url: view.webContents.getURL(), color: color });
});
view.webContents.on('new-window', (e, url) => {
+ if (view.isDestroyed()) return;
+
e.preventDefault();
this.addView(windowId, url, true);
});
view.webContents.on('context-menu', (e, params) => {
+ if (view.isDestroyed()) return;
+
const menu = Menu.buildFromTemplate(
[
...(params.linkURL !== '' ?
});
view.webContents.on('before-input-event', (e, input) => {
+ if (view.isDestroyed()) return;
+
if ((input.control || input.meta) && input.shift && input.key == 'I') {
e.preventDefault();
if (view.webContents.isDevToolsOpened()) {