Add webContents.sendToAll to send message to all frames

This commit is contained in:
Cheng Zhao 2016-05-27 16:58:49 +09:00
parent c1facec5a6
commit 9ab76fb884
7 changed files with 58 additions and 18 deletions

View file

@ -1090,7 +1090,12 @@ void WebContents::TabTraverse(bool reverse) {
bool WebContents::SendIPCMessage(const base::string16& channel,
const base::ListValue& args) {
return Send(new AtomViewMsg_Message(routing_id(), channel, args));
return Send(new AtomViewMsg_Message(routing_id(), false, channel, args));
}
bool WebContents::SendIPCMessageToAll(const base::string16& channel,
const base::ListValue& args) {
return Send(new AtomViewMsg_Message(routing_id(), true, channel, args));
}
void WebContents::SendInputEvent(v8::Isolate* isolate,
@ -1258,6 +1263,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("focus", &WebContents::Focus)
.SetMethod("tabTraverse", &WebContents::TabTraverse)
.SetMethod("_send", &WebContents::SendIPCMessage)
.SetMethod("_sendToAll", &WebContents::SendIPCMessageToAll)
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
.SetMethod("beginFrameSubscription",
&WebContents::BeginFrameSubscription)

View file

@ -124,6 +124,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Send messages to browser.
bool SendIPCMessage(const base::string16& channel,
const base::ListValue& args);
bool SendIPCMessageToAll(const base::string16& channel,
const base::ListValue& args);
// Send WebInputEvent to the page.
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);