mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
do setOwnerWindow
This commit is contained in:
@@ -84,7 +84,7 @@ BrowserWindow.fromWebContents = (webContents: WebContents) => {
|
||||
};
|
||||
|
||||
BrowserWindow.fromBrowserView = (browserView: BrowserView) => {
|
||||
return browserView.ownerWindow;
|
||||
return BrowserWindow.fromWebContents(browserView.webContents);
|
||||
};
|
||||
|
||||
BrowserWindow.prototype.setTouchBar = function (touchBar) {
|
||||
@@ -162,8 +162,10 @@ BrowserWindow.prototype.setBackgroundThrottling = function (allowed: boolean) {
|
||||
};
|
||||
|
||||
BrowserWindow.prototype.addBrowserView = function (browserView: BrowserView) {
|
||||
if (browserView.ownerWindow) { browserView.ownerWindow.removeBrowserView(browserView); }
|
||||
this.contentView.addChildView(browserView.webContentsView);
|
||||
browserView.ownerWindow = this;
|
||||
browserView.webContents._setOwnerWindow(this);
|
||||
this._browserViews.push(browserView);
|
||||
};
|
||||
|
||||
@@ -193,7 +195,6 @@ BrowserWindow.prototype.getBrowserViews = function () {
|
||||
};
|
||||
|
||||
BrowserWindow.prototype.setTopBrowserView = function (browserView: BrowserView) {
|
||||
this.removeBrowserView(browserView);
|
||||
this.addBrowserView(browserView);
|
||||
};
|
||||
|
||||
|
||||
@@ -1998,6 +1998,10 @@ void WebContents::SetOwnerWindow(NativeWindow* owner_window) {
|
||||
SetOwnerWindow(GetWebContents(), owner_window);
|
||||
}
|
||||
|
||||
void WebContents::SetOwnerBaseWindow(BaseWindow* owner_window) {
|
||||
SetOwnerWindow(GetWebContents(), owner_window->window());
|
||||
}
|
||||
|
||||
void WebContents::SetOwnerWindow(content::WebContents* web_contents,
|
||||
NativeWindow* owner_window) {
|
||||
if (owner_window) {
|
||||
@@ -4033,6 +4037,7 @@ v8::Local<v8::ObjectTemplate> WebContents::FillObjectTemplate(
|
||||
.SetProperty("devToolsWebContents", &WebContents::DevToolsWebContents)
|
||||
.SetProperty("debugger", &WebContents::Debugger)
|
||||
.SetProperty("mainFrame", &WebContents::MainFrame)
|
||||
.SetMethod("_setOwnerWindow", &WebContents::SetOwnerBaseWindow)
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,8 @@ class OffScreenWebContentsView;
|
||||
|
||||
namespace api {
|
||||
|
||||
class BaseWindow;
|
||||
|
||||
// Wrapper around the content::WebContents.
|
||||
class WebContents : public ExclusiveAccessContext,
|
||||
public gin::Wrappable<WebContents>,
|
||||
@@ -375,6 +377,7 @@ class WebContents : public ExclusiveAccessContext,
|
||||
void SetOwnerWindow(NativeWindow* owner_window);
|
||||
void SetOwnerWindow(content::WebContents* web_contents,
|
||||
NativeWindow* owner_window);
|
||||
void SetOwnerBaseWindow(BaseWindow* owner_window);
|
||||
|
||||
// Returns the WebContents managed by this delegate.
|
||||
content::WebContents* GetWebContents() const;
|
||||
|
||||
1
typings/internal-electron.d.ts
vendored
1
typings/internal-electron.d.ts
vendored
@@ -88,6 +88,7 @@ declare namespace Electron {
|
||||
detachFromOuterFrame(): void;
|
||||
setEmbedder(embedder: Electron.WebContents): void;
|
||||
viewInstanceId: number;
|
||||
_setOwnerWindow(w: BaseWindow): void;
|
||||
}
|
||||
|
||||
interface WebFrameMain {
|
||||
|
||||
Reference in New Issue
Block a user