let loadInfo = appControl.getLoadInfo();
let src = loadInfo.getSrc();
- if (_this.webApplication) {
- if (_this.webApplication.preloadState == 'readyToShow') {
- _this.webApplication.show();
- }
-
- let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
- if (launchMode != 'backgroundAtStartup') {
- _this.webApplication.preloadState = 'none';
- }
-
- let skipReload = appControl.getData('SkipReload');
- if (skipReload == 'Yes') {
- console.log('skipping reload');
- _this.webApplication.resume();
- return;
- }
-
- let reload = loadInfo.getReload();
- if (!reload) {
- if (src != _this.webApplication.mainWindow.getURL())
- reload = true;
- }
- // handle http://tizen.org/appcontrol/operation/main operation specially.
- // only menu-screen app can send launch request with main operation.
- // in this case, web app should have to resume web app not reset.
- if (reload && appControl.getOperation() == 'http://tizen.org/appcontrol/operation/main')
- reload = false;
- if (reload) {
- _this.webApplication.mainWindow.destroy();
- _this.webApplication = nullptr;
- } else {
- _this.webApplication.sendAppControlEvent();
- }
- }
-
if (wrt.isElectronApp()) {
- console.log("Electron App launch");
- require('module').globalPaths.push(wrt.getAppPath());
+ console.log('Electron App launch');
+ const Module = require('module');
+ 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');
+ console.log('loading path:', mainJsPath);
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');
- if (launchMode == 'backgroundAtStartup') {
- console.log('backgroundAtStartup');
- _this.webApplication.preloadState = "preload";
+ console.log('Tizen Web App launch');
+ if (!_this.webApplication) {
+ console.log('Creating WebApplication');
+ options.launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
+ _this.webApplication = new WebApplication(options);
+ _this.webApplication.mainWindow.loadURL(src);
+ } else {
+ console.log('Handling app-control event');
+ if (_this.webApplication.preloadState == 'readyToShow') {
+ _this.webApplication.show();
+ } else {
+ let launchMode = appControl.getData('http://samsung.com/appcontrol/data/launch_mode');
+ if (launchMode != 'backgroundAtStartup') {
+ _this.webApplication.preloadState = 'none';
+ }
+ }
+
+ let skipReload = appControl.getData('SkipReload');
+ if (skipReload == 'Yes') {
+ console.log('skipping reload');
+ _this.webApplication.resume();
+ return;
+ }
+
+ let reload = loadInfo.getReload();
+ if (!reload) {
+ if (src != _this.webApplication.mainWindow.getURL())
+ reload = true;
+ }
+ // handle http://tizen.org/appcontrol/operation/main operation specially.
+ // only menu-screen app can send launch request with main operation.
+ // in this case, web app should have to resume web app not reset.
+ if (reload && appControl.getOperation() == 'http://tizen.org/appcontrol/operation/main')
+ reload = false;
+ if (reload) {
+ _this.webApplication.closeWindows();
+ _this.webApplication.mainWindow.loadURL(src);
+ } else {
+ _this.webApplication.sendAppControlEvent();
+ }
}
- _this.webApplication.mainWindow.loadURL(src);
}
// FIX ME : It must be supplemented to set a specific path
wrt.setCookiePath();
console.log('mainWindow id : ' + this.mainWindow.id);
this.handleEvents(winopt);
this.firstRendered = false;
- this.preloadState = 'none';
this.backgroundSupport = wrt.getBackgroundSupport();
this.multitaskingSupport = wrt.getMultitaskingSupport();
+ if (options.launchMode == 'backgroundAtStartup') {
+ console.log('backgroundAtStartup');
+ this.preloadState = 'preload';
+ } else {
+ this.preloadState = 'none';
+ }
}
getBrowserWindowOption() {
return {
this.mainWindow.show();
}
}
+ closeWindows() {
+ BrowserWindow.getAllWindows().forEach((window) => {
+ if (window != this.mainWindow)
+ window.destroy();
+ });
+ }
}
module.exports = WebApplication;