Revert "fixup! Implement app control handler" 92/202292/1
authorKwangHyuk Kim <hyuki.kim@samsung.com>
Wed, 27 Mar 2019 01:20:43 +0000 (01:20 +0000)
committerKwangHyuk Kim <hyuki.kim@samsung.com>
Wed, 27 Mar 2019 01:20:43 +0000 (01:20 +0000)
This reverts commit ab48671261d6adb069b1ceddd67b9331a5e688e4.

Change-Id: I05eb2480d72e7ec66bd0e09ca780639138887fbc

wrt_app/src/runtime.js
wrt_app/src/web_application.js

index d73db46c9621240c1f12ee0cf64d5221c65b9e5b..8017068a0b398c8b9d9272c2c2ac02a4ec9ab39a 100755 (executable)
@@ -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');
index 730f3078ed675a32e6951abee105ed8a001a3fd9..ade5d7d28ac29562ab23f580e1a1a3e376d9c375 100755 (executable)
@@ -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;