Adds plugin hook for decorating the electron browser options (#310)

* adds hook for decorating the electron browser options

* pass browser options to decorator
This commit is contained in:
Dan Prince 2016-07-22 01:32:39 +01:00 committed by Guillermo Rauch
parent c573001774
commit b06f28ae10
2 changed files with 21 additions and 2 deletions

View file

@ -48,7 +48,7 @@ app.on('ready', () => {
function createWindow (fn) {
const cfg = plugins.getDecoratedConfig();
const win = new BrowserWindow({
const browserDefaults = {
width: 540,
height: 380,
minHeight: 190,
@ -61,7 +61,10 @@ app.on('ready', () => {
// we only want to show when the prompt
// is ready for user input
show: process.env.HYPERTERM_DEBUG || isDev
});
};
const browserOptions = plugins.getDecoratedBrowserOptions(browserDefaults);
const win = new BrowserWindow(browserOptions);
windowSet.add(win);
win.loadURL(url);

View file

@ -311,3 +311,19 @@ exports.getDecoratedConfig = function () {
});
return decorated;
};
exports.getDecoratedBrowserOptions = function (defaults) {
let decorated = defaults;
modules.forEach((plugin) => {
if (plugin.decorateBrowserOptions) {
const res = plugin.decorateBrowserOptions(decorated);
if (res && 'object' === typeof res) {
decorated = res;
} else {
notify('Plugin error!', `"${plugin._name}": invalid return type for \`decorateBrowserOptions\``);
}
}
});
return decorated;
};