Skip to content

Commit

Permalink
refactor: clean up the default app implementation (#14719)
Browse files Browse the repository at this point in the history
* Disable nodeIntegration
* Enable contextIsolation
* Re-implement the CSP security check to handle running in
contextIsolation
* Disable bad DCHECKS for the promise helper
* Remove the unused "-d" flag for the electron binary
* Added a way to hide the default help output for electron devs who
don't want to see it every time
  • Loading branch information
MarshallOfSound committed Sep 21, 2018
1 parent a24307b commit 32a9df2
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 305 deletions.
1 change: 0 additions & 1 deletion atom/common/promise_util.cc
Expand Up @@ -11,7 +11,6 @@ namespace atom {
namespace util {

Promise::Promise(v8::Isolate* isolate) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
isolate_ = isolate;
resolver_.Reset(isolate, v8::Promise::Resolver::New(isolate));
}
Expand Down
1 change: 0 additions & 1 deletion atom/common/promise_util.h
Expand Up @@ -52,7 +52,6 @@ class Promise {

private:
v8::Local<v8::Promise::Resolver> GetInner() const {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return resolver_.Get(isolate());
}

Expand Down
52 changes: 28 additions & 24 deletions default_app/default_app.js
Expand Up @@ -8,28 +8,32 @@ app.on('window-all-closed', () => {
app.quit()
})

exports.load = (appUrl) => {
app.on('ready', () => {
const options = {
width: 900,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
webPreferences: {
nodeIntegrationInWorker: true
},
useContentSize: true,
show: false
}
if (process.platform === 'linux') {
options.icon = path.join(__dirname, 'icon.png')
}

mainWindow = new BrowserWindow(options)

mainWindow.on('ready-to-show', () => mainWindow.show())

mainWindow.loadURL(appUrl)
mainWindow.focus()
})
exports.load = async (appUrl) => {
await app.whenReady()

const options = {
width: 900,
height: 600,
autoHideMenuBar: true,
backgroundColor: '#FFFFFF',
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
preload: path.resolve(__dirname, 'renderer.js'),
webviewTag: false
},
useContentSize: true,
show: false
}

if (process.platform === 'linux') {
options.icon = path.join(__dirname, 'icon.png')
}

mainWindow = new BrowserWindow(options)

mainWindow.on('ready-to-show', () => mainWindow.show())

mainWindow.loadURL(appUrl)
mainWindow.focus()
}
2 changes: 0 additions & 2 deletions default_app/index.html
Expand Up @@ -83,8 +83,6 @@ <h4>Forge</h4>
</div>
</div>
</nav>

<script src="./renderer.js"></script>
</body>

</html>

0 comments on commit 32a9df2

Please sign in to comment.