From 715e7ae0de1102429f1ca539086fe61807013b0d Mon Sep 17 00:00:00 2001 From: DongHyun Song Date: Wed, 20 Nov 2019 11:36:24 +0900 Subject: [PATCH] [VD] Replaces WRT APIs for TV profile Related patch: https://review.tizen.org/gerrit/218144/ Change-Id: If585649d7b9065eac0dc32a7af6cbc665553abdf Signed-off-by: DongHyun Song --- wrt_app/src/runtime.js | 21 +++++++++++---------- wrt_app/src/web_application.js | 43 +++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 31 deletions(-) mode change 100644 => 100755 wrt_app/src/web_application.js diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index dcb678b..077bdcf 100755 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -35,7 +35,6 @@ class Runtime { this.sandbox = []; this.webContents = null; this.addonPkgs = []; - this.isTVProfile = (wrt.getPlatformType() === 'product_tv'); var _this = this; app.on('before-quit', function(event) { @@ -79,7 +78,7 @@ class Runtime { }); app.on('web-contents-created', function(event, webContents) { console.log('web-contents-created'); - if (_this.isTVProfile) + if (wrt.tv) _this.setCookiePath(); _this.webContents = webContents; _this.webContents.on('before-input-event', function(event, input) { @@ -94,9 +93,9 @@ class Runtime { if (!options.noAddons) { _this.addonManager.build(); } - if (_this.isTVProfile) { - wrt.importCertificate(''); - wrt.optimizeCache(); + if (wrt.tv) { + wrt.tv.importCertificate(''); + wrt.tv.optimizeCache(); } }); wrt.on('app-control', function(event, appControl) { @@ -128,10 +127,12 @@ class Runtime { _this.webApplication = new WebApplication(options); _this.webApplication.addonEmitter = _this.addonManager.evt_emitter_; - _this.inspectorEnabledByVconf = wrt.needUseInspector(); - if (_this.inspectorEnabledByVconf && launchMode != 'backgroundExecution') { - _this.webApplication.inspectorSrc = src; - src = "about:blank"; + if (wrt.tv) { + _this.inspectorEnabledByVconf = wrt.tv.needUseInspector(); + if (_this.inspectorEnabledByVconf && launchMode != 'backgroundExecution') { + _this.webApplication.inspectorSrc = src; + src = "about:blank"; + } } _this.webApplication.mainWindow.loadURL(src); _this.webApplication.prelaunch(src); @@ -155,7 +156,7 @@ class Runtime { let reload = loadInfo.getReload() || _this.webApplication.isAlwaysReload; if (!reload) { - if (_this.isTVProfile) { + if (wrt.tv) { console.log(`src = ${src}, app-control uri = ${_this.webApplication.mainWindow.getURL()}`); const url = require('url'); let appcontrolUrl = url.parse(src); diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js old mode 100644 new mode 100755 index 5c848b3..fc38141 --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -33,7 +33,6 @@ class WebApplication { this.windowList = []; this.firstRendered = false; this.backgroundSupport = wrt.getBackgroundSupport(); - this.multitaskingSupport = wrt.getMultitaskingSupport(); this.debugPort = 0; this.inspectorSrc = ''; if (options.launchMode == 'backgroundAtStartup') { @@ -48,14 +47,14 @@ class WebApplication { } else { this.backgroundExecution = false; } - this.accessiblePath = wrt.getAccessiblePath(); - this.isAlwaysReload = wrt.isAlwaysReload(); + this.accessiblePath = (wrt.tv ? wrt.tv.getAccessiblePath() : null); + this.isAlwaysReload = (wrt.tv ? wrt.tv.isAlwaysReload() : false); + this.multitaskingSupport = (wrt.tv ? wrt.tv.getMultitaskingSupport() : true); + this.defaultBackgroundColor = (wrt.tv ? '#000' : '#FFF'); + this.defaultTransparent = (wrt.tv ? true : false); this.suspended = false; this.loadFinished = false; this.runningStatus = 'none'; - this.isTVProfile = (wrt.getPlatformType() === "product_tv"); - this.defaultBackgroundColor = (this.isTVProfile ? '#000' : '#FFF'); - this.defaultTransparent = (this.isTVProfile ? true : false); this.addonEmitter = null; let self = this; @@ -121,8 +120,8 @@ class WebApplication { event.preventDefault(); let usrname = ''; let passwd = ''; - if (self.isTVProfile && authInfo.isProxy) { - let vconfProxy = wrt.getProxy(); + if (wrt.tv && authInfo.isProxy) { + let vconfProxy = wrt.tv.getProxy(); if (vconfProxy) { let proxyInfo = new URL(vconfProxy); usrname = proxyInfo.username; @@ -138,7 +137,7 @@ class WebApplication { wrt.handleAuthRequest(id, webContents); } }); - if (this.isTVProfile) { + if (wrt.tv) { // TODO. This logic in only for QA verification // Current TV default client cert will be expired. // So that detecting apps which use TV client certificate, @@ -148,7 +147,7 @@ class WebApplication { event.preventDefault(); if (list.length > 0 && list[0].subjectName == 'Samsung TV,BDP certificate') { setTimeout(() => { - wrt.showDialog(webContents, 'Samsung TV,BDP certificate'); + wrt.tv.showDialog(webContents, 'Samsung TV,BDP certificate'); }, 7000); } callback(list[0]); @@ -206,7 +205,7 @@ class WebApplication { }); wrt.on('app-status-changed', function(event, status) { console.log(`runningStatus: ${status}, ${self.loadFinished}`); - if (!self.isTVProfile) { + if (!wrt.tv) { return; } self.runningStatus = status; @@ -250,7 +249,7 @@ class WebApplication { }); } let self = this; - if (!self.isTVProfile) { + if (!wrt.tv) { self.showTimer = setTimeout(() => { if (!self.suspended) { console.log('FrameRendered not obtained from engine. To show window, timer fired'); @@ -282,7 +281,7 @@ class WebApplication { wrt.hideSplashScreen(2); if (wrt.isIMEWebApp()) { self.activateIMEWebHelperClient(); - } else if (self.isTVProfile) { + } else if (wrt.tv) { if (self.inspectorSrc) { self.showInspectorGuide(); } else { @@ -301,7 +300,7 @@ class WebApplication { // TODO : Need to care this situation and decide to pass the addon event emitter to suspend() this.suspend(); if (this.runningStatus !== 'behind') - wrt.notifyAppStatus('preload'); + wrt.tv.notifyAppStatus('preload'); } } showInspectorGuide() { @@ -315,7 +314,7 @@ class WebApplication { "network log from the initial loading.\r\nPlease click Record button " + "in Timeline panel in PC before click OK button,\r\nThen you can get " + "profile log from the initial loading." - wrt.showDialog(this.mainWindow.webContents, message); + wrt.tv.showDialog(this.mainWindow.webContents, message); } suspend() { console.log('WebApplication : suspend'); @@ -326,8 +325,8 @@ class WebApplication { console.log('WebApplication : suspend - Invalid event emitter'); } this.suspended = true; - if (this.isTVProfile) { - wrt.flushCookie(); + if (wrt.tv) { + wrt.tv.flushCookie(); this.windowList.forEach((window) => window.webContents.session.flushStorageData()); } if (!this.backgroundRunnable()) { @@ -366,8 +365,10 @@ class WebApplication { } finalize() { console.log('WebApplication : finalize'); - this.inspectorSrc = ''; - wrt.cancelDialogs(this.mainWindow.webContents); + if (wrt.tv) { + this.inspectorSrc = ''; + wrt.tv.cancelDialogs(this.mainWindow.webContents); + } if (this.debugPort) { console.log('stop inspector server'); this.debugPort = 0; @@ -451,10 +452,10 @@ class WebApplication { } lowMemory() { console.log('WebApplication : lowMemory to clearcache'); - if (this.isTVProfile) { + if (wrt.tv) { this.windowList.forEach((window) => { //clear webframe cache - wrt.clearWebCache(window.webContents); + wrt.tv.clearWebCache(window.webContents); window.webContents.session.clearCache(function() { console.log('clear session Cache complete'); }) -- 2.7.4