2 * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import { BrowserWindow } from 'electron';
18 import * as WRTWebContents from '../browser/wrt_web_contents';
20 export const { WRTWindow } = process.wrtBinding('wrt_window');
22 Object.setPrototypeOf(WRTWindow.prototype, BrowserWindow.prototype);
24 WRTWindow.prototype._init = function () {
25 (BrowserWindow.prototype as any)._init.call(this);
26 // This removes a macOS specific hack present in electron
27 // that causes side effects on Tizen
28 this.webContents.removeAllListeners('load-url');
29 if (typeof this.setup === 'function')
31 this.constructor = BrowserWindow;
32 this.webContents.on('new-window', (event: Electron.NewWindowWebContentsEvent,
35 disposition: ('default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'save-to-disk' | 'other'),
37 event.preventDefault();
38 if (!options.webContents) {
39 options.webContents = WRTWebContents.create();
40 options.webContents.loadURL(url);
42 event.newGuest = new WRTWindow(options);