From: Youngsoo Choi Date: Mon, 4 Sep 2017 13:06:49 +0000 (+0900) Subject: Upgrade wrt for electron v1.6.7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8d609641cbdf7fdf5782a8591feb464e191b4f3f;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Upgrade wrt for electron v1.6.7 The wrt was built on electron v0.35.4 and the electron has been upgraded to v1.6.7. There are following differences between them. This upgrades the changed APIs for electron v1.6.7. 1) requiring electron module The usage of electron module has been changed. For instance, |const app = require('app')| is changed to |const {app} = require('electron')|. 2) ipc usage The ipc has been separated to ipcMain and ipcRenderer. The related changes are applied by this. Also, this revises the message types as ipc_message or was_event. The ipc_message communicates between different processes but was_event communicates in same process. Change-Id: I8e6467a7721d9b715c918ccb179a3fe461ddbea4 Signed-off-by: Youngsoo Choi --- diff --git a/wrt/build/test/runtime/js/renderer-process/unittest.runtime.web_application.js b/wrt/build/test/runtime/js/renderer-process/unittest.runtime.web_application.js index 0d4652070..e11effa52 100644 --- a/wrt/build/test/runtime/js/renderer-process/unittest.runtime.web_application.js +++ b/wrt/build/test/runtime/js/renderer-process/unittest.runtime.web_application.js @@ -3,10 +3,10 @@ */ describe('runtime', function () { - const remote = require('remote'); + const remote = require('electron').remote; const assert = require('assert'); const should = require('should'); - const ipc = require('ipc'); + const {ipcMain} = require('electron'); const require_main = remote.require; const main = require_main('../../../../../src/main.js'); diff --git a/wrt/src/chromium/app.js b/wrt/src/chromium/app.js index 8a3870c8a..467fe651c 100644 --- a/wrt/src/chromium/app.js +++ b/wrt/src/chromium/app.js @@ -1,7 +1,7 @@ 'use strict'; const common_app = require('../common/app.js'); -const app = require('app'); +const {app} = require('electron'); class chromium_app extends common_app { constructor () { @@ -34,4 +34,4 @@ class chromium_app extends common_app { } } -module.exports = chromium_app; \ No newline at end of file +module.exports = chromium_app; diff --git a/wrt/src/chromium/browserwindow.js b/wrt/src/chromium/browserwindow.js index 28c0a36ac..22d986441 100644 --- a/wrt/src/chromium/browserwindow.js +++ b/wrt/src/chromium/browserwindow.js @@ -1,6 +1,6 @@ 'use strict'; -var BrowserWindow = require('browser-window'); +var {BrowserWindow} = require('electron'); var common_browserWindow = require('../common/browserwindow.js'); @@ -17,7 +17,7 @@ class chromium_browserWindow extends common_browserWindow { } loadUrl(url) { - this.browserWindow.loadUrl(url); + this.browserWindow.loadURL(url); } show () { @@ -77,4 +77,4 @@ class chromium_browserWindow extends common_browserWindow { } } -module.exports = chromium_browserWindow; \ No newline at end of file +module.exports = chromium_browserWindow; diff --git a/wrt/src/chromium/events.js b/wrt/src/chromium/events.js new file mode 100644 index 000000000..29f92e198 --- /dev/null +++ b/wrt/src/chromium/events.js @@ -0,0 +1,21 @@ +'use strict'; + +var common_events = require('../common/events.js'); +var Events = require('events'); + +class chromium_events extends common_events { + constructor () { + super(); + this.events = new Events(); + } + + on (event, callback) { + this.events.on(event, callback); + } + + emit (event) { + this.events.emit(event); + } +} + +module.exports = chromium_events; diff --git a/wrt/src/chromium/ipc.js b/wrt/src/chromium/ipc.js deleted file mode 100644 index 84c66c22d..000000000 --- a/wrt/src/chromium/ipc.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -var common_ipc = require('../common/ipc.js'); - -var ipc = require('ipc'); - -class chromium_ipc extends common_ipc { - constructor () { - super(); - this.ipc = ipc; - } - - on (event, callback) { - this.ipc.on(event, callback); - } - - emit (event) { - this.ipc.emit(event); - } -} - -module.exports = chromium_ipc; \ No newline at end of file diff --git a/wrt/src/common/events.js b/wrt/src/common/events.js new file mode 100644 index 000000000..4b80505ec --- /dev/null +++ b/wrt/src/common/events.js @@ -0,0 +1,21 @@ +'use strict'; + +class common_events { + constructor () { + this.events = null; + } + + on () { + + } + + emit () { + + } + + send () { + + } +} + +module.exports = common_events; diff --git a/wrt/src/default_value.js b/wrt/src/default_value.js index 94aad1fd2..35ec23042 100644 --- a/wrt/src/default_value.js +++ b/wrt/src/default_value.js @@ -8,8 +8,8 @@ define({ TIZEN: 'TIZEN' }, CANVAS:{ - PATH: 'wrt/static/web_window.html', - PATH_HOSTED: 'wrt/static_hosted/web_window.html' + PATH: 'static/web_window.html', + PATH_HOSTED: 'static_hosted/web_window.html' }, RULE: { CHILD_PROCESS_SPAWN: false, @@ -36,4 +36,4 @@ define({ 'web-security': false } } -}); \ No newline at end of file +}); diff --git a/wrt/src/event_define.js b/wrt/src/event_define.js deleted file mode 100644 index 66a60e299..000000000 --- a/wrt/src/event_define.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; -var define = require('node-constants')(exports); - -define({ - RUNTIME: { - MINIMIZE: 'was:runtime:minimize', - UNMINIMIZE: 'was:runtime:unminimize', - MAXIMIZE: 'was:runtime:maximize', - UNMAXIMIZE: 'was:runtime:unmaximize', - FOCUS: 'was:runtime:focus', - UNFOCUS: 'was:runtime:unfocus' - }, - WEBAPPLICATION: { - SUSPEND: 'was:webapplication:suspend', - RESUME: 'was:webapplication:resume' - }, - WEBCONTENTS: { - DID_FINISH_LOAD: 'was:webcontents:did-finish-load', - DID_FAIL_LOAD: 'was:webcontents:did-fail-load', - DID_FRAME_FINISH_LOAD: 'was:webcontents:did-frame-finish-load', - DID_START_LOADING: 'was:webcontents:did-start-loading', - DID_STOP_LOADING: 'was:webcontents:did-stop-loading', - DID_GET_RESPONSE_DETAILS: 'was:webcontents:did-get-response-details', - DID_GET_REDIRECT_REQUEST: 'was:webcontents:did-get-redirect-request', - DOM_READY: 'was:webcontents:dom-ready', - PAGE_FAVICON_UPDATED: 'was:webcontents:page-favicon-updated', - NEW_WINDOW: 'was:webcontents:new-window', - WILL_NAVIGATE: 'was:webcontents:will-navigate', - CRASHED: 'was:webcontents:crashed', - PLUGIN_CRASHED: 'was:webcontents:plugin-crashed', - DESTROYED: 'was:webcontents:destroyed', - UPDATE_SRC: 'was:webcontents:update-src' - }, - LAUNCHER:{ - UPDATE: 'was:launcher:update' - } -}); diff --git a/wrt/src/extension_manager.js b/wrt/src/extension_manager.js index e884ea167..a11cf8c33 100644 --- a/wrt/src/extension_manager.js +++ b/wrt/src/extension_manager.js @@ -10,8 +10,9 @@ const T_API = 'API'; var EXTENSIONS_PATH = process.env.WAS_EXTENSIONS_PATH; if (!EXTENSIONS_PATH) { + var resourcePath = __dirname.split('app.asar')[0]; extension_debug('WARNING! WAS_EXTENSIONS_PATH not set - extensions cannot be loaded'); - EXTENSIONS_PATH = path.join(__dirname, 'extensions'); + EXTENSIONS_PATH = path.join(resourcePath, 'wrt_support/extensions'); extension_debug('Temporarily set WAS_EXTENSIONS_PATH=' + EXTENSIONS_PATH); } @@ -117,6 +118,7 @@ class ExtensionManager { if (!js_path) { js_path = path.join(this.ext_path_, PRELOAD_JS_FILE); } + extension_debug('preload.js : ' + js_path); var fd; try { fd = fs.openSync(js_path, 'w'); @@ -303,4 +305,4 @@ class ExtensionManager { } } -module.exports = ExtensionManager; \ No newline at end of file +module.exports = ExtensionManager; diff --git a/wrt/src/ipc_message.js b/wrt/src/ipc_message.js index b31fe5450..63d441db8 100644 --- a/wrt/src/ipc_message.js +++ b/wrt/src/ipc_message.js @@ -1,10 +1,30 @@ 'use strict'; var define = require('node-constants')(exports); define({ + WEBCONTENTS: { + DID_FINISH_LOAD: 'ipc:webcontents:did-finish-load', + DID_FAIL_LOAD: 'ipc:webcontents:did-fail-load', + DID_FRAME_FINISH_LOAD: 'ipc:webcontents:did-frame-finish-load', + DID_START_LOADING: 'ipc:webcontents:did-start-loading', + DID_STOP_LOADING: 'ipc:webcontents:did-stop-loading', + DID_GET_RESPONSE_DETAILS: 'ipc:webcontents:did-get-response-details', + DID_GET_REDIRECT_REQUEST: 'ipc:webcontents:did-get-redirect-request', + DOM_READY: 'ipc:webcontents:dom-ready', + PAGE_FAVICON_UPDATED: 'ipc:webcontents:page-favicon-updated', + NEW_WINDOW: 'ipc:webcontents:new-window', + WILL_NAVIGATE: 'ipc:webcontents:will-navigate', + CRASHED: 'ipc:webcontents:crashed', + PLUGIN_CRASHED: 'ipc:webcontents:plugin-crashed', + DESTROYED: 'ipc:webcontents:destroyed', + UPDATE_SRC: 'ipc:webcontents:update-src' + }, + LAUNCHER:{ + UPDATE: 'ipc:launcher:update' + }, EXTENSIONS: { INSTALLED: 'ipc:extensions:installed', UNINSTALLED: 'ipc:extensions:uninstalled', ACTIVATE: 'ipc:extensions:activate', DEACTIVATE: 'ipc:extensions:deactivate' } -}); \ No newline at end of file +}); diff --git a/wrt/src/main.js b/wrt/src/main.js index e4597b7ac..245cc378c 100644 --- a/wrt/src/main.js +++ b/wrt/src/main.js @@ -14,9 +14,11 @@ const installer = 'installer'; const commonModuleManager = require('./manager'); const app = commonModuleManager.app; -var installPath = process.env.WAS_APPS_REPO || path.join(__dirname.split('out')[0], apps_repo), - installerPath = process.env.WAS_INSTALLER_PATH || path.join(__dirname.split('out')[0], installer), - developPath = process.env.WAS_HOME, +path_debug('__dirname : ' + __dirname); +var resourcePath = __dirname.split('app.asar')[0], + installPath = process.env.WAS_APPS_REPO || path.join(resourcePath, apps_repo), + installerPath = process.env.WAS_INSTALLER_PATH || path.join(resourcePath, 'wrt_support/installer'), + developPath = process.env.WAS_HOME || path.join(resourcePath, 'wrt_support'), parseCommandLine, makeArguments, start, @@ -54,7 +56,7 @@ makeArguments = function () { case 1: // launcher path_debug('package name : launcher'); packageName = args['packageName'] = DEFAULT.LAUNCHER.NAME; - packagePath = path.join(developPath,'sample', packageName); + packagePath = path.join(developPath, 'sample', packageName); if (fs.existsSync(packagePath)) { packageRealPath = packagePathPrefix + path.join(packagePath, packageIndexSuffix); path_debug('RealPath : ' + packageRealPath); @@ -231,4 +233,4 @@ start(makeArguments()); module.exports = { makeArguments : makeArguments, parseCommandLine: parseCommandLine -}; \ No newline at end of file +}; diff --git a/wrt/src/manager.js b/wrt/src/manager.js index efab0f50f..5d199cf61 100644 --- a/wrt/src/manager.js +++ b/wrt/src/manager.js @@ -2,7 +2,7 @@ const chromium_app = require('./chromium/app.js'); const chromium_browserWindow = require('./chromium/browserwindow.js'); -const chromium_ipc = require('./chromium/ipc.js'); +const chromium_events = require('./chromium/events.js'); var PLATFORM_ENUM = { CHROMIUM: 1 @@ -12,14 +12,14 @@ class CommonModuleManager { constructor (config) { this.app = null; this.browserWindow = null; - this.ipc = null; + this.events = null; this._init(config); } _init (config) { if (config === 1) { this.app = new chromium_app(); - this.ipc = new chromium_ipc(); + this.events = new chromium_events(); this.browserWindow = chromium_browserWindow; } } @@ -30,5 +30,5 @@ var commonModuleManager = new CommonModuleManager(PLATFORM_ENUM.CHROMIUM); module.exports = { app: commonModuleManager.app, browserWindow: commonModuleManager.browserWindow, - ipc: commonModuleManager.ipc -}; \ No newline at end of file + events: commonModuleManager.events +}; diff --git a/wrt/src/runtime.js b/wrt/src/runtime.js index dd54ffd27..b156ca3b9 100644 --- a/wrt/src/runtime.js +++ b/wrt/src/runtime.js @@ -4,11 +4,12 @@ const ExtensionManager = require('./extension_manager'); const IPC_MESSAGE = require('./ipc_message'); const runtime_debug = require('debug')('RUNTIME'); const try_debug = require('debug')('TRY'); -const WAS_EVENT = require('./event_define'); +const WAS_EVENT = require('./was_event'); const WebApplication = require('./web_application'); const commonModuleManager = require('./manager'); const app = commonModuleManager.app; -const ipc = commonModuleManager.ipc; +const events = commonModuleManager.events; +const {ipcMain} = require('electron'); class Runtime { constructor() { @@ -114,88 +115,89 @@ class Runtime { killAllProcesses() {} handleWasEvents() { var _this = this; - ipc.on(WAS_EVENT.RUNTIME.FOCUS, function(sender, id) { + events.on(WAS_EVENT.RUNTIME.FOCUS, (sender, id) => { + runtime_debug('handleWasMessages: focus ' + id); return _this.onResume(id); }); - ipc.on(WAS_EVENT.RUNTIME.UNFOCUS, function(sender, id) { + events.on(WAS_EVENT.RUNTIME.UNFOCUS, (sender, id) => { return _this.onPause(id); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DID_FINISH_LOAD, function(sender, id) { + } + handleIpcMessages() { + var _this = this; + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DID_FINISH_LOAD, (sender, id) => { runtime_debug('handleWasMessages: did-finish-load ' + id); - return app.emit(WAS_EVENT.WEBCONTENTS.DID_FINISH_LOAD, id); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DID_FINISH_LOAD, id); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DID_FAIL_LOAD, function(sender, id, params) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DID_FAIL_LOAD, function(sender, id, params) { runtime_debug('handleWasMessages: did-fail-load ' + id); runtime_debug(' params:' + JSON.stringify(params)); - return app.emit(WAS_EVENT.WEBCONTENTS.DID_FAIL_LOAD, id, params); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DID_FAIL_LOAD, id, params); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DID_FRAME_FINISH_LOAD, function(sender, id, params) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DID_FRAME_FINISH_LOAD, function(sender, id, params) { runtime_debug('handleWasMessages: did-frame-finish-load ' + id); runtime_debug(' params:' + JSON.stringify(params)); - return app.emit(WAS_EVENT.WEBCONTENTS.DID_FRAME_FINISH_LOAD, id, params); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DID_FRAME_FINISH_LOAD, id, params); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DID_START_LOADING, function(sender, id) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DID_START_LOADING, (sender, id) => { runtime_debug('handleWasMessages: did-start-loading ' + id); - return app.emit(WAS_EVENT.WEBCONTENTS.DID_START_LOADING, id); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DID_START_LOADING, id); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DID_STOP_LOADING, function(sender, id) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DID_STOP_LOADING, (sender, id) => { runtime_debug('handleWasMessages: did-stop-loading ' + id); - return app.emit(WAS_EVENT.WEBCONTENTS.DID_STOP_LOADING, id); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DID_STOP_LOADING, id); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, function(sender, id, params) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, function(sender, id, params) { runtime_debug('handleWasMessages: did-get-response-details ' + id); runtime_debug(' params:' + JSON.stringify(params)); - return app.emit(WAS_EVENT.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, id, params); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, id, params); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, function(sender, id, params) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, function(sender, id, params) { runtime_debug('handleWasMessages: did-get-redirect-request ' + id); runtime_debug(' params:' + JSON.stringify(params)); - return app.emit(WAS_EVENT.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, id, params); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, id, params); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DOM_READY, function(sender, id) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DOM_READY, (sender, id) => { runtime_debug('handleWasMessages: dom-ready ' + id); - return app.emit(WAS_EVENT.WEBCONTENTS.DOM_READY, id); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DOM_READY, id); }); - ipc.on(WAS_EVENT.WEBCONTENTS.PAGE_FAVICON_UPDATED, function(sender, id, params) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.PAGE_FAVICON_UPDATED, function(sender, id, params) { runtime_debug('handleWasMessages: page-favicon-updated ' + id); runtime_debug(' params:' + JSON.stringify(params)); - return app.emit(WAS_EVENT.WEBCONTENTS.PAGE_FAVICON_UPDATED, id, params); + return app.emit(IPC_MESSAGE.WEBCONTENTS.PAGE_FAVICON_UPDATED, id, params); }); - ipc.on(WAS_EVENT.WEBCONTENTS.NEW_WINDOW, function(sender, id, params) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.NEW_WINDOW, function(sender, id, params) { runtime_debug('handleWasMessages: new-window ' + id); runtime_debug(' params:' + JSON.stringify(params)); - return app.emit(WAS_EVENT.WEBCONTENTS.NEW_WINDOW, id, params); + return app.emit(IPC_MESSAGE.WEBCONTENTS.NEW_WINDOW, id, params); }); - ipc.on(WAS_EVENT.WEBCONTENTS.CRASHED, function(sender, id) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.CRASHED, (sender, id) => { runtime_debug('handleWasMessages: crashed ' + id); - return app.emit(WAS_EVENT.WEBCONTENTS.CRASHED, id); + return app.emit(IPC_MESSAGE.WEBCONTENTS.CRASHED, id); }); - ipc.on(WAS_EVENT.WEBCONTENTS.PLUGIN_CRASHED, function(sender, id, params) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.PLUGIN_CRASHED, function(sender, id, params) { runtime_debug('handleWasMessages: plugin-crashed ' + id); runtime_debug(' params:' + JSON.stringify(params)); - return app.emit(WAS_EVENT.WEBCONTENTS.PLUGIN_CRASHED, id, params); + return app.emit(IPC_MESSAGE.WEBCONTENTS.PLUGIN_CRASHED, id, params); }); - ipc.on(WAS_EVENT.WEBCONTENTS.DESTROYED, function(sender, id) { + ipcMain.on(IPC_MESSAGE.WEBCONTENTS.DESTROYED, (sender, id) => { runtime_debug('handleWasMessages: destroyed ' + id); - return app.emit(WAS_EVENT.WEBCONTENTS.DESTROYED, id); + return app.emit(IPC_MESSAGE.WEBCONTENTS.DESTROYED, id); }); - } - handleIpcMessages() { - var _this = this; - ipc.on(IPC_MESSAGE.EXTENSIONS.INSTALLED, function(sender, name) { + ipcMain.on(IPC_MESSAGE.EXTENSIONS.INSTALLED, (sender, name) => { runtime_debug('handleIpcMessages: INSTALLED ' + name); _this.extensionManager.build(); return _this.extensionManager.activate(app, name); }); - ipc.on(IPC_MESSAGE.EXTENSIONS.UNINSTALLED, function(sender, name) { + ipcMain.on(IPC_MESSAGE.EXTENSIONS.UNINSTALLED, (sender, name) => { runtime_debug('handleIpcMessages: UNINSTALLED ' + name); return _this.extensionManager.deactivate(app, name); }); - ipc.on(IPC_MESSAGE.EXTENSIONS.ACTIVATE, function(sender, name) { + ipcMain.on(IPC_MESSAGE.EXTENSIONS.ACTIVATE, (sender, name) => { runtime_debug('handleIpcMessages: ACTIVATE ' + name); return _this.extensionManager.activate(app, name); }); - ipc.on(IPC_MESSAGE.EXTENSIONS.DEACTIVATE, function(sender, name) { + ipcMain.on(IPC_MESSAGE.EXTENSIONS.DEACTIVATE, (sender, name) => { runtime_debug('handleIpcMessages: DEACTIVATE ' + name); return _this.extensionManager.deactivate(app, name); }); diff --git a/wrt/src/was_event.js b/wrt/src/was_event.js new file mode 100644 index 000000000..41007e2f4 --- /dev/null +++ b/wrt/src/was_event.js @@ -0,0 +1,17 @@ +'use strict'; +var define = require('node-constants')(exports); + +define({ + RUNTIME: { + MINIMIZE: 'was:runtime:minimize', + UNMINIMIZE: 'was:runtime:unminimize', + MAXIMIZE: 'was:runtime:maximize', + UNMAXIMIZE: 'was:runtime:unmaximize', + FOCUS: 'was:runtime:focus', + UNFOCUS: 'was:runtime:unfocus' + }, + WEBAPPLICATION: { + SUSPEND: 'was:webapplication:suspend', + RESUME: 'was:webapplication:resume' + } +}); diff --git a/wrt/src/web_application.js b/wrt/src/web_application.js index 07dd12433..0bb944c92 100644 --- a/wrt/src/web_application.js +++ b/wrt/src/web_application.js @@ -1,5 +1,5 @@ 'use strict'; -const WAS_EVENT = require('./event_define'); +const WAS_EVENT = require('./was_event'); const DEFAULT = require('./default_value'); const path = require('path'); const ChildProcess = require('child_process'); @@ -9,7 +9,8 @@ const rp_new_debug = require('debug')('RP_NEW'); const try_debug = require('debug')('TRY'); const commonModuleManager = require('./manager'); const app = commonModuleManager.app; -const ipc = commonModuleManager.ipc; +const events = commonModuleManager.events; +const {ipcMain} = require('electron'); const BrowserWindow = commonModuleManager.browserWindow; var WebWindow = null; @@ -71,7 +72,6 @@ class WebApplication { var unfocused_web_contents, result; webapplication_debug('WebApplication : suspend id = ' + web_window_id); unfocused_web_contents = BrowserWindow.fromId(web_window_id).webContents; - webapplication_debug('WebApplication : selected webwindow = ' + (JSON.stringify(unfocused_web_contents))); unfocused_web_contents.stop(); unfocused_web_contents.send(WAS_EVENT.WEBAPPLICATION.SUSPEND, web_window_id); result = web_window_id; @@ -106,7 +106,6 @@ class WebApplication { makeNewWebWindow(event, options) { var packageName, packagePath, packageType, packageContent; - webapplication_debug('LauncherEvent : ' + (JSON.stringify(event))); webapplication_debug('LauncherEvent options : ' + (JSON.stringify(options))); packageName = options.packageName; packageType = options.type; @@ -114,10 +113,12 @@ class WebApplication { if (packageType === 'hosted') { options.packageRealPath = options.content; } else { + let resourcePath = __dirname.split('app.asar')[0]; packagePath = path.join(this.installPath, packageName); packageContent = options.content ? options.content : this.packageIndexSuffix; - options.packageRealPath = this.packagePathPrefix + path.join(packagePath, packageContent); + options.packageRealPath = this.packagePathPrefix + path.join(resourcePath, 'wrt_support/apps_repo', packageName, packageContent); } + webapplication_debug('options.packageRealPath : ' + options.packageRealPath); return new WebWindow(options); } @@ -155,7 +156,7 @@ class WebApplication { handleLauncherEvents() { var self = this; - ipc.on('open', function(event, options) { + ipcMain.on('open', function(event, options) { if (DEFAULT.RULE.CHILD_PROCESS_SPAWN) { self.makeForkForNewView(event, options); } else { diff --git a/wrt/src/web_window.js b/wrt/src/web_window.js index 4ba8e27d0..891c9c23d 100644 --- a/wrt/src/web_window.js +++ b/wrt/src/web_window.js @@ -1,5 +1,6 @@ 'use strict'; -const WAS_EVENT = require('./event_define'); +const IPC_MESSAGE = require('./ipc_message'); +const WAS_EVENT = require('./was_event'); const DEFAULT = require('./default_value'); const DEFAULT_URL = 'http://www.samsung.com'; const webwindow_debug = require('debug')('WEBWINDOW'); @@ -8,8 +9,9 @@ const path = require('path'); const ExtensionManager = require('./extension_manager'); const rp_new_debug = require('debug')('RP_NEW'); const commonModuleManager = require('./manager'); -const ipc = commonModuleManager.ipc; +const {ipcRenderer} = require('electron'); const BrowserWindow = commonModuleManager.browserWindow; +const events = commonModuleManager.events; class WebWindow { constructor(options) { @@ -58,11 +60,11 @@ class WebWindow { var self = this; this.mainWindow.on('focus', function() { webwindow_debug('WebWindow : focus'); - ipc.emit(WAS_EVENT.RUNTIME.FOCUS, 'web_window', self.mainWindow.id); + events.emit(WAS_EVENT.RUNTIME.FOCUS, 'web_window', self.mainWindow.id); }); this.mainWindow.on('blur', function() { webwindow_debug('WebWindow : blur'); - ipc.emit(WAS_EVENT.RUNTIME.UNFOCUS, 'web_window', self.mainWindow.id); + events.emit(WAS_EVENT.RUNTIME.UNFOCUS, 'web_window', self.mainWindow.id); }); this.mainWindow.on('maximize', function(event, command, args) { webwindow_debug('WebWindow : maximize'); @@ -140,7 +142,7 @@ class WebWindow { webwindow_debug('WebWindow : browserWindow show options is ',options.show); self.show(); } - ipc.emit(WAS_EVENT.WEBCONTENTS.DID_FINISH_LOAD, 'web_window', self.mainWindow.id); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_FINISH_LOAD, 'web_window', self.mainWindow.id); }); this.mainWindow.webContents.on('did-fail-load', function(event, errorCode, errorDescription, validatedUrl) { webwindow_debug('WebWindow : webContents did-fail-load'); @@ -148,21 +150,21 @@ class WebWindow { params.errorCode = errorCode; params.errorDescription = errorDescription; params.validatedUrl = validatedUrl; - ipc.emit(WAS_EVENT.WEBCONTENTS.DID_FAIL_LOAD, 'web_window', self.mainWindow.id, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_FAIL_LOAD, 'web_window', self.mainWindow.id, params); }); this.mainWindow.webContents.on('did-frame-finish-load', function(event, isMainFrame) { webwindow_debug('WebWindow : webContents did-frame-finish-load:'); var params = {}; params.isMainFrame = isMainFrame; - ipc.emit(WAS_EVENT.WEBCONTENTS.DID_FRAME_FINISH_LOAD, 'web_window', self.mainWindow.id, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_FRAME_FINISH_LOAD, 'web_window', self.mainWindow.id, params); }); this.mainWindow.webContents.on('did-start-loading', function() { webwindow_debug('WebWindow : webContents did-start-loading'); - ipc.emit(WAS_EVENT.WEBCONTENTS.DID_START_LOADING, 'web_window', self.mainWindow.id); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_START_LOADING, 'web_window', self.mainWindow.id); }); this.mainWindow.webContents.on('did-stop-loading', function() { webwindow_debug('WebWindow : webContents did-stop-loading'); - ipc.emit(WAS_EVENT.WEBCONTENTS.DID_STOP_LOADING, 'web_window', self.mainWindow.id); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_STOP_LOADING, 'web_window', self.mainWindow.id); }); this.mainWindow.webContents.on('did-get-response-details', function(event, status, newUrl, originalUrl, httpResponseCode, requestMethod, referrer, headers) { webwindow_debug('WebWindow : webContents did-get-response-details'); @@ -174,7 +176,7 @@ class WebWindow { params.requestMethod = requestMethod; params.referrer = referrer; params.headers = headers; - ipc.emit(WAS_EVENT.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, 'web_window', self.mainWindow.id, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, 'web_window', self.mainWindow.id, params); }); this.mainWindow.webContents.on('did-get-redirect-request', function(event, oldUrl, newUrl, isMainFrame, httpResponseCode, requestMethod, referrer, headers) { webwindow_debug('WebWindow : webContents did-get-redirect-request'); @@ -186,17 +188,17 @@ class WebWindow { params.requestMethod = requestMethod; params.referrer = referrer; params.headers = headers; - ipc.emit(WAS_EVENT.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, 'web_window', self.mainWindow.id, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, 'web_window', self.mainWindow.id, params); }); this.mainWindow.webContents.on('dom-ready', function(event) { webwindow_debug('WebWindow : webContents dom-ready'); - ipc.emit(WAS_EVENT.WEBCONTENTS.DOM_READY, 'web_window', self.mainWindow.id); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DOM_READY, 'web_window', self.mainWindow.id); }); this.mainWindow.webContents.on('page-favicon-updated', function(event, favicons) { webwindow_debug('WebWindow : webContents page-favicon-updated'); var params = {}; params.favicons = favicons; - ipc.emit(WAS_EVENT.WEBCONTENTS.PAGE_FAVICON_UPDATED, 'web_window', self.mainWindow.id, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.PAGE_FAVICON_UPDATED, 'web_window', self.mainWindow.id, params); }); this.mainWindow.webContents.on('new-window', function(event, url, frameName, disposition, options) { webwindow_debug('WebWindow : webContents new-window'); @@ -205,25 +207,25 @@ class WebWindow { params.frameName = frameName; params.disposition = disposition; params.options = options; - ipc.emit(WAS_EVENT.WEBCONTENTS.NEW_WINDOW, 'web_window', self.mainWindow.id, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.NEW_WINDOW, 'web_window', self.mainWindow.id, params); }); this.mainWindow.webContents.on('will-navigate', function(event, url) { webwindow_debug('WebWindow : webContents will-navigate'); }); this.mainWindow.webContents.on('crashed', function() { webwindow_debug('WebWindow : webContents crashed'); - ipc.emit(WAS_EVENT.WEBCONTENTS.CRASHED, 'web_window', self.mainWindow.id); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.CRASHED, 'web_window', self.mainWindow.id); }); this.mainWindow.webContents.on('plugin-crashed', function(event, name, version) { webwindow_debug('WebWindow : webContents plugin-crashed'); var params = {}; params.name = name; params.version = version; - ipc.emit(WAS_EVENT.WEBCONTENTS.PLUGIN_CRASHED, 'web_window', self.mainWindow.id, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.PLUGIN_CRASHED, 'web_window', self.mainWindow.id, params); }); this.mainWindow.webContents.on('destroyed', function() { webwindow_debug('WebWindow : webContents destroyed'); - ipc.emit(WAS_EVENT.WEBCONTENTS.DESTROYED, 'web_window', self.mainWindow.id); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DESTROYED, 'web_window', self.mainWindow.id); }); } setUrl(path) { diff --git a/wrt/src/web_window_tag.js b/wrt/src/web_window_tag.js index 56ebee05f..63335faf9 100644 --- a/wrt/src/web_window_tag.js +++ b/wrt/src/web_window_tag.js @@ -1,5 +1,6 @@ 'use strict'; -const WAS_EVENT = require('./event_define'); +const IPC_MESSAGE = require('./ipc_message'); +const WAS_EVENT = require('./was_event'); const DEFAULT = require('./default_value'); const DEFAULT_URL = 'http://www.samsung.com'; const webwindow_debug = require('debug')('WEBWINDOW_TAG'); @@ -8,7 +9,7 @@ const path = require('path'); const ExtensionManager = require('./extension_manager'); const rp_new_debug = require('debug')('RP_NEW'); const commonModuleManager = require('./manager'); -const ipc = commonModuleManager.ipc; +const events = commonModuleManager.events; const BrowserWindow = commonModuleManager.browserWindow; class WebWindowTag { @@ -23,6 +24,7 @@ class WebWindowTag { this.canvas = this.makeCanvas(type_hosted); webwindow_debug('canvas: ' + this.canvas); + webwindow_debug('canvas.mainWindow.id: ' + this.canvas.mainWindow.id); this.mainWindow = this.canvas.mainWindow; this.handleEvents(options); @@ -36,16 +38,27 @@ class WebWindowTag { } makeCanvas(type_hosted){ var canvas_option = WebWindowTag.getBrowserWindowOption(), - resolved_path = process.env.WAS_HOME, + resolved_path = process.env.WAS_HOME || path.join(__dirname, '..'), packagePathPrefix = 'file://', canvas_html_path = path.join(packagePathPrefix, resolved_path, DEFAULT.CANVAS.PATH); + webwindow_debug('canvas_packageRealPath 111 : ' + packagePathPrefix); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); if (type_hosted === true) { canvas_html_path = path.join(packagePathPrefix, resolved_path, DEFAULT.CANVAS.PATH_HOSTED); } canvas_option.preload = path.join(ExtensionManager.getExtensionsPath(), ExtensionManager.getPreloadJsFile()); webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); + webwindow_debug('canvas_packageRealPath: ' + canvas_html_path); return { mainWindow: new BrowserWindow(canvas_option), html_path: canvas_html_path @@ -78,11 +91,12 @@ class WebWindowTag { var self = this; this.mainWindow.on('focus', function() { webwindow_debug('WebWindow : focus'); - ipc.emit(WAS_EVENT.RUNTIME.FOCUS, 'web_window', self.mainWindow.id); + webwindow_debug('WebWindow : self.mainWindow.id = ' + self.mainWindow.id); + events.emit(WAS_EVENT.RUNTIME.FOCUS, 'web_window', self.mainWindow.id); }); this.mainWindow.on('blur', function() { webwindow_debug('WebWindow : blur'); - ipc.emit(WAS_EVENT.RUNTIME.UNFOCUS, 'web_window', self.mainWindow.id); + events.emit(WAS_EVENT.RUNTIME.UNFOCUS, 'web_window', self.mainWindow.id); }); this.mainWindow.on('maximize', function(event, command, args) { webwindow_debug('WebWindow : maximize'); @@ -156,8 +170,10 @@ class WebWindowTag { }); this.mainWindow.webContents.on('dom-ready', function() { webwindow_debug('WebWindow : webContents dom-ready'); - webwindow_debug('WebWindow : DEFAULT.WEBCONTENTS.UPDATE_SRC', WAS_EVENT.WEBCONTENTS.UPDATE_SRC); - self.mainWindow.webContents.send(WAS_EVENT.WEBCONTENTS.UPDATE_SRC, options.packageRealPath); + webwindow_debug('WebWindow : IPC_MESSAGE.WEBCONTENTS.UPDATE_SRC', IPC_MESSAGE.WEBCONTENTS.UPDATE_SRC); + webwindow_debug('WebWindow : src = ', options.packageRealPath); + webwindow_debug('WebWindow : options = ', JSON.stringify(options)); + self.mainWindow.webContents.send(IPC_MESSAGE.WEBCONTENTS.UPDATE_SRC, options.packageRealPath); }); } setUrl(path) { diff --git a/wrt/static/web_window.html b/wrt/static/web_window.html index 6229c20bb..c1f1f250e 100644 --- a/wrt/static/web_window.html +++ b/wrt/static/web_window.html @@ -5,6 +5,11 @@ CANVAS + diff --git a/wrt/static/web_window.js b/wrt/static/web_window.js index 947c27ca8..8f7df58b6 100644 --- a/wrt/static/web_window.js +++ b/wrt/static/web_window.js @@ -2,9 +2,9 @@ * Created by hosoup on 15. 11. 5. */ $ = require('./bower_components/jquery/dist/jquery.min.js'); -const remote = require('remote'); +const remote = require('electron').remote; const CurrentBrowserWindow = remote.getCurrentWindow(); -const WAS_EVENT = remote.require('./event_define'); +const IPC_MESSAGE = remote.require('./ipc_message'); function setWasEventHandler() { window.addEventListener('keydown', function(e) { if (e.keyCode == 27) { @@ -25,12 +25,18 @@ function setWasEventHandler() { $(function(){ setWasEventHandler(); var webview = $('webview'), - ipc = require('ipc'), + {ipcRenderer} = require('electron'), path = require('path'), windowId = CurrentBrowserWindow.id, webview_tag_src_updated = false; - var preload = path.join(process.env.WAS_EXTENSIONS_PATH, "preload.js"); - webview.attr('preload', preload); + var EXTENSIONS_PATH = process.env.WAS_EXTENSIONS_PATH; + if (!EXTENSIONS_PATH) { + var resourcePath = __dirname.split('app.asar')[0]; + EXTENSIONS_PATH = path.join(resourcePath, 'wrt_support/extensions'); + } + var preload = path.join(EXTENSIONS_PATH, "preload.js"); + console.log("preload.js : " + preload); +// webview.attr('preload', preload); // webContents events webview.on('did-finish-load', handleLoadFinish); @@ -51,17 +57,17 @@ $(function(){ webview.on('page-title-set', handlePageTitleSet); webview.on('close', handleExit); - ipc.on(WAS_EVENT.WEBCONTENTS.UPDATE_SRC, handleUpdateWebViewSrc); - ipc.on(WAS_EVENT.LAUNCHER.UPDATE, updateLauncher ); + ipcRenderer.on(IPC_MESSAGE.WEBCONTENTS.UPDATE_SRC, handleUpdateWebViewSrc); + ipcRenderer.on(IPC_MESSAGE.LAUNCHER.UPDATE, updateLauncher ); function updateLauncher(){ console.log("update launcher in canvas"); - //Delegate ipc message to webview tag - webview[0].send(WAS_EVENT.LAUNCHER.UPDATE); + //Delegate ipcRenderer message to webview tag + webview[0].send(IPC_MESSAGE.LAUNCHER.UPDATE); } - function handleUpdateWebViewSrc(url){ - console.log("handleUpdateWebViewSrc : ", url); + function handleUpdateWebViewSrc(events, url){ + console.log("handleUpdateWebViewSrc : ", JSON.stringify(url)); if(webview_tag_src_updated) return; webview.attr("src", url); webview_tag_src_updated = true; @@ -70,7 +76,7 @@ $(function(){ // handle webContents events function handleLoadFinish(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DID_FINISH_LOAD, windowId); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_FINISH_LOAD, windowId); CurrentBrowserWindow.show(); if (process.env.DEBUG && process.env.TARGET != "TIZEN") webview[0].openDevTools(); @@ -78,57 +84,57 @@ $(function(){ function handleLoadFail(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_FAIL_LOAD, windowId, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_FAIL_LOAD, windowId, params); } function handleLoadFrameFinish(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_FRAME_FINISH_LOAD, windowId, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_FRAME_FINISH_LOAD, windowId, params); } function handleLoadStart(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DID_START_LOADING, windowId); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_START_LOADING, windowId); } function handleLoadStop(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DID_STOP_LOADING, windowId); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_STOP_LOADING, windowId); } function handleGetResponseDetails(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, windowId, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, windowId, params); } function handleGetRedirectRequest(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, windowId, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, windowId, params); } function handleDomReady(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DOM_READY, windowId); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DOM_READY, windowId); } function handlePageFaviconUpdated(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.PAGE_FAVICON_UPDATED, windowId, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.PAGE_FAVICON_UPDATED, windowId, params); } function handleNewWindow(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.NEW_WINDOW, windowId, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.NEW_WINDOW, windowId, params); } function handleCrashed(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.CRASHED, windowId); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.CRASHED, windowId); } function handlePluginCrashed(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.PLUGIN_CRASHED, windowId, params); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.PLUGIN_CRASHED, windowId, params); } function handleDestroyed(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DESTROYED, windowId); + ipcRenderer.send(IPC_MESSAGE.WEBCONTENTS.DESTROYED, windowId); } // handle webContents events only for tags function handleLoadCommit(event) { diff --git a/wrt/static_hosted/web_window.js b/wrt/static_hosted/web_window.js index 947c27ca8..7d97d3e6b 100644 --- a/wrt/static_hosted/web_window.js +++ b/wrt/static_hosted/web_window.js @@ -2,7 +2,7 @@ * Created by hosoup on 15. 11. 5. */ $ = require('./bower_components/jquery/dist/jquery.min.js'); -const remote = require('remote'); +const remote = require('electron').remote; const CurrentBrowserWindow = remote.getCurrentWindow(); const WAS_EVENT = remote.require('./event_define'); function setWasEventHandler() { @@ -25,7 +25,7 @@ function setWasEventHandler() { $(function(){ setWasEventHandler(); var webview = $('webview'), - ipc = require('ipc'), + {ipcMain} = require('electron'), path = require('path'), windowId = CurrentBrowserWindow.id, webview_tag_src_updated = false; @@ -51,12 +51,12 @@ $(function(){ webview.on('page-title-set', handlePageTitleSet); webview.on('close', handleExit); - ipc.on(WAS_EVENT.WEBCONTENTS.UPDATE_SRC, handleUpdateWebViewSrc); - ipc.on(WAS_EVENT.LAUNCHER.UPDATE, updateLauncher ); + ipcMain.on(WAS_EVENT.WEBCONTENTS.UPDATE_SRC, handleUpdateWebViewSrc); + ipcMain.on(WAS_EVENT.LAUNCHER.UPDATE, updateLauncher ); function updateLauncher(){ console.log("update launcher in canvas"); - //Delegate ipc message to webview tag + //Delegate ipcMain message to webview tag webview[0].send(WAS_EVENT.LAUNCHER.UPDATE); } @@ -70,7 +70,7 @@ $(function(){ // handle webContents events function handleLoadFinish(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DID_FINISH_LOAD, windowId); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DID_FINISH_LOAD, windowId); CurrentBrowserWindow.show(); if (process.env.DEBUG && process.env.TARGET != "TIZEN") webview[0].openDevTools(); @@ -78,57 +78,57 @@ $(function(){ function handleLoadFail(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_FAIL_LOAD, windowId, params); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DID_FAIL_LOAD, windowId, params); } function handleLoadFrameFinish(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_FRAME_FINISH_LOAD, windowId, params); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DID_FRAME_FINISH_LOAD, windowId, params); } function handleLoadStart(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DID_START_LOADING, windowId); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DID_START_LOADING, windowId); } function handleLoadStop(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DID_STOP_LOADING, windowId); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DID_STOP_LOADING, windowId); } function handleGetResponseDetails(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, windowId, params); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DID_GET_RESPONSE_DETAILS, windowId, params); } function handleGetRedirectRequest(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, windowId, params); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DID_GET_REDIRECT_REQUEST, windowId, params); } function handleDomReady(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DOM_READY, windowId); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DOM_READY, windowId); } function handlePageFaviconUpdated(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.PAGE_FAVICON_UPDATED, windowId, params); + ipcMain.send(WAS_EVENT.WEBCONTENTS.PAGE_FAVICON_UPDATED, windowId, params); } function handleNewWindow(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.NEW_WINDOW, windowId, params); + ipcMain.send(WAS_EVENT.WEBCONTENTS.NEW_WINDOW, windowId, params); } function handleCrashed(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.CRASHED, windowId); + ipcMain.send(WAS_EVENT.WEBCONTENTS.CRASHED, windowId); } function handlePluginCrashed(event) { console.log(event.type); var params = event.originalEvent; - ipc.send(WAS_EVENT.WEBCONTENTS.PLUGIN_CRASHED, windowId, params); + ipcMain.send(WAS_EVENT.WEBCONTENTS.PLUGIN_CRASHED, windowId, params); } function handleDestroyed(event) { console.log(event.type); - ipc.send(WAS_EVENT.WEBCONTENTS.DESTROYED, windowId); + ipcMain.send(WAS_EVENT.WEBCONTENTS.DESTROYED, windowId); } // handle webContents events only for tags function handleLoadCommit(event) {