diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index b137ec092ed5..e662b487d956 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -29,7 +29,7 @@ namespace api { BrowserWindow::BrowserWindow(v8::Isolate* isolate, v8::Local wrapper, const mate::Dictionary& options) - : TopLevelWindow(isolate, wrapper, options), weak_factory_(this) { + : TopLevelWindow(isolate, options), weak_factory_(this) { mate::Handle web_contents; // Use options.webPreferences in WebContents. diff --git a/atom/browser/api/atom_api_top_level_window.cc b/atom/browser/api/atom_api_top_level_window.cc index dd0c06af2c90..0ee8c228ed2f 100644 --- a/atom/browser/api/atom_api_top_level_window.cc +++ b/atom/browser/api/atom_api_top_level_window.cc @@ -70,7 +70,6 @@ v8::Local ToBuffer(v8::Isolate* isolate, void* val, int size) { } // namespace TopLevelWindow::TopLevelWindow(v8::Isolate* isolate, - v8::Local wrapper, const mate::Dictionary& options) : weak_factory_(this) { // The parent window. @@ -101,6 +100,15 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate, #endif } +TopLevelWindow::TopLevelWindow(v8::Isolate* isolate, + v8::Local wrapper, + const mate::Dictionary& options) + : TopLevelWindow(isolate, options) { + InitWith(isolate, wrapper); + // Init window after everything has been setup. + window()->InitFromOptions(options); +} + TopLevelWindow::~TopLevelWindow() { if (!window_->IsClosed()) window_->CloseImmediately(); diff --git a/atom/browser/api/atom_api_top_level_window.h b/atom/browser/api/atom_api_top_level_window.h index 6082735a8c59..2022bca62840 100644 --- a/atom/browser/api/atom_api_top_level_window.h +++ b/atom/browser/api/atom_api_top_level_window.h @@ -35,6 +35,9 @@ class TopLevelWindow : public mate::TrackableObject, NativeWindow* window() const { return window_.get(); } protected: + // Common constructor. + TopLevelWindow(v8::Isolate* isolate, const mate::Dictionary& options); + // Creating independent TopLevelWindow instance. TopLevelWindow(v8::Isolate* isolate, v8::Local wrapper, const mate::Dictionary& options); diff --git a/filenames.gypi b/filenames.gypi index 8b8dd7690bb9..3e0cb381fb6e 100644 --- a/filenames.gypi +++ b/filenames.gypi @@ -34,6 +34,7 @@ 'lib/browser/api/screen.js', 'lib/browser/api/session.js', 'lib/browser/api/system-preferences.js', + 'lib/browser/api/top-level-window.js', 'lib/browser/api/touch-bar.js', 'lib/browser/api/tray.js', 'lib/browser/api/web-contents.js', diff --git a/lib/browser/api/module-list.js b/lib/browser/api/module-list.js index e6f398b47d00..68f41b491b4c 100644 --- a/lib/browser/api/module-list.js +++ b/lib/browser/api/module-list.js @@ -19,6 +19,7 @@ module.exports = [ {name: 'screen', file: 'screen'}, {name: 'session', file: 'session'}, {name: 'systemPreferences', file: 'system-preferences'}, + {name: 'TopLevelWindow', file: 'top-level-window'}, {name: 'TouchBar', file: 'touch-bar'}, {name: 'Tray', file: 'tray'}, {name: 'webContents', file: 'web-contents'}, diff --git a/lib/browser/api/top-level-window.js b/lib/browser/api/top-level-window.js new file mode 100644 index 000000000000..d913c3585c15 --- /dev/null +++ b/lib/browser/api/top-level-window.js @@ -0,0 +1,9 @@ +'use strict' + +const {EventEmitter} = require('events') +const {TopLevelWindow} = process.atomBinding('top_level_window') +const v8Util = process.atomBinding('v8_util') + +Object.setPrototypeOf(TopLevelWindow.prototype, EventEmitter.prototype) + +module.exports = TopLevelWindow