Skip to content

Commit 32a9df2

Browse files
refactor: clean up the default app implementation (electron#14719)
* 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
1 parent a24307b commit 32a9df2

File tree

10 files changed

+355
-305
lines changed

10 files changed

+355
-305
lines changed

atom/common/promise_util.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace atom {
1111
namespace util {
1212

1313
Promise::Promise(v8::Isolate* isolate) {
14-
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
1514
isolate_ = isolate;
1615
resolver_.Reset(isolate, v8::Promise::Resolver::New(isolate));
1716
}

atom/common/promise_util.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class Promise {
5252

5353
private:
5454
v8::Local<v8::Promise::Resolver> GetInner() const {
55-
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
5655
return resolver_.Get(isolate());
5756
}
5857

default_app/default_app.js

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,32 @@ app.on('window-all-closed', () => {
88
app.quit()
99
})
1010

11-
exports.load = (appUrl) => {
12-
app.on('ready', () => {
13-
const options = {
14-
width: 900,
15-
height: 600,
16-
autoHideMenuBar: true,
17-
backgroundColor: '#FFFFFF',
18-
webPreferences: {
19-
nodeIntegrationInWorker: true
20-
},
21-
useContentSize: true,
22-
show: false
23-
}
24-
if (process.platform === 'linux') {
25-
options.icon = path.join(__dirname, 'icon.png')
26-
}
27-
28-
mainWindow = new BrowserWindow(options)
29-
30-
mainWindow.on('ready-to-show', () => mainWindow.show())
31-
32-
mainWindow.loadURL(appUrl)
33-
mainWindow.focus()
34-
})
11+
exports.load = async (appUrl) => {
12+
await app.whenReady()
13+
14+
const options = {
15+
width: 900,
16+
height: 600,
17+
autoHideMenuBar: true,
18+
backgroundColor: '#FFFFFF',
19+
webPreferences: {
20+
contextIsolation: true,
21+
nodeIntegration: false,
22+
preload: path.resolve(__dirname, 'renderer.js'),
23+
webviewTag: false
24+
},
25+
useContentSize: true,
26+
show: false
27+
}
28+
29+
if (process.platform === 'linux') {
30+
options.icon = path.join(__dirname, 'icon.png')
31+
}
32+
33+
mainWindow = new BrowserWindow(options)
34+
35+
mainWindow.on('ready-to-show', () => mainWindow.show())
36+
37+
mainWindow.loadURL(appUrl)
38+
mainWindow.focus()
3539
}

default_app/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ <h4>Forge</h4>
8383
</div>
8484
</div>
8585
</nav>
86-
87-
<script src="./renderer.js"></script>
8886
</body>
8987

9088
</html>

0 commit comments

Comments
 (0)