From: DongHyun Song Date: Fri, 11 Mar 2022 03:50:21 +0000 (+0900) Subject: [VD] Refactors for background launch X-Git-Tag: submit/tizen/20220519.160023^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6dd0d720c66b5be3476a598b11b071d8a0929d71;p=platform%2Fframework%2Fweb%2Fwrtjs.git [VD] Refactors for background launch Refactors conditions regarding background launch related to clearify logics. Change-Id: If4e222a7212d0c5e22d55b5d393f43fb9db0079e Signed-off-by: DongHyun Song --- diff --git a/wrt_app/common/web_application_delegate.ts b/wrt_app/common/web_application_delegate.ts index 62f26611..ac5635d1 100644 --- a/wrt_app/common/web_application_delegate.ts +++ b/wrt_app/common/web_application_delegate.ts @@ -24,7 +24,6 @@ export class WebApplicationDelegate { this.webApplication = webApplication; } - backgroundExecutableLaunchMode() { return false; } beforeQuit() { } canIgnoreSuspend() { return false; } clearCache() { } @@ -33,7 +32,7 @@ export class WebApplicationDelegate { handleAppControlEvent(appControl: any) { return true; } handleProxyInfo(authInfo: any, callback: any) { return false; } initialize(options: RuntimeOption) { } - isPreloading() { return false; } + isBackgroundLaunch() { return false; } needInpectorGuide() { return false; } needReload(src: string) { let originalUrl = this.webApplication.mainWindow.webContents.getURL(); diff --git a/wrt_app/src/tv/web_application_tv.ts b/wrt_app/src/tv/web_application_tv.ts index d3668fc6..0f8853bd 100644 --- a/wrt_app/src/tv/web_application_tv.ts +++ b/wrt_app/src/tv/web_application_tv.ts @@ -21,7 +21,6 @@ import { WebApplication } from '../web_application'; import { WebApplicationDelegate } from '../../common/web_application_delegate'; export class WebApplicationDelegateTV extends WebApplicationDelegate { - backgroundExecutionLaunchMode: boolean = false; backgroundExecutionMetaData: string = 'false'; inspectorSrc: string = ''; isAlwaysReload: boolean = false; @@ -37,18 +36,12 @@ export class WebApplicationDelegateTV extends WebApplicationDelegate { initialize(options: RuntimeOption) { this.launchMode = options.launchMode; - if (options.launchMode == 'backgroundAtStartup') { - console.log('backgroundAtStartup'); + console.log(`launch mode is ${this.launchMode}`); + if (options.launchMode === 'backgroundAtStartup') { this.preloadStatus = 'preload'; } else { this.preloadStatus = 'none'; } - if (options.launchMode == 'backgroundExecution') { - console.log('launch mode is backgroundExecution'); - this.backgroundExecutionLaunchMode = true; - } else { - this.backgroundExecutionLaunchMode = false; - } this.isAlwaysReload = this.tv.isAlwaysReload(); this.webApplication.multitaskingSupport = this.tv.getMultitaskingSupport(); this.webApplication.defaultBackgroundColor = '#0000'; @@ -101,6 +94,9 @@ for (var i=0; i < window.frames.length; i++) } private showInspectorGuide() { + if (this.isBackgroundLaunch()) + return; + console.log('WebApplication : showInspectorGuide'); this.showInspectorGuide = () => { }; // call once const message = `${this.webApplication.debugPort.toString()} @@ -114,11 +110,6 @@ Please click Record button in Timeline panel in PC before click OK button, Then you can get profile log from the initial loading.`; let webContents = this.webApplication.mainWindow.webContents; this.tv.showDialog(webContents, message); - if (this.preloadStatus !== 'none') { - setTimeout(() => { - this.tv.cancelDialogs(webContents); - }, 5000); - } } private needSuspend() { @@ -138,26 +129,16 @@ Then you can get profile log from the initial loading.`; } } - backgroundExecutableLaunchMode() { - return this.backgroundExecutionLaunchMode; - } - - isPreloading() { - if (this.preloadStatus === 'preload' || - this.launchMode === 'runningAsBackground') { - console.log(`preloadStatus is ${this.preloadStatus} or ${this.launchMode}, show is skipped`); - return true; - } - return false; + isBackgroundLaunch() { + return (this.preloadStatus === 'preload' || + this.launchMode === 'runningAsBackground' || + this.launchMode === 'backgroundExecution'); } canIgnoreSuspend() { - if (this.launchMode === 'runningAsForeground' || - this.launchMode === 'runningAsBackground') { - console.log('WebApplication : view_suspend & multitasking feature is skipped!'); - return true; - } - return false; + return (this.launchMode === 'runningAsForeground' || + this.launchMode === 'runningAsBackground' || + this.launchMode === 'backgroundExecution'); } beforeQuit() { @@ -181,8 +162,10 @@ Then you can get profile log from the initial loading.`; } needInpectorGuide() { - let inspectorEnabledByVconf = this.tv.needUseInspector(); - if (inspectorEnabledByVconf && !this.backgroundExecutionLaunchMode) { + if (this.isBackgroundLaunch()) { + return false; + } + if (this.tv.needUseInspector()) { this.inspectorSrc = this.webApplication.contentSrc; this.webApplication.contentSrc = 'about:blank'; return true; @@ -243,11 +226,6 @@ Then you can get profile log from the initial loading.`; return false; } } - - if ('true' === this.backgroundExecutionMetaData) { - console.log(`handle AppControl background exectution app to show`); - this.webApplication.mainWindow.show(); - } return true; } diff --git a/wrt_app/src/web_application.ts b/wrt_app/src/web_application.ts index bdf777f5..1f55332d 100644 --- a/wrt_app/src/web_application.ts +++ b/wrt_app/src/web_application.ts @@ -244,12 +244,11 @@ export class WebApplication { // TODO: On 6.0, this causes a black screen on relaunch if (this.showTimer) clearTimeout(this.showTimer); - if (!this.backgroundRunnable()) - this.mainWindow.setEnabled(true); + this.mainWindow.setEnabled(true); } private initDisplayDelay() { - if (this.profileDelegate.isPreloading()) + if (this.profileDelegate.isBackgroundLaunch()) return; this.splashShown = wrt.showSplashScreen(); @@ -264,10 +263,6 @@ export class WebApplication { }, 2000); } - private backgroundRunnable() { - return this.backgroundSupport || this.profileDelegate.backgroundExecutableLaunchMode(); - } - handleAppControlEvent(appControl: any) { if (!this.profileDelegate.handleAppControlEvent(appControl)) { return; @@ -311,7 +306,7 @@ export class WebApplication { } private isPausable() { - return !this.profileDelegate.canIgnoreSuspend() && !this.backgroundRunnable(); + return !this.backgroundSupport && !this.profileDelegate.canIgnoreSuspend(); } suspend() { @@ -325,7 +320,7 @@ export class WebApplication { } if (this.isPausable()) { this.windowList.forEach((window) => window.setEnabled(false)); - if (!this.multitaskingSupport && !this.profileDelegate.isPreloading()) { + if (!this.multitaskingSupport && !this.profileDelegate.isBackgroundLaunch()) { setTimeout(() => { console.log('multitasking is not supported; quitting app') app.quit(); @@ -341,8 +336,7 @@ export class WebApplication { addonManager.emit('lcResume', this.mainWindow.id, this.reload); this.reload = false; - if (!this.backgroundRunnable()) - this.windowList.forEach((window) => window.setEnabled(true)); + this.windowList.forEach((window) => window.setEnabled(true)); this.windowList[this.windowList.length - 1].show(); } @@ -399,13 +393,12 @@ export class WebApplication { } show() { - if (this.profileDelegate.isPreloading()) { + if (this.profileDelegate.isBackgroundLaunch()) { + console.log('show() will be skipped by background launch'); return; } console.log('WebApplication : show'); - if (this.profileDelegate.backgroundExecutableLaunchMode()) { - console.log('skip showing while backgroundExecutionLaunchMode mode'); - } else if (!this.mainWindow.isVisible()) { + if (!this.mainWindow.isVisible()) { console.log(`show this.windowList.length : ${this.windowList.length}`); this.mainWindow.show(); if (this.windowList.length > 1) {