]> khamidou — GitHub mirrors - electron.git/commitdiff
Implement event.sender for ipcRenderer
authorCheng Zhao <zcbenz@gmail.com>
Tue, 10 Nov 2015 08:59:08 +0000 (16:59 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 10 Nov 2015 08:59:08 +0000 (16:59 +0800)
atom/renderer/atom_render_view_observer.cc

index ecd9401420f8a3bcce189fac4285e309a17ac04a..931913dd75d05484736cf5c32adf354bb3dc2688 100644 (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);
   }
 }