chore: remove unused and broken ipcRendererInternal.sendTo() (#29743)
This commit is contained in:
parent
6b4c59b8d8
commit
de6696ef1d
10 changed files with 12 additions and 25 deletions
|
@ -18,7 +18,7 @@ ipcRenderer.sendToHost = function (channel, ...args) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
|
ipcRenderer.sendTo = function (webContentsId, channel, ...args) {
|
||||||
return ipc.sendTo(internal, webContentsId, channel, args);
|
return ipc.sendTo(webContentsId, channel, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRenderer.invoke = async function (channel, ...args) {
|
ipcRenderer.invoke = async function (channel, ...args) {
|
||||||
|
|
|
@ -4,7 +4,8 @@ const { ipc } = process._linkedBinding('electron_renderer_ipc');
|
||||||
|
|
||||||
const internal = true;
|
const internal = true;
|
||||||
|
|
||||||
const ipcRendererInternal = new EventEmitter() as any as ElectronInternal.IpcRendererInternal;
|
export const ipcRendererInternal = new EventEmitter() as any as ElectronInternal.IpcRendererInternal;
|
||||||
|
|
||||||
ipcRendererInternal.send = function (channel, ...args) {
|
ipcRendererInternal.send = function (channel, ...args) {
|
||||||
return ipc.send(internal, channel, args);
|
return ipc.send(internal, channel, args);
|
||||||
};
|
};
|
||||||
|
@ -13,10 +14,6 @@ ipcRendererInternal.sendSync = function (channel, ...args) {
|
||||||
return ipc.sendSync(internal, channel, args);
|
return ipc.sendSync(internal, channel, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
ipcRendererInternal.sendTo = function (webContentsId, channel, ...args) {
|
|
||||||
return ipc.sendTo(internal, webContentsId, channel, args);
|
|
||||||
};
|
|
||||||
|
|
||||||
ipcRendererInternal.invoke = async function<T> (channel: string, ...args: any[]) {
|
ipcRendererInternal.invoke = async function<T> (channel: string, ...args: any[]) {
|
||||||
const { error, result } = await ipc.invoke<T>(internal, channel, args);
|
const { error, result } = await ipc.invoke<T>(internal, channel, args);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -24,5 +21,3 @@ ipcRendererInternal.invoke = async function<T> (channel: string, ...args: any[])
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
export { ipcRendererInternal };
|
|
||||||
|
|
|
@ -1601,8 +1601,7 @@ void WebContents::MessageSync(
|
||||||
internal, channel, std::move(arguments));
|
internal, channel, std::move(arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::MessageTo(bool internal,
|
void WebContents::MessageTo(int32_t web_contents_id,
|
||||||
int32_t web_contents_id,
|
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
blink::CloneableMessage arguments) {
|
blink::CloneableMessage arguments) {
|
||||||
TRACE_EVENT1("electron", "WebContents::MessageTo", "channel", channel);
|
TRACE_EVENT1("electron", "WebContents::MessageTo", "channel", channel);
|
||||||
|
@ -1617,7 +1616,7 @@ void WebContents::MessageTo(bool internal,
|
||||||
WebFrameMain::From(JavascriptEnvironment::GetIsolate(), frame);
|
WebFrameMain::From(JavascriptEnvironment::GetIsolate(), frame);
|
||||||
|
|
||||||
int32_t sender_id = ID();
|
int32_t sender_id = ID();
|
||||||
web_frame_main->GetRendererApi()->Message(internal, channel,
|
web_frame_main->GetRendererApi()->Message(false /* internal */, channel,
|
||||||
std::move(arguments), sender_id);
|
std::move(arguments), sender_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,8 +410,7 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||||
blink::CloneableMessage arguments,
|
blink::CloneableMessage arguments,
|
||||||
electron::mojom::ElectronBrowser::MessageSyncCallback callback,
|
electron::mojom::ElectronBrowser::MessageSyncCallback callback,
|
||||||
content::RenderFrameHost* render_frame_host);
|
content::RenderFrameHost* render_frame_host);
|
||||||
void MessageTo(bool internal,
|
void MessageTo(int32_t web_contents_id,
|
||||||
int32_t web_contents_id,
|
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
blink::CloneableMessage arguments);
|
blink::CloneableMessage arguments);
|
||||||
void MessageHost(const std::string& channel,
|
void MessageHost(const std::string& channel,
|
||||||
|
|
|
@ -86,14 +86,12 @@ void ElectronBrowserHandlerImpl::MessageSync(bool internal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElectronBrowserHandlerImpl::MessageTo(bool internal,
|
void ElectronBrowserHandlerImpl::MessageTo(int32_t web_contents_id,
|
||||||
int32_t web_contents_id,
|
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
blink::CloneableMessage arguments) {
|
blink::CloneableMessage arguments) {
|
||||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||||
if (api_web_contents) {
|
if (api_web_contents) {
|
||||||
api_web_contents->MessageTo(internal, web_contents_id, channel,
|
api_web_contents->MessageTo(web_contents_id, channel, std::move(arguments));
|
||||||
std::move(arguments));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,7 @@ class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
blink::CloneableMessage arguments,
|
blink::CloneableMessage arguments,
|
||||||
MessageSyncCallback callback) override;
|
MessageSyncCallback callback) override;
|
||||||
void MessageTo(bool internal,
|
void MessageTo(int32_t web_contents_id,
|
||||||
int32_t web_contents_id,
|
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
blink::CloneableMessage arguments) override;
|
blink::CloneableMessage arguments) override;
|
||||||
void MessageHost(const std::string& channel,
|
void MessageHost(const std::string& channel,
|
||||||
|
|
|
@ -63,7 +63,6 @@ interface ElectronBrowser {
|
||||||
// Emits an event from the |ipcRenderer| JavaScript object in the target
|
// Emits an event from the |ipcRenderer| JavaScript object in the target
|
||||||
// WebContents's main frame, specified by |web_contents_id|.
|
// WebContents's main frame, specified by |web_contents_id|.
|
||||||
MessageTo(
|
MessageTo(
|
||||||
bool internal,
|
|
||||||
int32 web_contents_id,
|
int32 web_contents_id,
|
||||||
string channel,
|
string channel,
|
||||||
blink.mojom.CloneableMessage arguments);
|
blink.mojom.CloneableMessage arguments);
|
||||||
|
|
|
@ -172,7 +172,6 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||||
|
|
||||||
void SendTo(v8::Isolate* isolate,
|
void SendTo(v8::Isolate* isolate,
|
||||||
gin_helper::ErrorThrower thrower,
|
gin_helper::ErrorThrower thrower,
|
||||||
bool internal,
|
|
||||||
int32_t web_contents_id,
|
int32_t web_contents_id,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
v8::Local<v8::Value> arguments) {
|
v8::Local<v8::Value> arguments) {
|
||||||
|
@ -184,7 +183,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||||
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
|
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
electron_browser_remote_->MessageTo(internal, web_contents_id, channel,
|
electron_browser_remote_->MessageTo(web_contents_id, channel,
|
||||||
std::move(message));
|
std::move(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
typings/internal-ambient.d.ts
vendored
2
typings/internal-ambient.d.ts
vendored
|
@ -35,7 +35,7 @@ declare namespace NodeJS {
|
||||||
send(internal: boolean, channel: string, args: any[]): void;
|
send(internal: boolean, channel: string, args: any[]): void;
|
||||||
sendSync(internal: boolean, channel: string, args: any[]): any;
|
sendSync(internal: boolean, channel: string, args: any[]): any;
|
||||||
sendToHost(channel: string, args: any[]): void;
|
sendToHost(channel: string, args: any[]): void;
|
||||||
sendTo(internal: boolean, webContentsId: number, channel: string, args: any[]): void;
|
sendTo(webContentsId: number, channel: string, args: any[]): void;
|
||||||
invoke<T>(internal: boolean, channel: string, args: any[]): Promise<{ error: string, result: T }>;
|
invoke<T>(internal: boolean, channel: string, args: any[]): Promise<{ error: string, result: T }>;
|
||||||
postMessage(channel: string, message: any, transferables: MessagePort[]): void;
|
postMessage(channel: string, message: any, transferables: MessagePort[]): void;
|
||||||
}
|
}
|
||||||
|
|
3
typings/internal-electron.d.ts
vendored
3
typings/internal-electron.d.ts
vendored
|
@ -229,11 +229,10 @@ declare namespace ElectronInternal {
|
||||||
appIcon: Electron.NativeImage | null;
|
appIcon: Electron.NativeImage | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IpcRendererInternal extends Electron.IpcRenderer {
|
interface IpcRendererInternal extends NodeJS.EventEmitter, Pick<Electron.IpcRenderer, 'send' | 'sendSync' | 'invoke'> {
|
||||||
invoke<T>(channel: string, ...args: any[]): Promise<T>;
|
invoke<T>(channel: string, ...args: any[]): Promise<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal IPC has _replyInternal and NO reply method
|
|
||||||
interface IpcMainInternalEvent extends Omit<Electron.IpcMainEvent, 'reply'> {
|
interface IpcMainInternalEvent extends Omit<Electron.IpcMainEvent, 'reply'> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue