Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused and broken ipcRendererInternal.sendTo() #29743

Merged
merged 1 commit into from Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/renderer/api/ipc-renderer.ts
Expand Up @@ -18,7 +18,7 @@ ipcRenderer.sendToHost = function (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) {
Expand Down
9 changes: 2 additions & 7 deletions lib/renderer/ipc-renderer-internal.ts
Expand Up @@ -4,7 +4,8 @@ const { ipc } = process._linkedBinding('electron_renderer_ipc');

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) {
return ipc.send(internal, channel, args);
};
Expand All @@ -13,16 +14,10 @@ ipcRendererInternal.sendSync = function (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[]) {
const { error, result } = await ipc.invoke<T>(internal, channel, args);
if (error) {
throw new Error(`Error invoking remote method '${channel}': ${error}`);
}
return result;
};

export { ipcRendererInternal };
5 changes: 2 additions & 3 deletions shell/browser/api/electron_api_web_contents.cc
Expand Up @@ -1601,8 +1601,7 @@ void WebContents::MessageSync(
internal, channel, std::move(arguments));
}

void WebContents::MessageTo(bool internal,
int32_t web_contents_id,
void WebContents::MessageTo(int32_t web_contents_id,
const std::string& channel,
blink::CloneableMessage arguments) {
TRACE_EVENT1("electron", "WebContents::MessageTo", "channel", channel);
Expand All @@ -1617,7 +1616,7 @@ void WebContents::MessageTo(bool internal,
WebFrameMain::From(JavascriptEnvironment::GetIsolate(), frame);

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);
}
}
Expand Down
3 changes: 1 addition & 2 deletions shell/browser/api/electron_api_web_contents.h
Expand Up @@ -409,8 +409,7 @@ class WebContents : public gin::Wrappable<WebContents>,
blink::CloneableMessage arguments,
electron::mojom::ElectronBrowser::MessageSyncCallback callback,
content::RenderFrameHost* render_frame_host);
void MessageTo(bool internal,
int32_t web_contents_id,
void MessageTo(int32_t web_contents_id,
const std::string& channel,
blink::CloneableMessage arguments);
void MessageHost(const std::string& channel,
Expand Down
6 changes: 2 additions & 4 deletions shell/browser/electron_browser_handler_impl.cc
Expand Up @@ -86,14 +86,12 @@ void ElectronBrowserHandlerImpl::MessageSync(bool internal,
}
}

void ElectronBrowserHandlerImpl::MessageTo(bool internal,
int32_t web_contents_id,
void ElectronBrowserHandlerImpl::MessageTo(int32_t web_contents_id,
const std::string& channel,
blink::CloneableMessage arguments) {
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
if (api_web_contents) {
api_web_contents->MessageTo(internal, web_contents_id, channel,
std::move(arguments));
api_web_contents->MessageTo(web_contents_id, channel, std::move(arguments));
}
}

Expand Down
3 changes: 1 addition & 2 deletions shell/browser/electron_browser_handler_impl.h
Expand Up @@ -44,8 +44,7 @@ class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser,
const std::string& channel,
blink::CloneableMessage arguments,
MessageSyncCallback callback) override;
void MessageTo(bool internal,
int32_t web_contents_id,
void MessageTo(int32_t web_contents_id,
const std::string& channel,
blink::CloneableMessage arguments) override;
void MessageHost(const std::string& channel,
Expand Down
1 change: 0 additions & 1 deletion shell/common/api/api.mojom
Expand Up @@ -63,7 +63,6 @@ interface ElectronBrowser {
// Emits an event from the |ipcRenderer| JavaScript object in the target
// WebContents's main frame, specified by |web_contents_id|.
MessageTo(
bool internal,
int32 web_contents_id,
string channel,
blink.mojom.CloneableMessage arguments);
Expand Down
3 changes: 1 addition & 2 deletions shell/renderer/api/electron_api_ipc_renderer.cc
Expand Up @@ -172,7 +172,6 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,

void SendTo(v8::Isolate* isolate,
gin_helper::ErrorThrower thrower,
bool internal,
int32_t web_contents_id,
const std::string& channel,
v8::Local<v8::Value> arguments) {
Expand All @@ -184,7 +183,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
return;
}
electron_browser_remote_->MessageTo(internal, web_contents_id, channel,
electron_browser_remote_->MessageTo(web_contents_id, channel,
std::move(message));
}

Expand Down
2 changes: 1 addition & 1 deletion typings/internal-ambient.d.ts
Expand Up @@ -35,7 +35,7 @@ declare namespace NodeJS {
send(internal: boolean, channel: string, args: any[]): void;
sendSync(internal: boolean, channel: string, args: any[]): any;
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 }>;
postMessage(channel: string, message: any, transferables: MessagePort[]): void;
}
Expand Down
3 changes: 1 addition & 2 deletions typings/internal-electron.d.ts
Expand Up @@ -229,11 +229,10 @@ declare namespace ElectronInternal {
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>;
}

// Internal IPC has _replyInternal and NO reply method
interface IpcMainInternalEvent extends Omit<Electron.IpcMainEvent, 'reply'> {
}

Expand Down