diff --git a/src/tools/nacldeployqt/template_qtloader.cpp b/src/tools/nacldeployqt/template_qtloader.cpp index fe4bd98aa575e767e234e5bdfa6cd2461a45253b..58a5e4fe77bc5f74ca84bb79346d55917c853651 100644 --- a/src/tools/nacldeployqt/template_qtloader.cpp +++ b/src/tools/nacldeployqt/template_qtloader.cpp @@ -38,16 +38,22 @@ const char *templateQtLoader = R"STRING_DELIMITER( // element.postMessage(message) // ends up in pp::Instance::HandleMessage // element.addEventListener('message', function(message){ ... }) // -// Additional supported Qt constructor config keys -// query : Query string. Qt will parse this for environment variables. +// Additional supported Qt constructor config keys: +// query : Query string. Qt will parse this for pp:Instance::Init() arguments +// environment : JavaScript object with pp::Instance::Init() arguments // isChromeApp : enable Chrome Application package mode // loadText : Loading placeholder text // +// The pp:Instance::Init arguments are available in two ways: +// 1) As argn, argv key/value pairs to Init() of a QPepperInstance subclass. +// 2) As environment variables: toUpper(key)=value. + function QtLoader(config) { var self = this; self.config = config; self.loadText = config.loadText !== undefined ? config.loadText : "Loading Qt:" self.type = config.type !== undefined ? config.type : "%APPTYPE%" + self.environment = config.environment; self.loadTextElement = undefined; self.embed = undefined; self.listener = undefined; @@ -240,6 +246,12 @@ function loadNaCl() embed.setAttribute(key, queryHash[key]) } + // Propagate extra environment variables from QtLoader config. + for (var key in self.environment) { + if (key !== undefined) + embed.setAttribute(key, self.environment[key]) + } + self.listener.appendChild(embed); self.listener.embed = embed; }