let loadInfo = appControl.getLoadInfo();
let src = loadInfo.getSrc();
- if (_this.webApplication) {
+ if (wrt.isElectronApp()) {
+ console.log("Electron App launch");
+ let filePath = src;
+ let pkgJson = require(filePath.substr(7, filePath.length - 12));
+ let mainJsPath = filePath.substr(7, filePath.length - 19) +
+ (pkgJson.main || 'index.js');
+
+ const Module = require('module');
+ Module._load(mainJsPath, Module, true);
+ app.emit('ready');
+ } else if (_this.webApplication) {
if (_this.webApplication.preloadState == 'readyToShow') {
_this.webApplication.show();
}
if (launchMode != 'backgroundAtStartup') {
_this.webApplication.preloadState = 'none';
}
-
let skipReload = appControl.getData('SkipReload');
if (skipReload == 'Yes') {
console.log('skipping reload');
if (reload && appControl.getOperation() == 'http://tizen.org/appcontrol/operation/main')
reload = false;
if (reload) {
- _this.webApplication.mainWindow.destroy();
- _this.webApplication = nullptr;
+ _this.webApplication.closeWindows();
+ _this.webApplication.mainWindow.loadURL(src);
} else {
_this.webApplication.sendAppControlEvent();
}
- }
-
- if (wrt.isElectronApp()) {
- console.log("Electron App launch");
- require('module').globalPaths.push(wrt.getAppPath());
- let filePath = src[7] === '/' ? src.substr(8) : src.substr(7); // strip "file://"
- let pkgJson = require(filePath);
- let pos = filePath.lastIndexOf('/');
- let mainJsPath = (pos !== -1 ? filePath.substr(0, pos + 1) : '') +
- (pkgJson.main || 'index.js');
-
- const Module = require('module');
- Module._load(mainJsPath, Module, true);
- app.emit('ready');
} else {
_this.webApplication = new WebApplication(options);
let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
}
resume() {
console.log('WebApplication : resume');
- if (!this.firstRendered) {
+ if (this.preloadState != 'none') {
return;
}
BrowserWindow.getAllWindows().forEach((window) => {
console.log('show browserWindow');
this.mainWindow.show();
}
+ closeWindows() {
+ BrowserWindow.getAllWindows().forEach((window) => {
+ if (window != this.mainWindow)
+ window.destroy();
+ });
}
}
module.exports = WebApplication;