From 19ba690a97c1fae238fa34330a48cf1102a2bf3f Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Mon, 8 May 2023 14:16:48 +0900 Subject: [PATCH] [Tizen7.5 Migration][VD] Fix load early url issue 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 --- wrt_app/src/runtime.ts | 23 +++++++++++++++++++++++ wrt_app/src/web_application.ts | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/wrt_app/src/runtime.ts b/wrt_app/src/runtime.ts index a4e4123..44bd5a3 100644 --- a/wrt_app/src/runtime.ts +++ b/wrt_app/src/runtime.ts @@ -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); } }); diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index eef640b..b4e7c4e 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -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); -- 2.7.4