Make same function name with its event name 87/248787/5
authorDongHyun Song <dh81.song@samsung.com>
Wed, 2 Dec 2020 07:54:15 +0000 (16:54 +0900)
committerDongHyun Song <dh81.song@samsung.com>
Wed, 2 Dec 2020 08:31:42 +0000 (17:31 +0900)
1) Rename functions same as its event name
2) Add blank line among functions.

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

index 3717d43..94f9e99 100644 (file)
@@ -27,21 +27,24 @@ class Runtime {
   inspectorEnabledByVconf = false;
 
   constructor() {
-    app.on('before-quit', (event) => {
+    app.on('before-quit', (event: any) => {
       console.log('before-quit');
-      this.webApplication?.quit();
+      this.webApplication?.beforeQuit();
     });
-    app.on('will-quit', (event) => {
+
+    app.on('will-quit', (event: any) => {
       console.log('will-quit');
       addonManager.deactivateAll();
     });
-    app.on('quit', (event) => {
+
+    app.on('quit', (event: any) => {
       console.log('quit');
       if (this.webApplication) {
-        this.webApplication.finalize();
+        this.webApplication.quit();
         this.webApplication = undefined;
       }
     });
+
     app.on('browser-window-created', () => {
       console.log('browser-window-created');
       if (!this.isLaunched) {
@@ -49,18 +52,21 @@ class Runtime {
         this.isLaunched = true;
       }
     });
+
     app.on('window-all-closed', () => {
       console.log('window-all-closed');
       app.quit();
     });
-    app.on('web-contents-created', (event, webContents) => {
+
+    app.on('web-contents-created', (event: any, webContents: any) => {
       console.log('web-contents-created');
-      webContents.on('before-input-event', (event, input) => {
+      webContents.on('before-input-event', (event: any, input: any) => {
         if (this.isLaunched && this.webApplication)
           this.handleKeyEvents(input.key);
       });
     });
-    app.once('ready', (event) => {
+
+    app.once('ready', (event: any) => {
       console.log('ready');
       let addonAvailable = addonManager.build();
       console.log("addonBuild : " + addonAvailable);
@@ -71,7 +77,8 @@ class Runtime {
       }
       wrt.tv?.importCertificate('');
     });
-    wrt.on('app-control', (event, appControl) => {
+
+    wrt.on('app-control', (event: any, appControl: any) => {
       console.log('app-control');
       let loadInfo = appControl.getLoadInfo();
       let src = loadInfo.getSrc();
@@ -166,19 +173,23 @@ class Runtime {
       }
       this.launchInspector(appControl);
     });
+
     wrt.on('suspend', () => {
       console.log('suspend');
       this.webApplication?.suspend();
     });
+
     wrt.on('resume', () => {
       console.log('resume');
       this.webApplication?.resume();
     });
+
     wrt.on('low-memory', () => {
       console.log('low-memory');
       this.webApplication?.lowMemory();
     });
-    wrt.on('message', (event, type, params) => {
+
+    wrt.on('message', (event: any, type: string, params: string[]) => {
       console.log('message type(' + type + ') params : ' + params);
       const app_id = params[0];
       if (type === 'startService') {
@@ -189,21 +200,26 @@ class Runtime {
         event.preventDefault();
       }
     });
+
     wrt.on('ambient-tick', () => {
       this.webApplication?.ambientTick();
     });
-    wrt.on('ambient-changed', (event, ambient_mode) => {
+
+    wrt.on('ambient-changed', (event: any, ambient_mode: boolean) => {
       console.log('ambient-changed , ambient_mode:' + ambient_mode);
       this.webApplication?.ambientChanged(ambient_mode);
     });
-    wrt.on('addon-installed', (event, path) => {
+
+    wrt.on('addon-installed', (event: any, path: string) => {
       console.log('addon-installed at ' + path);
       addonManager.checkAddon(path);
     });
-    wrt.on('addon-uninstalled', (event, id) => {
+
+    wrt.on('addon-uninstalled', (event: any, id: string) => {
       console.log('addon-unistalled named ' + id);
     });
-    wrt.on('wgt-checking-done', (event) => {
+
+    wrt.on('wgt-checking-done', (event: any) => {
       console.log('wgt-checking-done');
       addonManager.updateDB();
     });
index 8888289..ce20833 100755 (executable)
@@ -74,7 +74,7 @@ export class WebApplication {
   }
 
   private setupEventListener(options: RuntimeOption) {
-    app.on('browser-window-created', (event, window) => {
+    app.on('browser-window-created', (event: any, window: any) => {
       if (this.windowList.length > 0)
         this.windowList[this.windowList.length - 1].hide();
       this.windowList.push(window);
@@ -88,12 +88,14 @@ export class WebApplication {
           this.windowList[this.windowList.length - 1].show();
       });
     });
-    app.on('web-contents-created', (event, webContents) => {
+
+    app.on('web-contents-created', (event: any, webContents: any) => {
       webContents.on('crashed', function() {
         console.error('webContents crashed');
         app.exit(100);
       });
-      webContents.session.setPermissionRequestHandler((webContents, permission, callback) => {
+
+      webContents.session.setPermissionRequestHandler((webContents: any, permission: string, callback: any) => {
         console.log(`handlePermissionRequests for ${permission}`);
         if (permission === 'notifications') {
           if (!this.notificationPermissionMap)
@@ -127,7 +129,8 @@ export class WebApplication {
         }
       });
     });
-    app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
+
+    app.on('certificate-error', (event: any, webContents: any, url: string, error: string, certificate: any, callback: any) => {
       console.log('A certificate error has occurred');
       event.preventDefault();
       if (certificate.data) {
@@ -140,7 +143,8 @@ export class WebApplication {
         callback(false);
       }
     });
-    app.on('login', (event, webContents, request, authInfo, callback) => {
+
+    app.on('login', (event: any, webContents: any, request: any, authInfo: any, callback: any) => {
       console.log(`Login info is required, isproxy: ${authInfo.isProxy}`);
       event.preventDefault();
       let usrname = '';
@@ -165,9 +169,10 @@ export class WebApplication {
         wrt.handleAuthRequest(id, webContents);
       }
     });
+
     if (this.accessiblePath) {
       console.log(`accessiblePath: ${this.accessiblePath}`);
-      protocol.interceptFileProtocol('file', (request, callback) => {
+      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);
@@ -190,11 +195,12 @@ export class WebApplication {
           console.log('request url is empty');
           (callback as any)(403);
         }
-      }, (error) => {
+      }, (error: Error) => {
         console.log(error);
       });
     }
-    wrt.on('permission-response', (event, id, result) => {
+
+    wrt.on('permission-response', (event: any, id: number, result: boolean) => {
       console.log(`permission-response for ${id} is ${result}`);
       let callback = this.pendingCallbacks.get(id);
       if (typeof callback === 'function') {
@@ -203,7 +209,8 @@ export class WebApplication {
         this.pendingCallbacks.delete(id);
       }
     });
-    wrt.on('auth-response', (event, id, submit, user, password) => {
+
+    wrt.on('auth-response', (event: any, id: number, submit: boolean, user: string, password: string) => {
       let callback = this.pendingCallbacks.get(id);
       if (typeof callback === 'function') {
         console.log('calling auth response callback');
@@ -214,7 +221,8 @@ export class WebApplication {
         this.pendingCallbacks.delete(id);
       }
     });
-    wrt.on('app-status-changed', (event, status) => {
+
+    wrt.on('app-status-changed', (event: any, status: string) => {
       console.log(`runningStatus: ${status}, ${this.loadFinished}`);
       if (!wrt.tv)
         return;
@@ -258,10 +266,12 @@ export class WebApplication {
       }
       this.show();
     });
+
     this.mainWindow.webContents.on('did-start-loading', () => {
       console.log('webContents did-start-loading');
       this.loadFinished = false;
     });
+
     this.mainWindow.webContents.on('did-finish-load', () => {
       console.log('webContents did-finish-load');
       this.loadFinished = true;
@@ -379,8 +389,8 @@ Then you can get profile log from the initial loading.`;
     this.windowList[this.windowList.length - 1].show();
   }
 
-  finalize() {
-    console.log('WebApplication : finalize');
+  quit() {
+    console.log('WebApplication : quit');
     this.flushData();
     this.windowList.forEach((window) => window.removeAllListeners());
     this.inQuit = false;
@@ -388,8 +398,8 @@ Then you can get profile log from the initial loading.`;
       this.suspend();
   }
 
-  quit() {
-    console.log('WebApplication : quit');
+  beforeQuit() {
+    console.log('WebApplication : beforeQuit');
     addonManager.emit('lcQuit', this.mainWindow.id);
     if (wrt.tv) {
       this.inspectorSrc = '';