[Tizen7.5 Migration][VD] Fix load early url issue 59/293059/1 submit/tizen/20230530.160042
authorDongHyun Song <dh81.song@samsung.com>
Mon, 8 May 2023 05:16:48 +0000 (14:16 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Fri, 19 May 2023 03:44:51 +0000 (12:44 +0900)
If the app has app-control option in config.xml, app can jump the
URL defined in the option. Then it will not be a default src.

In this case, the app has to be able to jump to defined URL again.

FYI) This early-load URL feature is enabled to TV profile.

Reference:
https://review.tizen.org/gerrit/#/c/platform/framework/web/wrtjs/+/292434/

Change-Id: Iedf48ad48a5b1fb73f6e84d812c2820304e53480
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
wrt_app/src/runtime.ts
wrt_app/src/web_application.ts

index a4e4123..44bd5a3 100644 (file)
@@ -22,6 +22,7 @@ import { app } from 'electron';
 import { WebApplication } from './web_application';
 
 class Runtime {
+  skipCreateTizenWebAppOnce: Boolean = false;
   webApplication?: WebApplication = undefined;
 
   constructor() {
@@ -79,6 +80,12 @@ class Runtime {
         this.handleAppControlForElectronApp(appControl);
         return;
       }
+      if (this.skipCreateTizenWebAppOnce) {
+        this.skipCreateTizenWebAppOnce = false;
+        console.log('Already WebApplication instance created');
+        this.webApplication?.loadUrl(appControl);
+        return;
+      }
       console.log('Tizen Web App launch');
       if (!this.webApplication) {
         this.createWebApplicationAndLoadUrl(appControl);
@@ -116,6 +123,22 @@ class Runtime {
         this.webApplication?.hideSplashScreen(params[0]);
       } else if (type === 'selectionText') {
         addonManager.emit('message', type, params[0]);
+      } else if (type === 'loadHostedApp') {
+        const url = params[0];
+        const needInspector = wrt.tv?.needUseInspector();
+        console.log(`url : ${url}, needInspector : ${needInspector}`);
+        if (needInspector)
+          return;
+
+        if (!this.webApplication) {
+          let options: RuntimeOption = {
+            isAddonAvailable: false,
+            launchMode: ''
+          }
+          this.webApplication = new WebApplication(options);
+          this.skipCreateTizenWebAppOnce = true;
+        }
+        this.webApplication.loadUrlEarly(url);
       }
     });
 
index eef640b..b4e7c4e 100644 (file)
@@ -44,6 +44,7 @@ export class WebApplication {
   profileDelegate: WebApplicationDelegate;
   splashShown: boolean = false;
   reload: boolean = false;
+  earlyLoadedUrl: string = '';
 
   constructor(options: RuntimeOption) {
     if (wrt.tv) {
@@ -310,8 +311,17 @@ export class WebApplication {
     }
   }
 
+  loadUrlEarly(url: string) {
+    console.log(`early load : ${url}`);
+    this.earlyLoadedUrl = url;
+    this.mainWindow.loadURL(url);
+  }
+
   loadUrl(appControl: NativeWRTjs.AppControl) {
     this.contentSrc = appControl.getLoadInfo().getSrc();
+    if (this.earlyLoadedUrl === this.contentSrc)
+      return;
+
     this.launchInspectorIfNeeded(appControl);
     this.mainWindow.loadURL(this.contentSrc);
     this.prelaunch(this.contentSrc);