Bump v12.0.0-nightly.20200827
This commit is contained in:
parent
5e1950ceff
commit
443540fd13
32 changed files with 1267 additions and 1267 deletions
|
@ -1 +1 @@
|
||||||
11.0.0-nightly.20200826
|
12.0.0-nightly.20200827
|
|
@ -1,95 +1,95 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('open-error-dialog', event => {
|
ipcMain.on('open-error-dialog', event => {
|
||||||
dialog.showErrorBox('An Error Message', 'Demonstrating an error message.')
|
dialog.showErrorBox('An Error Message', 'Demonstrating an error message.')
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('open-information-dialog', event => {
|
ipcMain.on('open-information-dialog', event => {
|
||||||
const options = {
|
const options = {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'Information',
|
title: 'Information',
|
||||||
message: "This is an information dialog. Isn't it nice?",
|
message: "This is an information dialog. Isn't it nice?",
|
||||||
buttons: ['Yes', 'No']
|
buttons: ['Yes', 'No']
|
||||||
}
|
}
|
||||||
dialog.showMessageBox(options, index => {
|
dialog.showMessageBox(options, index => {
|
||||||
event.sender.send('information-dialog-selection', index)
|
event.sender.send('information-dialog-selection', index)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('open-file-dialog', event => {
|
ipcMain.on('open-file-dialog', event => {
|
||||||
dialog.showOpenDialog(
|
dialog.showOpenDialog(
|
||||||
{
|
{
|
||||||
properties: ['openFile', 'openDirectory']
|
properties: ['openFile', 'openDirectory']
|
||||||
},
|
},
|
||||||
files => {
|
files => {
|
||||||
if (files) {
|
if (files) {
|
||||||
event.sender.send('selected-directory', files)
|
event.sender.send('selected-directory', files)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('save-dialog', event => {
|
ipcMain.on('save-dialog', event => {
|
||||||
const options = {
|
const options = {
|
||||||
title: 'Save an Image',
|
title: 'Save an Image',
|
||||||
filters: [{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }]
|
filters: [{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }]
|
||||||
}
|
}
|
||||||
dialog.showSaveDialog(options, filename => {
|
dialog.showSaveDialog(options, filename => {
|
||||||
event.sender.send('saved-file', filename)
|
event.sender.send('saved-file', filename)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
const { ipcRenderer, shell } = require('electron')
|
const { ipcRenderer, shell } = require('electron')
|
||||||
|
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
const errorBtn = document.getElementById('error-dialog')
|
const errorBtn = document.getElementById('error-dialog')
|
||||||
|
|
||||||
errorBtn.addEventListener('click', event => {
|
errorBtn.addEventListener('click', event => {
|
||||||
ipcRenderer.send('open-error-dialog')
|
ipcRenderer.send('open-error-dialog')
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -1,70 +1,70 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
ipcMain.on('open-information-dialog', event => {
|
ipcMain.on('open-information-dialog', event => {
|
||||||
const options = {
|
const options = {
|
||||||
type: 'info',
|
type: 'info',
|
||||||
title: 'Information',
|
title: 'Information',
|
||||||
message: "This is an information dialog. Isn't it nice?",
|
message: "This is an information dialog. Isn't it nice?",
|
||||||
buttons: ['Yes', 'No']
|
buttons: ['Yes', 'No']
|
||||||
}
|
}
|
||||||
dialog.showMessageBox(options, index => {
|
dialog.showMessageBox(options, index => {
|
||||||
event.sender.send('information-dialog-selection', index)
|
event.sender.send('information-dialog-selection', index)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
const { ipcRenderer, shell } = require('electron')
|
const { ipcRenderer, shell } = require('electron')
|
||||||
|
|
||||||
const informationBtn = document.getElementById('information-dialog')
|
const informationBtn = document.getElementById('information-dialog')
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
informationBtn.addEventListener('click', event => {
|
informationBtn.addEventListener('click', event => {
|
||||||
ipcRenderer.send('open-information-dialog')
|
ipcRenderer.send('open-information-dialog')
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('information-dialog-selection', (event, index) => {
|
ipcRenderer.on('information-dialog-selection', (event, index) => {
|
||||||
let message = 'You selected '
|
let message = 'You selected '
|
||||||
if (index === 0) message += 'yes.'
|
if (index === 0) message += 'yes.'
|
||||||
else message += 'no.'
|
else message += 'no.'
|
||||||
document.getElementById('info-selection').innerHTML = message
|
document.getElementById('info-selection').innerHTML = message
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -1,70 +1,70 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
ipcMain.on('open-file-dialog', event => {
|
ipcMain.on('open-file-dialog', event => {
|
||||||
dialog.showOpenDialog(
|
dialog.showOpenDialog(
|
||||||
{
|
{
|
||||||
properties: ['openFile', 'openDirectory']
|
properties: ['openFile', 'openDirectory']
|
||||||
},
|
},
|
||||||
files => {
|
files => {
|
||||||
if (files) {
|
if (files) {
|
||||||
event.sender.send('selected-directory', files)
|
event.sender.send('selected-directory', files)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
const { ipcRenderer, shell } = require('electron')
|
const { ipcRenderer, shell } = require('electron')
|
||||||
|
|
||||||
const selectDirBtn = document.getElementById('select-directory')
|
const selectDirBtn = document.getElementById('select-directory')
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
selectDirBtn.addEventListener('click', event => {
|
selectDirBtn.addEventListener('click', event => {
|
||||||
ipcRenderer.send('open-file-dialog')
|
ipcRenderer.send('open-file-dialog')
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('selected-directory', (event, path) => {
|
ipcRenderer.on('selected-directory', (event, path) => {
|
||||||
document.getElementById('selected-file').innerHTML = `You selected: ${path}`
|
document.getElementById('selected-file').innerHTML = `You selected: ${path}`
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,66 +1,66 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.on('save-dialog', event => {
|
ipcMain.on('save-dialog', event => {
|
||||||
const options = {
|
const options = {
|
||||||
title: 'Save an Image',
|
title: 'Save an Image',
|
||||||
filters: [{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }]
|
filters: [{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }]
|
||||||
}
|
}
|
||||||
dialog.showSaveDialog(options, filename => {
|
dialog.showSaveDialog(options, filename => {
|
||||||
event.sender.send('saved-file', filename)
|
event.sender.send('saved-file', filename)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
const { ipcRenderer, shell } = require('electron')
|
const { ipcRenderer, shell } = require('electron')
|
||||||
|
|
||||||
const saveBtn = document.getElementById('save-dialog')
|
const saveBtn = document.getElementById('save-dialog')
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
saveBtn.addEventListener('click', event => {
|
saveBtn.addEventListener('click', event => {
|
||||||
ipcRenderer.send('save-dialog')
|
ipcRenderer.send('save-dialog')
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('saved-file', (event, path) => {
|
ipcRenderer.on('saved-file', (event, path) => {
|
||||||
if (!path) path = 'No path'
|
if (!path) path = 'No path'
|
||||||
document.getElementById('file-saved').innerHTML = `Path selected: ${path}`
|
document.getElementById('file-saved').innerHTML = `Path selected: ${path}`
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -1,56 +1,56 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
const { shell } = require('electron')
|
const { shell } = require('electron')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
|
|
||||||
const exLinksBtn = document.getElementById('open-ex-links')
|
const exLinksBtn = document.getElementById('open-ex-links')
|
||||||
const fileManagerBtn = document.getElementById('open-file-manager')
|
const fileManagerBtn = document.getElementById('open-file-manager')
|
||||||
|
|
||||||
fileManagerBtn.addEventListener('click', (event) => {
|
fileManagerBtn.addEventListener('click', (event) => {
|
||||||
shell.showItemInFolder(os.homedir())
|
shell.showItemInFolder(os.homedir())
|
||||||
})
|
})
|
||||||
|
|
||||||
exLinksBtn.addEventListener('click', (event) => {
|
exLinksBtn.addEventListener('click', (event) => {
|
||||||
shell.openExternal('https://electronjs.org')
|
shell.openExternal('https://electronjs.org')
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
const basicNotification = {
|
const basicNotification = {
|
||||||
title: 'Basic Notification',
|
title: 'Basic Notification',
|
||||||
body: 'Short message part'
|
body: 'Short message part'
|
||||||
}
|
}
|
||||||
|
|
||||||
const notification = {
|
const notification = {
|
||||||
title: 'Notification with image',
|
title: 'Notification with image',
|
||||||
body: 'Short message plus a custom image',
|
body: 'Short message plus a custom image',
|
||||||
icon: 'https://via.placeholder.com/150'
|
icon: 'https://via.placeholder.com/150'
|
||||||
}
|
}
|
||||||
|
|
||||||
const basicNotificationButton = document.getElementById('basic-noti')
|
const basicNotificationButton = document.getElementById('basic-noti')
|
||||||
const notificationButton = document.getElementById('advanced-noti')
|
const notificationButton = document.getElementById('advanced-noti')
|
||||||
|
|
||||||
notificationButton.addEventListener('click', () => {
|
notificationButton.addEventListener('click', () => {
|
||||||
const myNotification = new window.Notification(notification.title, notification)
|
const myNotification = new window.Notification(notification.title, notification)
|
||||||
|
|
||||||
myNotification.onclick = () => {
|
myNotification.onclick = () => {
|
||||||
console.log('Notification clicked')
|
console.log('Notification clicked')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
basicNotificationButton.addEventListener('click', () => {
|
basicNotificationButton.addEventListener('click', () => {
|
||||||
const myNotification = new window.Notification(basicNotification.title, basicNotification)
|
const myNotification = new window.Notification(basicNotification.title, basicNotification)
|
||||||
|
|
||||||
myNotification.onclick = () => {
|
myNotification.onclick = () => {
|
||||||
console.log('Notification clicked')
|
console.log('Notification clicked')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,35 +1,35 @@
|
||||||
const { ipcRenderer, shell } = require('electron')
|
const { ipcRenderer, shell } = require('electron')
|
||||||
|
|
||||||
const trayBtn = document.getElementById('put-in-tray')
|
const trayBtn = document.getElementById('put-in-tray')
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
let trayOn = false
|
let trayOn = false
|
||||||
|
|
||||||
trayBtn.addEventListener('click', function (event) {
|
trayBtn.addEventListener('click', function (event) {
|
||||||
if (trayOn) {
|
if (trayOn) {
|
||||||
trayOn = false
|
trayOn = false
|
||||||
document.getElementById('tray-countdown').innerHTML = ''
|
document.getElementById('tray-countdown').innerHTML = ''
|
||||||
ipcRenderer.send('remove-tray')
|
ipcRenderer.send('remove-tray')
|
||||||
} else {
|
} else {
|
||||||
trayOn = true
|
trayOn = true
|
||||||
const message = 'Click demo again to remove.'
|
const message = 'Click demo again to remove.'
|
||||||
document.getElementById('tray-countdown').innerHTML = message
|
document.getElementById('tray-countdown').innerHTML = message
|
||||||
ipcRenderer.send('put-in-tray')
|
ipcRenderer.send('put-in-tray')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// Tray removed from context menu on icon
|
// Tray removed from context menu on icon
|
||||||
ipcRenderer.on('tray-removed', function () {
|
ipcRenderer.on('tray-removed', function () {
|
||||||
ipcRenderer.send('remove-tray')
|
ipcRenderer.send('remove-tray')
|
||||||
trayOn = false
|
trayOn = false
|
||||||
document.getElementById('tray-countdown').innerHTML = ''
|
document.getElementById('tray-countdown').innerHTML = ''
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
|
@ -1,56 +1,56 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
const { BrowserWindow } = require('electron').remote
|
const { BrowserWindow } = require('electron').remote
|
||||||
const shell = require('electron').shell
|
const shell = require('electron').shell
|
||||||
|
|
||||||
const framelessWindowBtn = document.getElementById('frameless-window')
|
const framelessWindowBtn = document.getElementById('frameless-window')
|
||||||
|
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
framelessWindowBtn.addEventListener('click', (event) => {
|
framelessWindowBtn.addEventListener('click', (event) => {
|
||||||
const modalPath = 'https://electronjs.org'
|
const modalPath = 'https://electronjs.org'
|
||||||
let win = new BrowserWindow({ frame: false })
|
let win = new BrowserWindow({ frame: false })
|
||||||
|
|
||||||
win.on('close', () => { win = null })
|
win.on('close', () => { win = null })
|
||||||
win.loadURL(modalPath)
|
win.loadURL(modalPath)
|
||||||
win.show()
|
win.show()
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
const { BrowserWindow } = require('electron').remote
|
const { BrowserWindow } = require('electron').remote
|
||||||
const shell = require('electron').shell
|
const shell = require('electron').shell
|
||||||
|
|
||||||
const manageWindowBtn = document.getElementById('manage-window')
|
const manageWindowBtn = document.getElementById('manage-window')
|
||||||
|
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
let win
|
let win
|
||||||
|
|
||||||
manageWindowBtn.addEventListener('click', (event) => {
|
manageWindowBtn.addEventListener('click', (event) => {
|
||||||
const modalPath = 'https://electronjs.org'
|
const modalPath = 'https://electronjs.org'
|
||||||
win = new BrowserWindow({ width: 400, height: 275 })
|
win = new BrowserWindow({ width: 400, height: 275 })
|
||||||
|
|
||||||
win.on('resize', updateReply)
|
win.on('resize', updateReply)
|
||||||
win.on('move', updateReply)
|
win.on('move', updateReply)
|
||||||
win.on('close', () => { win = null })
|
win.on('close', () => { win = null })
|
||||||
win.loadURL(modalPath)
|
win.loadURL(modalPath)
|
||||||
win.show()
|
win.show()
|
||||||
|
|
||||||
function updateReply () {
|
function updateReply () {
|
||||||
const manageWindowReply = document.getElementById('manage-window-reply')
|
const manageWindowReply = document.getElementById('manage-window-reply')
|
||||||
const message = `Size: ${win.getSize()} Position: ${win.getPosition()}`
|
const message = `Size: ${win.getSize()} Position: ${win.getPosition()}`
|
||||||
manageWindowReply.innerText = message
|
manageWindowReply.innerText = message
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
// Modules to control application life and create native browser window
|
// Modules to control application life and create native browser window
|
||||||
const { app, BrowserWindow } = require('electron')
|
const { app, BrowserWindow } = require('electron')
|
||||||
|
|
||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
let mainWindow
|
let mainWindow
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('index.html')
|
mainWindow.loadFile('index.html')
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
// mainWindow.webContents.openDevTools()
|
// mainWindow.webContents.openDevTools()
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on('closed', function () {
|
mainWindow.on('closed', function () {
|
||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.whenReady().then(createWindow)
|
app.whenReady().then(createWindow)
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On macOS it is common for applications and their menu bar
|
// On macOS it is common for applications and their menu bar
|
||||||
// to stay active until the user quits explicitly with Cmd + Q
|
// to stay active until the user quits explicitly with Cmd + Q
|
||||||
if (process.platform !== 'darwin') {
|
if (process.platform !== 'darwin') {
|
||||||
app.quit()
|
app.quit()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('activate', function () {
|
app.on('activate', function () {
|
||||||
// On macOS it is common to re-create a window in the app when the
|
// On macOS it is common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// In this file you can include the rest of your app's specific main process
|
// In this file you can include the rest of your app's specific main process
|
||||||
// code. You can also put them in separate files and require them here.
|
// code. You can also put them in separate files and require them here.
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
const { BrowserWindow } = require('electron').remote
|
const { BrowserWindow } = require('electron').remote
|
||||||
const shell = require('electron').shell
|
const shell = require('electron').shell
|
||||||
|
|
||||||
const listenToWindowBtn = document.getElementById('listen-to-window')
|
const listenToWindowBtn = document.getElementById('listen-to-window')
|
||||||
const focusModalBtn = document.getElementById('focus-on-modal-window')
|
const focusModalBtn = document.getElementById('focus-on-modal-window')
|
||||||
|
|
||||||
const links = document.querySelectorAll('a[href]')
|
const links = document.querySelectorAll('a[href]')
|
||||||
|
|
||||||
let win
|
let win
|
||||||
|
|
||||||
listenToWindowBtn.addEventListener('click', () => {
|
listenToWindowBtn.addEventListener('click', () => {
|
||||||
const modalPath = 'https://electronjs.org'
|
const modalPath = 'https://electronjs.org'
|
||||||
win = new BrowserWindow({ width: 600, height: 400 })
|
win = new BrowserWindow({ width: 600, height: 400 })
|
||||||
|
|
||||||
const hideFocusBtn = () => {
|
const hideFocusBtn = () => {
|
||||||
focusModalBtn.classList.add('disappear')
|
focusModalBtn.classList.add('disappear')
|
||||||
focusModalBtn.classList.remove('smooth-appear')
|
focusModalBtn.classList.remove('smooth-appear')
|
||||||
focusModalBtn.removeEventListener('click', clickHandler)
|
focusModalBtn.removeEventListener('click', clickHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
const showFocusBtn = (btn) => {
|
const showFocusBtn = (btn) => {
|
||||||
if (!win) return
|
if (!win) return
|
||||||
focusModalBtn.classList.add('smooth-appear')
|
focusModalBtn.classList.add('smooth-appear')
|
||||||
focusModalBtn.classList.remove('disappear')
|
focusModalBtn.classList.remove('disappear')
|
||||||
focusModalBtn.addEventListener('click', clickHandler)
|
focusModalBtn.addEventListener('click', clickHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
win.on('focus', hideFocusBtn)
|
win.on('focus', hideFocusBtn)
|
||||||
win.on('blur', showFocusBtn)
|
win.on('blur', showFocusBtn)
|
||||||
win.on('close', () => {
|
win.on('close', () => {
|
||||||
hideFocusBtn()
|
hideFocusBtn()
|
||||||
win = null
|
win = null
|
||||||
})
|
})
|
||||||
win.loadURL(modalPath)
|
win.loadURL(modalPath)
|
||||||
win.show()
|
win.show()
|
||||||
|
|
||||||
const clickHandler = () => { win.focus() }
|
const clickHandler = () => { win.focus() }
|
||||||
})
|
})
|
||||||
|
|
||||||
Array.prototype.forEach.call(links, (link) => {
|
Array.prototype.forEach.call(links, (link) => {
|
||||||
const url = link.getAttribute('href')
|
const url = link.getAttribute('href')
|
||||||
if (url.indexOf('http') === 0) {
|
if (url.indexOf('http') === 0) {
|
||||||
link.addEventListener('click', (e) => {
|
link.addEventListener('click', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shell.openExternal(url)
|
shell.openExternal(url)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "electron",
|
"name": "electron",
|
||||||
"version": "11.0.0-nightly.20200826",
|
"version": "12.0.0-nightly.20200827",
|
||||||
"repository": "https://github.com/electron/electron",
|
"repository": "https://github.com/electron/electron",
|
||||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
param([string]$gomaDir=$PWD)
|
param([string]$gomaDir=$PWD)
|
||||||
$cmdPath = Join-Path -Path $gomaDir -ChildPath "goma_ctl.py"
|
$cmdPath = Join-Path -Path $gomaDir -ChildPath "goma_ctl.py"
|
||||||
Start-Process -FilePath cmd -ArgumentList "/C", "python", "$cmdPath", "ensure_start"
|
Start-Process -FilePath cmd -ArgumentList "/C", "python", "$cmdPath", "ensure_start"
|
||||||
$timedOut = $false; $waitTime = 0; $waitIncrement = 5; $timeout=120;
|
$timedOut = $false; $waitTime = 0; $waitIncrement = 5; $timeout=120;
|
||||||
Do { sleep $waitIncrement; $timedOut = (($waitTime+=$waitIncrement) -gt $timeout); iex "$gomaDir\gomacc.exe port 2" > $null; } Until(($LASTEXITCODE -eq 0) -or $timedOut)
|
Do { sleep $waitIncrement; $timedOut = (($waitTime+=$waitIncrement) -gt $timeout); iex "$gomaDir\gomacc.exe port 2" > $null; } Until(($LASTEXITCODE -eq 0) -or $timedOut)
|
||||||
if ($timedOut) {
|
if ($timedOut) {
|
||||||
write-error 'Timed out waiting for goma to start'; exit 1;
|
write-error 'Timed out waiting for goma to start'; exit 1;
|
||||||
} else {
|
} else {
|
||||||
Write-Output "Successfully started goma!"
|
Write-Output "Successfully started goma!"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +1,65 @@
|
||||||
// Copyright (c) 2019 GitHub, Inc.
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "shell/browser/electron_autofill_driver.h"
|
#include "shell/browser/electron_autofill_driver.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "content/public/browser/render_widget_host_view.h"
|
#include "content/public/browser/render_widget_host_view.h"
|
||||||
#include "shell/browser/api/electron_api_web_contents.h"
|
#include "shell/browser/api/electron_api_web_contents.h"
|
||||||
#include "shell/browser/javascript_environment.h"
|
#include "shell/browser/javascript_environment.h"
|
||||||
#include "shell/browser/native_window.h"
|
#include "shell/browser/native_window.h"
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
AutofillDriver::AutofillDriver(
|
AutofillDriver::AutofillDriver(
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
mojom::ElectronAutofillDriverAssociatedRequest request)
|
mojom::ElectronAutofillDriverAssociatedRequest request)
|
||||||
: render_frame_host_(render_frame_host), binding_(this) {
|
: render_frame_host_(render_frame_host), binding_(this) {
|
||||||
autofill_popup_ = std::make_unique<AutofillPopup>();
|
autofill_popup_ = std::make_unique<AutofillPopup>();
|
||||||
binding_.Bind(std::move(request));
|
binding_.Bind(std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
AutofillDriver::~AutofillDriver() = default;
|
AutofillDriver::~AutofillDriver() = default;
|
||||||
|
|
||||||
void AutofillDriver::ShowAutofillPopup(
|
void AutofillDriver::ShowAutofillPopup(
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) {
|
const std::vector<base::string16>& labels) {
|
||||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||||
v8::HandleScope scope(isolate);
|
v8::HandleScope scope(isolate);
|
||||||
auto* web_contents = api::WebContents::From(
|
auto* web_contents = api::WebContents::From(
|
||||||
content::WebContents::FromRenderFrameHost(render_frame_host_));
|
content::WebContents::FromRenderFrameHost(render_frame_host_));
|
||||||
if (!web_contents || !web_contents->owner_window())
|
if (!web_contents || !web_contents->owner_window())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto* embedder = web_contents->embedder();
|
auto* embedder = web_contents->embedder();
|
||||||
|
|
||||||
bool osr =
|
bool osr =
|
||||||
web_contents->IsOffScreen() || (embedder && embedder->IsOffScreen());
|
web_contents->IsOffScreen() || (embedder && embedder->IsOffScreen());
|
||||||
gfx::RectF popup_bounds(bounds);
|
gfx::RectF popup_bounds(bounds);
|
||||||
content::RenderFrameHost* embedder_frame_host = nullptr;
|
content::RenderFrameHost* embedder_frame_host = nullptr;
|
||||||
if (embedder) {
|
if (embedder) {
|
||||||
auto* embedder_view = embedder->web_contents()->GetMainFrame()->GetView();
|
auto* embedder_view = embedder->web_contents()->GetMainFrame()->GetView();
|
||||||
auto* view = web_contents->web_contents()->GetMainFrame()->GetView();
|
auto* view = web_contents->web_contents()->GetMainFrame()->GetView();
|
||||||
auto offset = view->GetViewBounds().origin() -
|
auto offset = view->GetViewBounds().origin() -
|
||||||
embedder_view->GetViewBounds().origin();
|
embedder_view->GetViewBounds().origin();
|
||||||
popup_bounds.Offset(offset);
|
popup_bounds.Offset(offset);
|
||||||
embedder_frame_host = embedder->web_contents()->GetMainFrame();
|
embedder_frame_host = embedder->web_contents()->GetMainFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
autofill_popup_->CreateView(render_frame_host_, embedder_frame_host, osr,
|
autofill_popup_->CreateView(render_frame_host_, embedder_frame_host, osr,
|
||||||
web_contents->owner_window()->content_view(),
|
web_contents->owner_window()->content_view(),
|
||||||
popup_bounds);
|
popup_bounds);
|
||||||
autofill_popup_->SetItems(values, labels);
|
autofill_popup_->SetItems(values, labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillDriver::HideAutofillPopup() {
|
void AutofillDriver::HideAutofillPopup() {
|
||||||
if (autofill_popup_)
|
if (autofill_popup_)
|
||||||
autofill_popup_->Hide();
|
autofill_popup_->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
// Copyright (c) 2019 GitHub, Inc.
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_H_
|
#ifndef SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_H_
|
||||||
#define SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_H_
|
#define SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
#include "shell/browser/ui/autofill_popup.h"
|
#include "shell/browser/ui/autofill_popup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mojo/public/cpp/bindings/associated_binding.h"
|
#include "mojo/public/cpp/bindings/associated_binding.h"
|
||||||
#include "shell/common/api/api.mojom.h"
|
#include "shell/common/api/api.mojom.h"
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
class AutofillDriver : public mojom::ElectronAutofillDriver {
|
class AutofillDriver : public mojom::ElectronAutofillDriver {
|
||||||
public:
|
public:
|
||||||
AutofillDriver(content::RenderFrameHost* render_frame_host,
|
AutofillDriver(content::RenderFrameHost* render_frame_host,
|
||||||
mojom::ElectronAutofillDriverAssociatedRequest request);
|
mojom::ElectronAutofillDriverAssociatedRequest request);
|
||||||
|
|
||||||
~AutofillDriver() override;
|
~AutofillDriver() override;
|
||||||
|
|
||||||
void ShowAutofillPopup(const gfx::RectF& bounds,
|
void ShowAutofillPopup(const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) override;
|
const std::vector<base::string16>& labels) override;
|
||||||
void HideAutofillPopup() override;
|
void HideAutofillPopup() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
content::RenderFrameHost* const render_frame_host_;
|
content::RenderFrameHost* const render_frame_host_;
|
||||||
|
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
std::unique_ptr<AutofillPopup> autofill_popup_;
|
std::unique_ptr<AutofillPopup> autofill_popup_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mojo::AssociatedBinding<mojom::ElectronAutofillDriver> binding_;
|
mojo::AssociatedBinding<mojom::ElectronAutofillDriver> binding_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
||||||
#endif // SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_H_
|
#endif // SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_H_
|
||||||
|
|
|
@ -1,111 +1,111 @@
|
||||||
// Copyright (c) 2019 GitHub, Inc.
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "shell/browser/electron_autofill_driver_factory.h"
|
#include "shell/browser/electron_autofill_driver_factory.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "content/public/browser/navigation_handle.h"
|
#include "content/public/browser/navigation_handle.h"
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "shell/browser/electron_autofill_driver.h"
|
#include "shell/browser/electron_autofill_driver.h"
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::unique_ptr<AutofillDriver> CreateDriver(
|
std::unique_ptr<AutofillDriver> CreateDriver(
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
mojom::ElectronAutofillDriverAssociatedRequest request) {
|
mojom::ElectronAutofillDriverAssociatedRequest request) {
|
||||||
return std::make_unique<AutofillDriver>(render_frame_host,
|
return std::make_unique<AutofillDriver>(render_frame_host,
|
||||||
std::move(request));
|
std::move(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AutofillDriverFactory::~AutofillDriverFactory() = default;
|
AutofillDriverFactory::~AutofillDriverFactory() = default;
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void AutofillDriverFactory::BindAutofillDriver(
|
void AutofillDriverFactory::BindAutofillDriver(
|
||||||
mojom::ElectronAutofillDriverAssociatedRequest request,
|
mojom::ElectronAutofillDriverAssociatedRequest request,
|
||||||
content::RenderFrameHost* render_frame_host) {
|
content::RenderFrameHost* render_frame_host) {
|
||||||
content::WebContents* web_contents =
|
content::WebContents* web_contents =
|
||||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AutofillDriverFactory* factory =
|
AutofillDriverFactory* factory =
|
||||||
AutofillDriverFactory::FromWebContents(web_contents);
|
AutofillDriverFactory::FromWebContents(web_contents);
|
||||||
if (!factory)
|
if (!factory)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AutofillDriver* driver = factory->DriverForFrame(render_frame_host);
|
AutofillDriver* driver = factory->DriverForFrame(render_frame_host);
|
||||||
if (!driver)
|
if (!driver)
|
||||||
factory->AddDriverForFrame(
|
factory->AddDriverForFrame(
|
||||||
render_frame_host,
|
render_frame_host,
|
||||||
base::BindOnce(CreateDriver, render_frame_host, std::move(request)));
|
base::BindOnce(CreateDriver, render_frame_host, std::move(request)));
|
||||||
}
|
}
|
||||||
|
|
||||||
AutofillDriverFactory::AutofillDriverFactory(content::WebContents* web_contents)
|
AutofillDriverFactory::AutofillDriverFactory(content::WebContents* web_contents)
|
||||||
: content::WebContentsObserver(web_contents) {
|
: content::WebContentsObserver(web_contents) {
|
||||||
const std::vector<content::RenderFrameHost*> frames =
|
const std::vector<content::RenderFrameHost*> frames =
|
||||||
web_contents->GetAllFrames();
|
web_contents->GetAllFrames();
|
||||||
for (content::RenderFrameHost* frame : frames) {
|
for (content::RenderFrameHost* frame : frames) {
|
||||||
if (frame->IsRenderFrameLive())
|
if (frame->IsRenderFrameLive())
|
||||||
RenderFrameCreated(frame);
|
RenderFrameCreated(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillDriverFactory::RenderFrameDeleted(
|
void AutofillDriverFactory::RenderFrameDeleted(
|
||||||
content::RenderFrameHost* render_frame_host) {
|
content::RenderFrameHost* render_frame_host) {
|
||||||
DeleteDriverForFrame(render_frame_host);
|
DeleteDriverForFrame(render_frame_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillDriverFactory::DidFinishNavigation(
|
void AutofillDriverFactory::DidFinishNavigation(
|
||||||
content::NavigationHandle* navigation_handle) {
|
content::NavigationHandle* navigation_handle) {
|
||||||
// For the purposes of this code, a navigation is not important if it has not
|
// For the purposes of this code, a navigation is not important if it has not
|
||||||
// committed yet or if it's in a subframe.
|
// committed yet or if it's in a subframe.
|
||||||
if (!navigation_handle->HasCommitted() ||
|
if (!navigation_handle->HasCommitted() ||
|
||||||
!navigation_handle->IsInMainFrame()) {
|
!navigation_handle->IsInMainFrame()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseAllPopups();
|
CloseAllPopups();
|
||||||
}
|
}
|
||||||
|
|
||||||
AutofillDriver* AutofillDriverFactory::DriverForFrame(
|
AutofillDriver* AutofillDriverFactory::DriverForFrame(
|
||||||
content::RenderFrameHost* render_frame_host) {
|
content::RenderFrameHost* render_frame_host) {
|
||||||
auto mapping = driver_map_.find(render_frame_host);
|
auto mapping = driver_map_.find(render_frame_host);
|
||||||
return mapping == driver_map_.end() ? nullptr : mapping->second.get();
|
return mapping == driver_map_.end() ? nullptr : mapping->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillDriverFactory::AddDriverForFrame(
|
void AutofillDriverFactory::AddDriverForFrame(
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
CreationCallback factory_method) {
|
CreationCallback factory_method) {
|
||||||
auto insertion_result =
|
auto insertion_result =
|
||||||
driver_map_.insert(std::make_pair(render_frame_host, nullptr));
|
driver_map_.insert(std::make_pair(render_frame_host, nullptr));
|
||||||
// This can be called twice for the key representing the main frame.
|
// This can be called twice for the key representing the main frame.
|
||||||
if (insertion_result.second) {
|
if (insertion_result.second) {
|
||||||
insertion_result.first->second = std::move(factory_method).Run();
|
insertion_result.first->second = std::move(factory_method).Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillDriverFactory::DeleteDriverForFrame(
|
void AutofillDriverFactory::DeleteDriverForFrame(
|
||||||
content::RenderFrameHost* render_frame_host) {
|
content::RenderFrameHost* render_frame_host) {
|
||||||
driver_map_.erase(render_frame_host);
|
driver_map_.erase(render_frame_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutofillDriverFactory::CloseAllPopups() {
|
void AutofillDriverFactory::CloseAllPopups() {
|
||||||
for (auto& it : driver_map_) {
|
for (auto& it : driver_map_) {
|
||||||
it.second->HideAutofillPopup();
|
it.second->HideAutofillPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WEB_CONTENTS_USER_DATA_KEY_IMPL(AutofillDriverFactory)
|
WEB_CONTENTS_USER_DATA_KEY_IMPL(AutofillDriverFactory)
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
|
@ -1,57 +1,57 @@
|
||||||
// Copyright (c) 2019 GitHub, Inc.
|
// Copyright (c) 2019 GitHub, Inc.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_FACTORY_H_
|
#ifndef SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_FACTORY_H_
|
||||||
#define SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_FACTORY_H_
|
#define SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_FACTORY_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "base/callback_forward.h"
|
#include "base/callback_forward.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
#include "content/public/browser/web_contents_user_data.h"
|
#include "content/public/browser/web_contents_user_data.h"
|
||||||
#include "shell/common/api/api.mojom.h"
|
#include "shell/common/api/api.mojom.h"
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
class AutofillDriver;
|
class AutofillDriver;
|
||||||
|
|
||||||
class AutofillDriverFactory
|
class AutofillDriverFactory
|
||||||
: public content::WebContentsObserver,
|
: public content::WebContentsObserver,
|
||||||
public content::WebContentsUserData<AutofillDriverFactory> {
|
public content::WebContentsUserData<AutofillDriverFactory> {
|
||||||
public:
|
public:
|
||||||
typedef base::OnceCallback<std::unique_ptr<AutofillDriver>()>
|
typedef base::OnceCallback<std::unique_ptr<AutofillDriver>()>
|
||||||
CreationCallback;
|
CreationCallback;
|
||||||
|
|
||||||
~AutofillDriverFactory() override;
|
~AutofillDriverFactory() override;
|
||||||
|
|
||||||
static void BindAutofillDriver(
|
static void BindAutofillDriver(
|
||||||
mojom::ElectronAutofillDriverAssociatedRequest request,
|
mojom::ElectronAutofillDriverAssociatedRequest request,
|
||||||
content::RenderFrameHost* render_frame_host);
|
content::RenderFrameHost* render_frame_host);
|
||||||
|
|
||||||
// content::WebContentsObserver:
|
// content::WebContentsObserver:
|
||||||
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
||||||
void DidFinishNavigation(
|
void DidFinishNavigation(
|
||||||
content::NavigationHandle* navigation_handle) override;
|
content::NavigationHandle* navigation_handle) override;
|
||||||
|
|
||||||
AutofillDriver* DriverForFrame(content::RenderFrameHost* render_frame_host);
|
AutofillDriver* DriverForFrame(content::RenderFrameHost* render_frame_host);
|
||||||
void AddDriverForFrame(content::RenderFrameHost* render_frame_host,
|
void AddDriverForFrame(content::RenderFrameHost* render_frame_host,
|
||||||
CreationCallback factory_method);
|
CreationCallback factory_method);
|
||||||
void DeleteDriverForFrame(content::RenderFrameHost* render_frame_host);
|
void DeleteDriverForFrame(content::RenderFrameHost* render_frame_host);
|
||||||
|
|
||||||
void CloseAllPopups();
|
void CloseAllPopups();
|
||||||
|
|
||||||
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit AutofillDriverFactory(content::WebContents* web_contents);
|
explicit AutofillDriverFactory(content::WebContents* web_contents);
|
||||||
friend class content::WebContentsUserData<AutofillDriverFactory>;
|
friend class content::WebContentsUserData<AutofillDriverFactory>;
|
||||||
|
|
||||||
std::unordered_map<content::RenderFrameHost*, std::unique_ptr<AutofillDriver>>
|
std::unordered_map<content::RenderFrameHost*, std::unique_ptr<AutofillDriver>>
|
||||||
driver_map_;
|
driver_map_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
||||||
#endif // SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_FACTORY_H_
|
#endif // SHELL_BROWSER_ELECTRON_AUTOFILL_DRIVER_FACTORY_H_
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
// Copyright (c) 2020 Samuel Maddock <sam@samuelmaddock.com>.
|
// Copyright (c) 2020 Samuel Maddock <sam@samuelmaddock.com>.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "shell/browser/extensions/api/i18n/i18n_api.h"
|
#include "shell/browser/extensions/api/i18n/i18n_api.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "chrome/browser/browser_process.h"
|
#include "chrome/browser/browser_process.h"
|
||||||
#include "shell/common/extensions/api/i18n.h"
|
#include "shell/common/extensions/api/i18n.h"
|
||||||
|
|
||||||
namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages;
|
namespace GetAcceptLanguages = extensions::api::i18n::GetAcceptLanguages;
|
||||||
|
|
||||||
namespace extensions {
|
namespace extensions {
|
||||||
|
|
||||||
ExtensionFunction::ResponseAction I18nGetAcceptLanguagesFunction::Run() {
|
ExtensionFunction::ResponseAction I18nGetAcceptLanguagesFunction::Run() {
|
||||||
auto locale = g_browser_process->GetApplicationLocale();
|
auto locale = g_browser_process->GetApplicationLocale();
|
||||||
std::vector<std::string> accept_languages = {locale};
|
std::vector<std::string> accept_languages = {locale};
|
||||||
return RespondNow(
|
return RespondNow(
|
||||||
ArgumentList(GetAcceptLanguages::Results::Create(accept_languages)));
|
ArgumentList(GetAcceptLanguages::Results::Create(accept_languages)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace extensions
|
} // namespace extensions
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
// Copyright (c) 2020 Samuel Maddock <sam@samuelmaddock.com>.
|
// Copyright (c) 2020 Samuel Maddock <sam@samuelmaddock.com>.
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
|
#ifndef SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
|
||||||
#define SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
|
#define SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
|
||||||
|
|
||||||
#include "extensions/browser/extension_function.h"
|
#include "extensions/browser/extension_function.h"
|
||||||
|
|
||||||
namespace extensions {
|
namespace extensions {
|
||||||
|
|
||||||
class I18nGetAcceptLanguagesFunction : public ExtensionFunction {
|
class I18nGetAcceptLanguagesFunction : public ExtensionFunction {
|
||||||
~I18nGetAcceptLanguagesFunction() override {}
|
~I18nGetAcceptLanguagesFunction() override {}
|
||||||
ResponseAction Run() override;
|
ResponseAction Run() override;
|
||||||
DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES)
|
DECLARE_EXTENSION_FUNCTION("i18n.getAcceptLanguages", I18N_GETACCEPTLANGUAGES)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace extensions
|
} // namespace extensions
|
||||||
|
|
||||||
#endif // SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
|
#endif // SHELL_BROWSER_EXTENSIONS_API_I18N_I18N_API_H_
|
||||||
|
|
|
@ -50,8 +50,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 11,0,0,20200826
|
FILEVERSION 12,0,0,20200827
|
||||||
PRODUCTVERSION 11,0,0,20200826
|
PRODUCTVERSION 12,0,0,20200827
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -68,12 +68,12 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "GitHub, Inc."
|
VALUE "CompanyName", "GitHub, Inc."
|
||||||
VALUE "FileDescription", "Electron"
|
VALUE "FileDescription", "Electron"
|
||||||
VALUE "FileVersion", "11.0.0"
|
VALUE "FileVersion", "12.0.0"
|
||||||
VALUE "InternalName", "electron.exe"
|
VALUE "InternalName", "electron.exe"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||||
VALUE "OriginalFilename", "electron.exe"
|
VALUE "OriginalFilename", "electron.exe"
|
||||||
VALUE "ProductName", "Electron"
|
VALUE "ProductName", "Electron"
|
||||||
VALUE "ProductVersion", "11.0.0"
|
VALUE "ProductVersion", "12.0.0"
|
||||||
VALUE "SquirrelAwareVersion", "1"
|
VALUE "SquirrelAwareVersion", "1"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
self.addEventListener('install', function (event) {
|
self.addEventListener('install', function (event) {
|
||||||
console.log('log log');
|
console.log('log log');
|
||||||
console.info('info log');
|
console.info('info log');
|
||||||
console.warn('warn log');
|
console.warn('warn log');
|
||||||
console.error('error log');
|
console.error('error log');
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
self.addEventListener('install', function (event) {
|
self.addEventListener('install', function (event) {
|
||||||
console.log('Installed');
|
console.log('Installed');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue