feat: add ipcRenderer.invoke() (#18449)
This commit is contained in:
parent
b180fb376c
commit
c436997840
17 changed files with 389 additions and 20 deletions
|
@ -924,6 +924,14 @@ void WebContents::Message(bool internal,
|
|||
internal, channel, std::move(arguments));
|
||||
}
|
||||
|
||||
void WebContents::Invoke(const std::string& channel,
|
||||
base::Value arguments,
|
||||
InvokeCallback callback) {
|
||||
// webContents.emit('-ipc-invoke', new Event(), channel, arguments);
|
||||
EmitWithSender("-ipc-invoke", bindings_.dispatch_context(),
|
||||
std::move(callback), channel, std::move(arguments));
|
||||
}
|
||||
|
||||
void WebContents::MessageSync(bool internal,
|
||||
const std::string& channel,
|
||||
base::Value arguments,
|
||||
|
|
|
@ -492,6 +492,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void Message(bool internal,
|
||||
const std::string& channel,
|
||||
base::Value arguments) override;
|
||||
void Invoke(const std::string& channel,
|
||||
base::Value arguments,
|
||||
InvokeCallback callback) override;
|
||||
void MessageSync(bool internal,
|
||||
const std::string& channel,
|
||||
base::Value arguments,
|
||||
|
|
|
@ -58,7 +58,7 @@ void Event::PreventDefault(v8::Isolate* isolate) {
|
|||
.Check();
|
||||
}
|
||||
|
||||
bool Event::SendReply(const base::ListValue& result) {
|
||||
bool Event::SendReply(const base::Value& result) {
|
||||
if (!callback_ || sender_ == nullptr)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ class Event : public Wrappable<Event>, public content::WebContentsObserver {
|
|||
// event.PreventDefault().
|
||||
void PreventDefault(v8::Isolate* isolate);
|
||||
|
||||
// event.sendReply(array), used for replying synchronous message.
|
||||
bool SendReply(const base::ListValue& result);
|
||||
// event.sendReply(value), used for replying to synchronous messages and
|
||||
// `invoke` calls.
|
||||
bool SendReply(const base::Value& result);
|
||||
|
||||
protected:
|
||||
explicit Event(v8::Isolate* isolate);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue