*/
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');
'use strict';
const common_app = require('../common/app.js');
-const app = require('app');
+const {app} = require('electron');
class chromium_app extends common_app {
constructor () {
}
}
-module.exports = chromium_app;
\ No newline at end of file
+module.exports = chromium_app;
'use strict';
-var BrowserWindow = require('browser-window');
+var {BrowserWindow} = require('electron');
var common_browserWindow = require('../common/browserwindow.js');
}
loadUrl(url) {
- this.browserWindow.loadUrl(url);
+ this.browserWindow.loadURL(url);
}
show () {
}
}
-module.exports = chromium_browserWindow;
\ No newline at end of file
+module.exports = chromium_browserWindow;
--- /dev/null
+'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;
+++ /dev/null
-'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
--- /dev/null
+'use strict';
+
+class common_events {
+ constructor () {
+ this.events = null;
+ }
+
+ on () {
+
+ }
+
+ emit () {
+
+ }
+
+ send () {
+
+ }
+}
+
+module.exports = common_events;
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,
'web-security': false
}
}
-});
\ No newline at end of file
+});
+++ /dev/null
-'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'
- }
-});
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);
}
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');
}
}
-module.exports = ExtensionManager;
\ No newline at end of file
+module.exports = ExtensionManager;
'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
+});
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,
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);
module.exports = {
makeArguments : makeArguments,
parseCommandLine: parseCommandLine
-};
\ No newline at end of file
+};
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
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;
}
}
module.exports = {
app: commonModuleManager.app,
browserWindow: commonModuleManager.browserWindow,
- ipc: commonModuleManager.ipc
-};
\ No newline at end of file
+ events: commonModuleManager.events
+};
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() {
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);
});
--- /dev/null
+'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'
+ }
+});
'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');
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;
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;
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;
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);
}
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 {
'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');
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) {
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');
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');
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');
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');
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');
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) {
'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');
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 {
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);
}
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
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');
});
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) {
<script src="web_window.js"></script>
<meta charset="UTF-8" name="viewport" content="width=device-width, user-scalable=no">
<title>CANVAS</title>
+ <style>
+ webview {
+ height:100%;
+ }
+ </style>
</head>
<body>
<webview autosize="on" disablewebsecurity nodeintegration>
* 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) {
$(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);
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;
// 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();
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 <webview> tags
function handleLoadCommit(event) {
* 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() {
$(function(){
setWasEventHandler();
var webview = $('webview'),
- ipc = require('ipc'),
+ {ipcMain} = require('electron'),
path = require('path'),
windowId = CurrentBrowserWindow.id,
webview_tag_src_updated = false;
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);
}
// 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();
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 <webview> tags
function handleLoadCommit(event) {