electron-194: adds support to set chrome flags

This commit is contained in:
Vishwas Shashidhar 2017-10-26 16:53:15 +05:30
parent 0fd57a8dd0
commit 6f28edc5bb
3 changed files with 61 additions and 2 deletions

View File

@ -11,5 +11,9 @@
"submitURL": "https://localhost:1127/post",
"companyName": "Symphony",
"uploadToServer": false
},
"customFlags": {
"authServerWhitelist": "",
"authNegotiateDelegateWhitelist": ""
}
}

View File

@ -322,6 +322,34 @@ function clearCachedConfigs() {
globalConfig = null;
}
function readConfigFileSync() {
let configPath;
let globalConfigFileName = path.join('config', configFileName);
if (isDevEnv) {
// for dev env, get config file from asar
configPath = path.join(app.getAppPath(), globalConfigFileName);
} else {
// for non-dev, config file is placed by installer relative to exe.
// this is so the config can be easily be changed post install.
let execPath = path.dirname(app.getPath('exe'));
// for mac exec is stored in subdir, for linux/windows config
// dir is in the same location.
configPath = path.join(execPath, isMac ? '..' : '', globalConfigFileName);
}
let data = fs.readFileSync(configPath);
try {
return JSON.parse(data);
} catch (err) {
console.log("parsing config failed", err);
}
return null;
}
module.exports = {
configFileName,
@ -334,6 +362,8 @@ module.exports = {
// items below here are only exported for testing, do NOT use!
saveUserConfig,
clearCachedConfigs
clearCachedConfigs,
readConfigFileSync
};

View File

@ -10,7 +10,7 @@ const AutoLaunch = require('auto-launch');
const urlParser = require('url');
// Local Dependencies
const {getConfigField, updateUserConfigWin, updateUserConfigMac} = require('./config.js');
const {getConfigField, updateUserConfigWin, updateUserConfigMac, readConfigFileSync} = require('./config.js');
const { isMac, isDevEnv } = require('./utils/misc.js');
const protocolHandler = require('./protocolHandler');
const getCmdLineArg = require('./utils/getCmdLineArg.js');
@ -87,6 +87,31 @@ if (isMac) {
});
}
function setChromeFlags() {
log.send(logLevels.INFO, 'checking if we need to set custom chrome flags!');
let config = readConfigFileSync();
if (config && config !== null && config.customFlags) {
log.send(logLevels.INFO, 'Chrome flags config found!');
if (config.customFlags.authServerWhitelist && config.customFlags.authServerWhitelist !== "") {
log.send(logLevels.INFO, 'Setting auth server whitelist flag');
app.commandLine.appendSwitch('auth-server-whitelist', config.customFlags.authServerWhitelist);
}
if (config.customFlags.authNegotiateDelegateWhitelist && config.customFlags.authNegotiateDelegateWhitelist !== "") {
log.send(logLevels.INFO, 'Setting auth negotiate delegate whitelist flag');
app.commandLine.appendSwitch('auth-negotiate-delegate-whitelist', config.customFlags.authNegotiateDelegateWhitelist);
}
}
}
setChromeFlags();
/**
* This method will be called when Electron has finished
* initialization and is ready to create browser windows.