this.handleIpcMessages();
this.addonManager = null;
this.isLaunched = false;
- this.debugMode = false;
- this.needInspector = false;
+ this.inspectorEnabledByVconf = false;
this.webContents = null;
this.allowQuit = false;
app.emit('ready');
} else {
console.log('Tizen Web App launch');
+ let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
if (!_this.webApplication) {
console.log('Creating WebApplication');
options.isAddonAvailable = !options.noAddons &&
_this.addonManager.isAddonAvailable();
- options.launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
+ options.launchMode = launchMode;
_this.webApplication = new WebApplication(options);
- if (!_this.debugMode && wrt.needUseInspector() &&
- options.launchMode != 'backgroundExecution') {
- _this.webApplication.defaultSrc = src;
+ _this.inspectorEnabledByVconf = wrt.needUseInspector();
+ if (_this.inspectorEnabledByVconf && launchMode != 'backgroundExecution') {
+ _this.webApplication.inspectorSrc = src;
src = "about:blank";
}
_this.webApplication.mainWindow.loadURL(src);
_this.webApplication.prelaunch(_this.addonManager.prelaunch_path, src);
} else {
console.log('Handling app-control event');
- if (_this.webApplication.preloadState == 'readyToShow') {
+ if (_this.webApplication.preloadStatus == 'readyToShow') {
_this.webApplication.show();
} else {
- let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
if (launchMode != 'backgroundAtStartup') {
- _this.webApplication.preloadState = 'none';
+ _this.webApplication.preloadStatus = 'none';
}
}
}
}
}
- // FIX ME : It must be supplemented to set a specific path
- wrt.setCookiePath();
-
- // AUL public key/Vconf - To support inspector
- if (!_this.debugMode && _this.checkInspectorCondition(appControl)) {
- _this.debugMode = true;
- _this.launchInspector(appControl);
- }
+ _this.configureRuntime(appControl);
});
wrt.on('suspend', function() {
console.log('suspend');
});
}
checkInspectorCondition(appControl) {
- var _this = this;
- let bundle_debug = (appControl.getData('__AUL_DEBUG__') === "1");
- _this.needInspector = wrt.needUseInspector();
- return (bundle_debug || _this.needInspector);
+ let bundleDebug = (appControl.getData('__AUL_DEBUG__') === "1");
+ return (bundleDebug || this.inspectorEnabledByVconf);
}
launchInspector(appControl) {
- var _this = this;
var portnum = wrt.getDebuggingPort();
var data = { "port" : [ portnum.toString() ] };
- if(_this.needInspector) {
- _this.webApplication.debugport = portnum;
- }
+ if (this.webApplication)
+ this.webApplication.debugPort = portnum;
appControl.reply(data);
}
+ configureRuntime(appControl) {
+ this.configureRuntime = (param) => {}; // call once
+
+ // FIX ME : It must be supplemented to set a specific path
+ wrt.setCookiePath();
+
+ // AUL public key/Vconf - To support inspector
+ if (this.checkInspectorCondition(appControl)) {
+ this.launchInspector(appControl);
+ }
+ }
handleKeyEvents(key) {
let path = null;
let _this = this;
this.firstRendered = false;
this.backgroundSupport = wrt.getBackgroundSupport();
this.multitaskingSupport = wrt.getMultitaskingSupport();
- this.debugport = 0;
- this.debugDialogShow = false;
- this.defaultSrc = '';
+ this.debugPort = 0;
+ this.inspectorSrc = '';
if (options.launchMode == 'backgroundAtStartup') {
console.log('backgroundAtStartup');
- this.preloadState = 'preload';
+ this.preloadStatus = 'preload';
} else {
- this.preloadState = 'none';
+ this.preloadStatus = 'none';
}
if (options.launchMode == 'backgroundExecution') {
console.log('backgroundExecution');
this.backgroundExecution = true;
- this.backgroundSupport = true;
} else {
this.backgroundExecution = false;
}
});
wrt.on('app-status-changed', function(event, status) {
console.log(`runningStatus: ${status}, ${self.loadFinished}`);
+ if (!self.isTVProfile) {
+ return;
+ }
self.runningStatus = status;
- if (self.loadFinished && self.runningStatus == 'behind') {
+ if (self.runningStatus === 'DialogClose' && self.inspectorSrc) {
+ console.log(`runningStatus is DialogClose, src is ${self.inspectorSrc}`);
+ self.mainWindow.loadURL(self.inspectorSrc);
+ self.inspectorSrc = '';
+ } else if (self.runningStatus == 'behind' && self.loadFinished) {
self.suspend();
}
- if (self.debugDialogShow && self.runningStatus == 'DialogClose') {
- console.log(`runningStatus is DialogClose, src is ${self.defaultSrc}`);
- self.debugDialogShow = false;
- self.mainWindow.loadURL(self.defaultSrc);
- }
});
}
+ backgroundRunnable() {
+ return this.backgroundSupport || this.backgroundExecution;
+ }
getWindowOption(options) {
return {
fullscreen: false,
clearTimeout(self.showTimer);
wrt.hideSplashScreen(1);
self.firstRendered = true;
- if (self.preloadState == 'preload') {
- self.preloadState = 'readyToShow';
+ if (self.preloadStatus == 'preload') {
+ self.preloadStatus = 'readyToShow';
console.log('preloading show is skipped!');
return;
}
self.loadFinished = false;
});
this.mainWindow.webContents.on('did-finish-load', function() {
- console.log(`webContents did-finish-load preloadState: ${self.preloadState}, status: ${self.runningStatus}`);
+ console.log('webContents did-finish-load');
self.loadFinished = true;
wrt.hideSplashScreen(2);
- if (wrt.isIMEWebApp())
+ if (wrt.isIMEWebApp()) {
self.activateIMEWebHelperClient();
- if (self.preloadState === 'readyToShow' || self.preloadState === 'preload' || self.runningStatus === 'behind') {
- self.suspend();
- if (self.runningStatus !== 'behind')
- wrt.notifyAppStatus('preload');
- }
- if(self.debugport && self.isTVProfile && !self.backgroundExecution) {
- let message = self.debugport.toString() +
- "\r\nFast RWI is used, [about:blank] is loaded fist instead of \r\n[" +
- self.defaultSrc +
- "]\r\nClick OK button will start the real loading.\r\nNotes:\r\nPlease " +
- "connect to RWI in PC before click OK button.\r\nThen you can get " +
- "network log from the initial loading.\r\nPlease click Record button " +
- "in Timeline panel in PC before click OK button,\r\nThen you can get " +
- "profile log from the initial loading."
- self.debugDialogShow = true;
- self.debugport = 0;
- wrt.modalDialog(self.mainWindow.webContents, message);
+ } else if (self.isTVProfile) {
+ if (self.inspectorSrc) {
+ self.showInspectorGuide();
+ } else {
+ self.suspendByStatus();
+ }
}
});
}
+ suspendByStatus() {
+ if (this.preloadStatus === 'readyToShow' ||
+ this.preloadStatus === 'preload' ||
+ this.runningStatus === 'behind') {
+ console.log(`preloadStatus: ${this.preloadStatus}, runningStatus: ${this.runningStatus}`);
+ this.suspend();
+ if (this.runningStatus !== 'behind')
+ wrt.notifyAppStatus('preload');
+ }
+ }
+ showInspectorGuide() {
+ this.showInspectorGuide = () => {}; // call once
+ let message = this.debugPort.toString() +
+ "\r\nFast RWI is used, [about:blank] is loaded fist instead of \r\n[" +
+ this.inspectorSrc +
+ "]\r\nClick OK button will start the real loading.\r\nNotes:\r\nPlease " +
+ "connect to RWI in PC before click OK button.\r\nThen you can get " +
+ "network log from the initial loading.\r\nPlease click Record button " +
+ "in Timeline panel in PC before click OK button,\r\nThen you can get " +
+ "profile log from the initial loading."
+ wrt.modalDialog(this.mainWindow.webContents, message);
+ }
suspend(path) {
console.log('WebApplication : suspend');
if (path != null) {
console.log('multitasking is not supported; quitting app')
app.quit();
}, 1000);
- } else if (!this.backgroundSupport) {
+ } else if (!this.backgroundRunnable()) {
this.windowList.forEach((window) => window.setEnabled(false));
}
this.windowList[this.windowList.length - 1].hide();
}
return;
}
- if (!this.backgroundSupport) {
+ if (!this.backgroundRunnable()) {
this.windowList.forEach((window) => window.setEnabled(true));
}
this.windowList[this.windowList.length - 1].show();
}
finalize() {
+ this.inspectorSrc = '';
this.windowList.forEach((window) => {
window.removeAllListeners();
});
}
show() {
console.log('WebApplication : show');
- this.preloadState = 'none';
- if (!this.backgroundExecution && !this.mainWindow.isVisible()) {
+ this.preloadStatus = 'none';
+ if (this.backgroundExecution) {
+ console.log('skip showing while backgroundExecution mode');
+ } else if (!this.mainWindow.isVisible()) {
console.log('show window');
this.mainWindow.show();
}