chore: remove unused sendToAll + related APIs (#26771)

* chore: remove unused sendToAll + related APIs

* refactor: no need to args.ShallowClone() anymore
This commit is contained in:
Milan Burda 2020-12-03 07:55:50 +01:00 committed by GitHub
parent 8eee9d1290
commit b37982987a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 23 additions and 94 deletions

View file

@ -1577,7 +1577,6 @@ void WebContents::MessageSync(bool internal,
}
void WebContents::MessageTo(bool internal,
bool send_to_all,
int32_t web_contents_id,
const std::string& channel,
blink::CloneableMessage arguments) {
@ -1585,7 +1584,7 @@ void WebContents::MessageTo(bool internal,
auto* web_contents = FromID(web_contents_id);
if (web_contents) {
web_contents->SendIPCMessageWithSender(internal, send_to_all, channel,
web_contents->SendIPCMessageWithSender(internal, channel,
std::move(arguments), ID());
}
}
@ -2685,7 +2684,6 @@ bool WebContents::IsFocused() const {
#endif
bool WebContents::SendIPCMessage(bool internal,
bool send_to_all,
const std::string& channel,
v8::Local<v8::Value> args) {
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
@ -2695,37 +2693,21 @@ bool WebContents::SendIPCMessage(bool internal,
gin::StringToV8(isolate, "Failed to serialize arguments")));
return false;
}
return SendIPCMessageWithSender(internal, send_to_all, channel,
std::move(message));
return SendIPCMessageWithSender(internal, channel, std::move(message));
}
bool WebContents::SendIPCMessageWithSender(bool internal,
bool send_to_all,
const std::string& channel,
blink::CloneableMessage args,
int32_t sender_id) {
std::vector<content::RenderFrameHost*> target_hosts;
if (!send_to_all) {
auto* frame_host = web_contents()->GetMainFrame();
if (frame_host) {
target_hosts.push_back(frame_host);
}
} else {
target_hosts = web_contents()->GetAllFrames();
}
for (auto* frame_host : target_hosts) {
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
frame_host->GetRemoteAssociatedInterfaces()->GetInterface(
&electron_renderer);
electron_renderer->Message(internal, false, channel, args.ShallowClone(),
sender_id);
}
auto* frame_host = web_contents()->GetMainFrame();
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
frame_host->GetRemoteAssociatedInterfaces()->GetInterface(&electron_renderer);
electron_renderer->Message(internal, channel, std::move(args), sender_id);
return true;
}
bool WebContents::SendIPCMessageToFrame(bool internal,
bool send_to_all,
int32_t frame_id,
const std::string& channel,
v8::Local<v8::Value> args) {
@ -2747,7 +2729,7 @@ bool WebContents::SendIPCMessageToFrame(bool internal,
mojo::AssociatedRemote<mojom::ElectronRenderer> electron_renderer;
(*iter)->GetRemoteAssociatedInterfaces()->GetInterface(&electron_renderer);
electron_renderer->Message(internal, send_to_all, channel, std::move(message),
electron_renderer->Message(internal, channel, std::move(message),
0 /* sender_id */);
return true;
}