message: implement dynamic chrome command line flags logic
  implement dynamic chrome command line flags logic
  added more validation
diff: @@ -135,9 +135,6 @@ function setChromeFlags() {
  app.commandLine.appendSwitch('auth-negotiate-delegate-whitelist', config.customFlags.authNegotiateDelegateWhitelist);
  }
  - // ELECTRON-261: Windows 10 Screensharing issues. We set chrome flags
  - // to disable gpu which fixes the black screen issue observed on
  - // multiple monitors
  if (config.customFlags.disableGpu) {
  log.send(logLevels.INFO, 'Setting disable gpu, gpu compositing and d3d11 flags to true');
  app.commandLine.appendSwitch("disable-gpu", true);
  @@ -148,6 +145,53 @@ function setChromeFlags() {
  }
  app.commandLine.appendSwitch("disable-background-timer-throttling", true);
  +
  + if (isDevEnv) {
  + setChromeFlagsFromCommandLine();
  + }
  +
  +}
  +
  +function setChromeFlagsFromCommandLine() {
  +
  + log.send(logLevels.INFO, 'Setting chrome flags from command line arguments!');
  +
  + let chromeFlagsFromCmd = getCmdLineArg(process.argv, '--chrome-flags=', false);
  + if (!chromeFlagsFromCmd) {
  + return;
  + }
  +
  + let chromeFlagsArgs = chromeFlagsFromCmd.substr(15);
  + if (!chromeFlagsArgs) {
  + return;
  + }
  +
  + let flags = chromeFlagsArgs.split(',');
  + if (!flags || !Array.isArray(flags)) {
  + return;
  + }
  +
  + for (let key in flags) {
  +
  + if (!Object.prototype.hasOwnProperty.call(flags, key)) {
  + continue;
  + }
  +
  + if (!flags[key]) {
  + return;
  + }
  +
  + let flagArray = flags[key].split(':');
  +
  + if (flagArray && Array.isArray(flagArray) && flagArray.length > 0) {
  + let chromeFlagKey = flagArray[0];
  + let chromeFlagValue = flagArray[1];
  + log.send(logLevels.INFO, `Setting chrome flag ${chromeFlagKey} to ${chromeFlagValue}`);
  + app.commandLine.appendSwitch(chromeFlagKey, chromeFlagValue);
  + }
  +
  + }
  +
  }
  // Set the chrome flags
  