summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2016-02-12 23:56:33 +0100
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>2016-02-12 23:05:01 +0000
commit750a9a7af2f609518427bad227d043349df2eb90 (patch)
treec14b687bbb573d33e542eff67af605d301106524
parent9218b74df738da1b6e8c304641656957d152b501 (diff)
qtlaoder.js: Support adding Init() arguments.
This is useful for sending arguments to the application at startup. QtLoader users can now add key/value pairs to config.environment. QtLoader will forward these as attributes on the embed element. Finally the key/value pairs will end up as arguments to pp::Instance::Init() Change-Id: Ic7ca434e9c097cd624b25692c250daa46a257c2f Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
-rw-r--r--src/tools/nacldeployqt/template_qtloader.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/tools/nacldeployqt/template_qtloader.cpp b/src/tools/nacldeployqt/template_qtloader.cpp
index fe4bd98aa5..58a5e4fe77 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;
}