From 3848a4cffa7936bd57ccf3e8677c1bb8948eea7e Mon Sep 17 00:00:00 2001 From: Aoichaan0513 Date: Sat, 18 May 2019 16:47:44 +0900 Subject: [PATCH] =?utf8?q?v1.3.4=20=E3=83=BBFloating=20Window=E3=81=AE?= =?utf8?q?=E3=83=99=E3=83=BC=E3=82=BF=E5=AF=BE=E5=BF=9C=20=E3=83=BB?= =?utf8?q?=E3=83=97=E3=83=A9=E3=82=A4=E3=83=99=E3=83=BC=E3=83=88=E3=83=A2?= =?utf8?q?=E3=83=BC=E3=83=89=E3=81=AE=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3?= =?utf8?q?=E6=83=85=E5=A0=B1=E7=AD=89=E3=81=8C=E3=82=A2=E3=83=97=E3=83=AA?= =?utf8?q?=E3=82=92=E9=96=8B=E3=81=8D=E7=9B=B4=E3=81=97=E3=81=9F=E3=81=A8?= =?utf8?q?=E3=81=8D=E3=81=AB=E6=AE=8B=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE?= =?utf8?q?=E6=AD=A3=20=E3=83=BB=E3=81=9D=E3=81=AE=E4=BB=96=E3=83=90?= =?utf8?q?=E3=82=B0=E3=83=BB=E4=B8=8D=E5=85=B7=E5=90=88=E3=81=AE=E4=BF=AE?= =?utf8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- electron/WindowManager.js | 40 ++++++++++++++++++++++------------------ package.json | 2 +- pages/settings.html | 2 +- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/electron/WindowManager.js b/electron/WindowManager.js index b1cb64a..d8c2116 100644 --- a/electron/WindowManager.js +++ b/electron/WindowManager.js @@ -108,26 +108,10 @@ registerProtocols = () => { }, (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')) { @@ -456,7 +440,7 @@ module.exports = class WindowManager { experimentalFeatures: true, safeDialogs: true, safeDialogsMessage: '今後このページではダイアログを表示しない', - ...(String(windowId).startsWith('private') && { partition: `persist:${windowId}` }), + ...(String(windowId).startsWith('private') && { partition: windowId }), preload: require.resolve('./Preload') } }); @@ -466,13 +450,19 @@ module.exports = class WindowManager { } 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() }); @@ -480,6 +470,8 @@ module.exports = class WindowManager { }); view.webContents.on('did-start-navigation', (e) => { + if (view.isDestroyed()) return; + const url = view.webContents.getURL(); if (config.get('adBlocker')) @@ -489,6 +481,8 @@ module.exports = class WindowManager { }); 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() }); @@ -499,6 +493,8 @@ module.exports = class WindowManager { }); 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] }); @@ -510,16 +506,22 @@ module.exports = class WindowManager { }); 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 !== '' ? @@ -701,6 +703,8 @@ module.exports = class WindowManager { }); 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()) { diff --git a/package.json b/package.json index 079e2e2..d78a4c0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "MyBrowser-Stable", - "version": "1.3.1", + "version": "1.3.4", "private": true, "main": "electron/Starter.js", "homepage": "./", diff --git a/pages/settings.html b/pages/settings.html index d9a0713..99a450f 100644 --- a/pages/settings.html +++ b/pages/settings.html @@ -160,7 +160,7 @@

MyBrowser は(多分)最新版です

-

バージョン: 1.2.0 (Dev) (73.0.36831.121)

+

バージョン: 1.3.4 (Dev) (73.0.36831.121)


MyBrowser

Copyright 2019 Aoichaan0513. All rights reserved.

-- 2.11.0