Simplify the implementation of sendToAll
This commit is contained in:
parent
de001a9bbf
commit
5f3fdbe635
3 changed files with 9 additions and 20 deletions
|
@ -1088,14 +1088,10 @@ void WebContents::TabTraverse(bool reverse) {
|
||||||
web_contents()->FocusThroughTabTraversal(reverse);
|
web_contents()->FocusThroughTabTraversal(reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::SendIPCMessage(const base::string16& channel,
|
bool WebContents::SendIPCMessage(bool all_frames,
|
||||||
|
const base::string16& channel,
|
||||||
const base::ListValue& args) {
|
const base::ListValue& args) {
|
||||||
return Send(new AtomViewMsg_Message(routing_id(), false, channel, args));
|
return Send(new AtomViewMsg_Message(routing_id(), all_frames, 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,
|
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
|
@ -1263,7 +1259,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("focus", &WebContents::Focus)
|
.SetMethod("focus", &WebContents::Focus)
|
||||||
.SetMethod("tabTraverse", &WebContents::TabTraverse)
|
.SetMethod("tabTraverse", &WebContents::TabTraverse)
|
||||||
.SetMethod("_send", &WebContents::SendIPCMessage)
|
.SetMethod("_send", &WebContents::SendIPCMessage)
|
||||||
.SetMethod("_sendToAll", &WebContents::SendIPCMessageToAll)
|
|
||||||
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
|
.SetMethod("sendInputEvent", &WebContents::SendInputEvent)
|
||||||
.SetMethod("beginFrameSubscription",
|
.SetMethod("beginFrameSubscription",
|
||||||
&WebContents::BeginFrameSubscription)
|
&WebContents::BeginFrameSubscription)
|
||||||
|
|
|
@ -122,10 +122,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
void TabTraverse(bool reverse);
|
void TabTraverse(bool reverse);
|
||||||
|
|
||||||
// Send messages to browser.
|
// Send messages to browser.
|
||||||
bool SendIPCMessage(const base::string16& channel,
|
bool SendIPCMessage(bool all_frames,
|
||||||
|
const base::string16& channel,
|
||||||
const base::ListValue& args);
|
const base::ListValue& args);
|
||||||
bool SendIPCMessageToAll(const base::string16& channel,
|
|
||||||
const base::ListValue& args);
|
|
||||||
|
|
||||||
// Send WebInputEvent to the page.
|
// Send WebInputEvent to the page.
|
||||||
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
void SendInputEvent(v8::Isolate* isolate, v8::Local<v8::Value> input_event);
|
||||||
|
|
|
@ -71,20 +71,15 @@ let wrapWebContents = function (webContents) {
|
||||||
webContents.setMaxListeners(0)
|
webContents.setMaxListeners(0)
|
||||||
|
|
||||||
// WebContents::send(channel, args..)
|
// WebContents::send(channel, args..)
|
||||||
webContents.send = function (channel, ...args) {
|
|
||||||
if (channel == null) {
|
|
||||||
throw new Error('Missing required channel argument')
|
|
||||||
}
|
|
||||||
return this._send(channel, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebContents::sendToAll(channel, args..)
|
// WebContents::sendToAll(channel, args..)
|
||||||
webContents.sendToAll = function (channel, ...args) {
|
const sendWrapper = (allFrames, channel, ...args) => {
|
||||||
if (channel == null) {
|
if (channel == null) {
|
||||||
throw new Error('Missing required channel argument')
|
throw new Error('Missing required channel argument')
|
||||||
}
|
}
|
||||||
return this._sendToAll(channel, args)
|
return webContents._send(allFrames, channel, args)
|
||||||
}
|
}
|
||||||
|
webContents.send = sendWrapper.bind(null, false)
|
||||||
|
webContents.sendToAll = sendWrapper.bind(null, true)
|
||||||
|
|
||||||
// The navigation controller.
|
// The navigation controller.
|
||||||
controller = new NavigationController(webContents)
|
controller = new NavigationController(webContents)
|
||||||
|
|
Loading…
Reference in a new issue