Implement event.sender for ipcRenderer

This commit is contained in:
Cheng Zhao 2015-11-10 16:59:08 +08:00
parent 90a7d4a906
commit d234f10177

View file

@ -31,6 +31,7 @@
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "ui/base/resource/resource_bundle.h"
#include "native_mate/dictionary.h"
namespace atom {
@ -143,8 +144,10 @@ void AtomRenderViewObserver::OnBrowserMessage(const base::string16& channel,
v8::Local<v8::Object> ipc;
if (GetIPCObject(isolate, context, &ipc)) {
auto args_vector = ListValueToVector(isolate, args);
// Insert a dummy Event object.
args_vector.insert(args_vector.begin(), v8::Object::New(isolate));
// Insert the Event object, event.sender is ipc.
mate::Dictionary event = mate::Dictionary::CreateEmpty(isolate);
event.Set("sender", ipc);
args_vector.insert(args_vector.begin(), event.GetHandle());
mate::EmitEvent(isolate, ipc, channel, args_vector);
}
}