'atom/browser/api/atom_api_auto_updater.cc',
'atom/browser/api/atom_api_auto_updater.h',
'atom/browser/api/atom_api_browser_ipc.cc',
- 'atom/browser/api/atom_api_browser_ipc.h',
'atom/browser/api/atom_api_dialog.cc',
'atom/browser/api/atom_api_event.cc',
'atom/browser/api/atom_api_event.h',
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "atom/browser/api/atom_api_browser_ipc.h"
-
#include "atom/common/api/api_messages.h"
-#include "atom/common/node_includes.h"
-#include "atom/common/v8/native_type_conversions.h"
+#include "atom/common/native_mate_converters/string16_converter.h"
+#include "atom/common/native_mate_converters/value_converter.h"
#include "content/public/browser/render_view_host.h"
-using content::RenderViewHost;
-
-namespace atom {
-
-namespace api {
+#include "atom/common/node_includes.h"
-// static
-void BrowserIPC::Send(const v8::FunctionCallbackInfo<v8::Value>& args) {
- string16 channel;
- int process_id, routing_id;
- scoped_ptr<base::Value> arguments;
- if (!FromV8Arguments(args, &channel, &process_id, &routing_id, &arguments))
- return node::ThrowTypeError("Bad argument");
+using content::RenderViewHost;
- DCHECK(arguments && arguments->IsType(base::Value::TYPE_LIST));
+namespace {
+bool Send(const string16& channel, int process_id, int routing_id,
+ const base:ListValue& arguments) {
RenderViewHost* render_view_host(RenderViewHost::FromID(
process_id, routing_id));
- if (!render_view_host)
- return node::ThrowError("Invalid render view host");
+ if (!render_view_host) {
+ node::ThrowError("Invalid render view host");
+ return false;
+ }
- args.GetReturnValue().Set(render_view_host->Send(new AtomViewMsg_Message(
- routing_id,
- channel,
- *static_cast<base::ListValue*>(arguments.get()))));
+ return render_view_host->Send(new AtomViewMsg_Message(routing_id, channel,
+ arguments));
}
-// static
-void BrowserIPC::Initialize(v8::Handle<v8::Object> target) {
- NODE_SET_METHOD(target, "send", Send);
+void Initialize(v8::Handle<v8::Object> exports) {
+ mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
+ dict.SetMethod("send", &Send);
}
-} // namespace api
-
-} // namespace atom
+} // namespace
-NODE_MODULE(atom_browser_ipc, atom::api::BrowserIPC::Initialize)
+NODE_MODULE(atom_browser_ipc, Initialize)
+++ /dev/null
-// Copyright (c) 2013 GitHub, Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ATOM_BROWSER_API_ATOM_API_BROWSER_IPC_H_
-#define ATOM_BROWSER_API_ATOM_API_BROWSER_IPC_H_
-
-#include "base/basictypes.h"
-#include "v8/include/v8.h"
-
-namespace atom {
-
-namespace api {
-
-class BrowserIPC {
- public:
- static void Initialize(v8::Handle<v8::Object> target);
-
- private:
- static void Send(const v8::FunctionCallbackInfo<v8::Value>& args);
-
- DISALLOW_IMPLICIT_CONSTRUCTORS(BrowserIPC);
-};
-
-} // namespace api
-
-} // namespace atom
-
-#endif // ATOM_BROWSER_API_ATOM_API_BROWSER_IPC_H_