From: Aron Kim Date: Mon, 27 May 2019 11:14:13 +0000 (+0900) Subject: Revert "Refactor termination sequence" X-Git-Tag: submit/tizen/20190814.020427~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15dca7383c7a1b5901e1ac19ef5eee9111eca8ff;p=platform%2Fframework%2Fweb%2Fwrtjs.git Revert "Refactor termination sequence" This reverts commit 64527f72f0990d9a5f3b7bc6bd4dc4355b27046f. This is an additional patch due to the ContextMenu implementation. This patch is not required when the ContextMenu is refactored. Linked to: https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/207875/ Change-Id: I923fafed04f3979f6d8d4a09ac383eab00685517 Signed-off-by: Aron Kim --- diff --git a/wrt_app/src/runtime.js b/wrt_app/src/runtime.js index 8fcdcf1c..ebc0037b 100755 --- a/wrt_app/src/runtime.js +++ b/wrt_app/src/runtime.js @@ -34,7 +34,6 @@ class Runtime { var _this = this; app.on('before-quit', function(event) { console.log('before-quit'); - wrt.exit(); }); app.on('will-quit', function(event) { console.log('will-quit'); @@ -43,6 +42,7 @@ class Runtime { }); app.on('quit', function(event) { console.log('quit'); + wrt.exit(); }); app.on('browser-window-blur', function() { console.log('browser-window-blur'); @@ -62,9 +62,7 @@ class Runtime { }); app.on('window-all-closed', function(event) { console.log('window-all-closed'); - // For Tizen Apps, quit will be called from web_application.js - if (!_this.webApplication) - app.quit(); + app.quit(); }); app.on('will-finish-launching', function(event) { console.log('will-finish-launching'); @@ -151,19 +149,15 @@ class Runtime { }); wrt.on('suspend', function() { console.log('suspend'); - if (_this.webApplication) - _this.webApplication.suspend(); + _this.webApplication.suspend(); }); wrt.on('resume', function() { console.log('resume'); - if (_this.webApplication) - _this.webApplication.resume(); + _this.webApplication.resume(); }); wrt.on('terminate', function() { console.log('terminate'); - if (_this.webApplication) - _this.webApplication.terminate(); - else app.quit(); + _this.webApplication.terminate(); }); } onLanguageChanged() {} diff --git a/wrt_app/src/web_application.js b/wrt_app/src/web_application.js index 3f242e98..d578788a 100755 --- a/wrt_app/src/web_application.js +++ b/wrt_app/src/web_application.js @@ -55,16 +55,14 @@ class WebApplication { console.log(`window closed : #${self.windowList.length}`); let index = self.windowList.indexOf(window); self.windowList.splice(index, 1); - if (!self.windowList.length) - self.terminate(); - else if (index === self.windowList.length) + if (!self.isTerminating && index === self.windowList.length && self.windowList.length > 0) self.windowList[self.windowList.length - 1].show(); }); }); app.on('web-contents-created', function(event, webContents) { webContents.on('crashed', function() { console.error('webContents crashed'); - self.terminate(); + app.exit(100); }); webContents.session.setPermissionRequestHandler(function(webContents, permission, callback) { console.log(`handlePermissionRequests for ${permission}`); @@ -240,7 +238,7 @@ class WebApplication { let windows = BrowserWindow.getAllWindows(); if (!this.multitaskingSupport) { console.log('multitasking is not supported; quitting app') - this.terminate(); + app.quit(); } else if (!this.backgroundSupport) { windows.forEach((window) => window.setEnabled(false)); } @@ -260,12 +258,7 @@ class WebApplication { this.windowList[this.windowList.length - 1].show(); } terminate() { - console.log('WebApplication : terminate'); - if (!this.isTerminating) { - console.log('terminating app'); - this.isTerminating = true; - app.quit(); - } else console.log('termination is already in progress'); + this.isTerminating = true; } sendAppControlEvent() { const kAppControlEventScript =