Expose TopLevelWindow to JavaScript
This commit is contained in:
parent
cfed9fa4b9
commit
71ebd99dfa
6 changed files with 24 additions and 2 deletions
|
@ -29,7 +29,7 @@ namespace api {
|
|||
BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> wrapper,
|
||||
const mate::Dictionary& options)
|
||||
: TopLevelWindow(isolate, wrapper, options), weak_factory_(this) {
|
||||
: TopLevelWindow(isolate, options), weak_factory_(this) {
|
||||
mate::Handle<class WebContents> web_contents;
|
||||
|
||||
// Use options.webPreferences in WebContents.
|
||||
|
|
|
@ -70,7 +70,6 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
|
|||
} // namespace
|
||||
|
||||
TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> 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<v8::Object> 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();
|
||||
|
|
|
@ -35,6 +35,9 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
|||
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<v8::Object> wrapper,
|
||||
const mate::Dictionary& options);
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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'},
|
||||
|
|
9
lib/browser/api/top-level-window.js
Normal file
9
lib/browser/api/top-level-window.js
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue