'use strict';
-import { protocol } from 'electron';
import { wrt } from '../../browser/wrt';
import { WebApplication } from '../web_application';
import { WebApplicationDelegate } from '../../common/web_application_delegate';
export class WebApplicationDelegateTV extends WebApplicationDelegate {
- accessiblePath?: string[];
backgroundExecution: boolean = false;
inspectorSrc: string = '';
isAlwaysReload: boolean = false;
this.backgroundExecution = false;
}
this.isAlwaysReload = this.tv.isAlwaysReload();
- this.accessiblePath = this.tv.getAccessiblePath();
-
this.webApplication.multitaskingSupport = this.tv.getMultitaskingSupport();
this.webApplication.defaultBackgroundColor = '#0000';
this.webApplication.defaultTransparent = true;
- this.initAccessiblePath();
this.initEventListener();
}
- private initAccessiblePath() {
- if (this.accessiblePath) {
- console.log(`accessiblePath: ${this.accessiblePath}`);
- protocol.interceptFileProtocol('file', (request: any, callback: any) => {
- if (request.url) {
- let parsed_info = new URL(request.url);
- let access_path = parsed_info.host + decodeURI(parsed_info.pathname);
- console.log(`check path: : ${access_path}`);
- for (let path of (this.accessiblePath as string[])) {
- if (access_path.startsWith(path)) {
- callback(access_path);
- return;
- }
- }
- if (access_path.indexOf("/shared/res/") > -1) {
- callback(access_path);
- return;
- }
- else {
- console.log(`invalid accesspath: ${access_path}`);
- (callback as any)(403);
- }
- } else {
- console.log('request url is empty');
- (callback as any)(403);
- }
- }, (error: Error) => {
- if (error)
- console.log(`error : ${error}`);
- });
- }
- }
-
initEventListener() {
wrt.on('app-status-changed', (event: any, status: string) => {
console.log(`runningStatus: ${status}, ${this.webApplication.loadFinished}`);