It is customized module of BrowserWindow and WebContents.
related to
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/208618/
Change-Id: I336c171e384316373e9cbb404efa7da4fb29e8a2
Signed-off-by: SangYong Park <sy302.park@samsung.com>
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const binding = process.binding('wrt_web_contents')
+const { WRTWebContents } = binding
+const { WebContents: AtomWebContents } = process.atomBinding('web_contents')
+
+const parent = AtomWebContents.prototype
+AtomWebContents.prototype = WRTWebContents.prototype
+
+Object.setPrototypeOf(WRTWebContents.prototype, parent)
+
+WRTWebContents.prototype._init = function () {
+ parent._init.call(this)
+}
+
+module.exports = {
+ create (options = {}) {
+ return binding.create(options)
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const { WRTWindow } = process.binding('wrt_window')
+const { BrowserWindow, TopLevelWindow } = require('electron')
+const WRTWebContents = require('../browser/wrt_web_contents');
+
+Object.setPrototypeOf(WRTWindow.prototype, BrowserWindow.prototype)
+
+WRTWindow.prototype._init = function () {
+ BrowserWindow.prototype._init.call(this)
+ this.setup()
+ let self = this
+ this.webContents.on('new-window', (event, url, frameName, disposition, options) => {
+ event.preventDefault()
+ let parentOptions = self.browserWindowOptions || {}
+ parentOptions.webContents = options.webContents || WRTWebContents()
+ const win = new WRTWindow(parentOptions)
+ event.newGuest = win
+ })
+}
+
+const isWindow = (win) => {
+ return win && win.constructor.name === 'WRTWindow'
+}
+
+WRTWindow.fromId = (id) => {
+ const win = TopLevelWindow.fromId(id)
+ return isWindow(win) ? win : null
+}
+
+WRTWindow.getAllWindows = () => {
+ return TopLevelWindow.getAllWindows().filter(isWindow)
+}
+
+module.exports = WRTWindow
'use strict';
-const {BrowserWindow, app, protocol} = require('electron');
+const { app, protocol } = require('electron');
const WAS_EVENT = require('./was_event');
const wrt = require('../browser/wrt');
+const WRTWebContents = require('../browser/wrt_web_contents');
+const WRTWindow = require('../browser/wrt_window');
class WebApplication {
constructor(options) {
}
});
}
- getBrowserWindowOption(options) {
+ getWindowOption(options) {
return {
fullscreen: false,
show: false,
nodeIntegration: options.isAddonAvailable,
nodeIntegrationInWorker: false
},
+ webContents: WRTWebContents.create(),
'web-preferences': {
'direct-write': true,
'subpixel-font-scaling': false,
};
}
createMainWindow(options) {
- let winopt = this.getBrowserWindowOption(options);
- this.mainWindow = new BrowserWindow(winopt);
+ let winopt = this.getWindowOption(options);
+ this.mainWindow = new WRTWindow(winopt);
if (options.devMode) {
this.mainWindow.webContents.openDevTools({
detached: true
console.log('App has been terminated; return');
return;
}
- let windows = BrowserWindow.getAllWindows();
+ let windows = WRTWindow.getAllWindows();
if (!this.multitaskingSupport) {
// FIXME : terminate app after visibilitychange event handling
setTimeout(() => {
console.log('WebApplication : resume firstRendered is false');
return;
}
- BrowserWindow.getAllWindows().forEach((window) => {
+ WRTWindow.getAllWindows().forEach((window) => {
if (!this.backgroundSupport)
window.setEnabled(true);
});
console.log('WebApplication : show');
this.preloadState = 'none';
if (!this.mainWindow.isVisible()) {
- console.log('show browserWindow');
+ console.log('show window');
this.mainWindow.show();
}
}
closeWindows() {
- BrowserWindow.getAllWindows().forEach((window) => {
+ WRTWindow.getAllWindows().forEach((window) => {
if (window != this.mainWindow)
window.destroy();
});