diff --git a/atom.gyp b/atom.gyp index 09bb7cdb52d1..a86e09eea379 100644 --- a/atom.gyp +++ b/atom.gyp @@ -49,7 +49,6 @@ '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', diff --git a/atom/browser/api/atom_api_browser_ipc.cc b/atom/browser/api/atom_api_browser_ipc.cc index 71da2c7cccfd..b2fb31cead1a 100644 --- a/atom/browser/api/atom_api_browser_ipc.cc +++ b/atom/browser/api/atom_api_browser_ipc.cc @@ -2,47 +2,35 @@ // 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" +#include "atom/common/node_includes.h" + using content::RenderViewHost; -namespace atom { - -namespace api { - -// static -void BrowserIPC::Send(const v8::FunctionCallbackInfo& args) { - string16 channel; - int process_id, routing_id; - scoped_ptr arguments; - if (!FromV8Arguments(args, &channel, &process_id, &routing_id, &arguments)) - return node::ThrowTypeError("Bad argument"); - - 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(arguments.get())))); + return render_view_host->Send(new AtomViewMsg_Message(routing_id, channel, + arguments)); } -// static -void BrowserIPC::Initialize(v8::Handle target) { - NODE_SET_METHOD(target, "send", Send); +void Initialize(v8::Handle exports) { + mate::Dictionary dict(v8::Isolate::GetCurrent(), exports); + dict.SetMethod("send", &Send); } -} // namespace api +} // namespace -} // namespace atom - -NODE_MODULE(atom_browser_ipc, atom::api::BrowserIPC::Initialize) +NODE_MODULE(atom_browser_ipc, Initialize) diff --git a/atom/browser/api/atom_api_browser_ipc.h b/atom/browser/api/atom_api_browser_ipc.h deleted file mode 100644 index 93f0ba79d419..000000000000 --- a/atom/browser/api/atom_api_browser_ipc.h +++ /dev/null @@ -1,29 +0,0 @@ -// 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 target); - - private: - static void Send(const v8::FunctionCallbackInfo& args); - - DISALLOW_IMPLICIT_CONSTRUCTORS(BrowserIPC); -}; - -} // namespace api - -} // namespace atom - -#endif // ATOM_BROWSER_API_ATOM_API_BROWSER_IPC_H_