class Runtime {
webApplication?: WebApplication = undefined;
isLaunched = false;
- inspectorEnabledByVconf = false;
constructor() {
app.on('before-quit', (event: any) => {
console.log('Handling app-control event');
this.webApplication.handleAppControlEvent(appControl);
}
- this.launchInspector(appControl);
});
wrt.on('suspend', () => {
private createWebApplicationAndLoadUrl(appControl: any) {
console.log('Creating WebApplication');
let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
- let src = appControl.getLoadInfo().getSrc();
let options: RuntimeOption = {
isAddonAvailable: addonManager.isAddonAvailable(),
launchMode: launchMode
}
this.webApplication = new WebApplication(options);
- if (wrt.tv) {
- this.inspectorEnabledByVconf = wrt.tv.needUseInspector();
- if (this.inspectorEnabledByVconf && launchMode != 'backgroundExecution') {
- this.webApplication.inspectorSrc = src;
- src = "about:blank";
- }
- }
- this.webApplication.loadUrl(src);
- }
-
- private launchInspector(appControl: NativeWRTjs.AppControl) {
- this.launchInspector = (param) => {}; // call once
- console.log('launchInspector');
-
- // AUL public key/Vconf - To support inspector
- if (this.checkInspectorCondition(appControl)) {
- let debugPort = wrt.startInspectorServer();
- let data = { "port" : [ debugPort.toString() ] };
- if (this.webApplication)
- this.webApplication.debugPort = debugPort;
- appControl.reply(data);
- }
- }
-
- private checkInspectorCondition(appControl: NativeWRTjs.AppControl) {
- let bundleDebug = (appControl.getData('__AUL_DEBUG__') === "1");
- return (bundleDebug || this.inspectorEnabledByVconf);
+ this.webApplication.loadUrl(appControl);
}
private handleKeyEvents(key: string) {
backgroundSupport = wrt.getBackgroundSupport();
debugPort = 0;
firstRendered = false;
+ contentSrc = '';
inspectorSrc = '';
loadFinished = false;
pendingCallbacks: Map<number, any> = new Map();
this.sendAppControlEvent();
}
- loadUrl(src: string) {
- this.mainWindow.loadURL(src);
- this.prelaunch(src);
+ private launchInspectorIfNeeded(appControl: NativeWRTjs.AppControl) {
+ console.log('launchInspectorIfNeeded');
+ let inspectorEnabledByVconf = wrt.tv ? wrt.tv.needUseInspector() : false;
+ if (inspectorEnabledByVconf && !this.backgroundExecution) {
+ this.inspectorSrc = this.contentSrc;
+ this.contentSrc = 'about:blank';
+ }
+ let hasAulDebug = (appControl.getData('__AUL_DEBUG__') === '1');
+ if (hasAulDebug || inspectorEnabledByVconf) {
+ let debugPort = wrt.startInspectorServer();
+ let data = { "port": [debugPort.toString()] };
+ this.debugPort = debugPort;
+ appControl.reply(data);
+ }
+ }
+
+ loadUrl(appControl: NativeWRTjs.AppControl) {
+ this.contentSrc = appControl.getLoadInfo().getSrc();
+ this.launchInspectorIfNeeded(appControl);
+ this.mainWindow.loadURL(this.contentSrc);
+ this.prelaunch(this.contentSrc);
if (wrt.da) {
this.mainWindow.emit('ready-to-show');
}