[VD feature] add preloading feature 45/202145/5
authorYONGMAN SON <yman.son@samsung.com>
Mon, 25 Mar 2019 07:49:21 +0000 (16:49 +0900)
committerYONGMAN SON <yman.son@samsung.com>
Tue, 26 Mar 2019 04:51:21 +0000 (13:51 +0900)
http://wiki.vd.sec.samsung.net/x/Kr5iAw
WRTJS TCs -> 1.5

Change-Id: I929356b3f196c6476d4ee9199b1f80fb5e8729a8

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

index acc25c0a96eaf7a3ff95563f7cb540240d04c415..8017068a0b398c8b9d9272c2c2ac02a4ec9ab39a 100755 (executable)
@@ -82,6 +82,15 @@ class Runtime {
             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');
@@ -121,6 +130,11 @@ class Runtime {
                 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";
+                }
                 _this.webApplication.mainWindow.loadURL(src);
             }
             // FIX ME : It must be supplemented to set a specific path
index db8c768e92ad8ec45a07758357c70e03fe293842..ade5d7d28ac29562ab23f580e1a1a3e376d9c375 100755 (executable)
@@ -32,7 +32,7 @@ class WebApplication {
         }
         console.log('mainWindow id : ' + this.mainWindow.id);
         this.handleEvents(winopt);
-        this.firstRendered = false;
+        this.preloadState = 'none';
         this.backgroundSupport = wrt.getBackgroundSupport();
         this.multitaskingSupport = wrt.getMultitaskingSupport();
     }
@@ -56,12 +56,12 @@ class WebApplication {
         this.mainWindow.on('ready-to-show', function() {
             console.log('mainWindow ready-to-show');
             wrt.hideSplashScreen(1);
-            self.firstRendered = true;
-
-            if (!self.mainWindow.isVisible()) {
-                console.log('show browserWindow');
-                self.mainWindow.show();
+            if (self.preloadState == 'preload') {
+                self.preloadState = 'readyToShow';
+                console.log('preloading show is skipped!');
+                return;
             }
+            self.show();
         });
         this.mainWindow.on('closed', function() {
             console.log('mainWindow closed!');
@@ -111,5 +111,12 @@ class WebApplication {
             '})()';
         wrt.executeJS(this.mainWindow.webContents, kAppControlEventScript);
     }
+    show() {
+        this.preloadState = 'none';
+        if (!this.mainWindow.isVisible()) {
+            console.log('show browserWindow');
+            this.mainWindow.show();
+        }
+    }
 }
 module.exports = WebApplication;