From: KwangHyuk Kim Date: Wed, 27 Mar 2019 01:20:43 +0000 (+0000) Subject: Revert "fixup! Implement app control handler" X-Git-Tag: submit/tizen/20190329.010456~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=533b3c74ae674681ec2dc402cc35204cb98bea91;p=platform%2Fframework%2Fweb%2Fwrtjs.git Revert "fixup! Implement app control handler" This reverts commit ab48671261d6adb069b1ceddd67b9331a5e688e4. Change-Id: I05eb2480d72e7ec66bd0e09ca780639138887fbc --- diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index d73db46c..8017068a 100755 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -81,17 +81,7 @@ class Runtime { let loadInfo = appControl.getLoadInfo(); let src = loadInfo.getSrc(); - 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) { if (_this.webApplication.preloadState == 'readyToShow') { _this.webApplication.show(); } @@ -100,6 +90,7 @@ class Runtime { if (launchMode != 'backgroundAtStartup') { _this.webApplication.preloadState = 'none'; } + let skipReload = appControl.getData('SkipReload'); if (skipReload == 'Yes') { console.log('skipping reload'); @@ -118,11 +109,25 @@ class Runtime { if (reload && appControl.getOperation() == 'http://tizen.org/appcontrol/operation/main') reload = false; if (reload) { - _this.webApplication.closeWindows(); - _this.webApplication.mainWindow.loadURL(src); + _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()); + 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'); diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js index 730f3078..ade5d7d2 100755 --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -91,7 +91,7 @@ class WebApplication { } resume() { console.log('WebApplication : resume'); - if (this.preloadState != 'none') { + if (!this.firstRendered) { return; } BrowserWindow.getAllWindows().forEach((window) => { @@ -117,11 +117,6 @@ class WebApplication { console.log('show browserWindow'); this.mainWindow.show(); } - closeWindows() { - BrowserWindow.getAllWindows().forEach((window) => { - if (window != this.mainWindow) - window.destroy(); - }); } } module.exports = WebApplication;