From: Cheng Zhao Date: Tue, 23 Apr 2013 09:21:34 +0000 (+0800) Subject: Add getRoutingID and getProcessID for window API. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d28f51fb9c7225b0a10ba9426c07fee45f29d600;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Add getRoutingID and getProcessID for window API. --- diff --git a/browser/api/atom_api_window.cc b/browser/api/atom_api_window.cc index bb94f61..848c2cd 100644 --- a/browser/api/atom_api_window.cc +++ b/browser/api/atom_api_window.cc @@ -9,6 +9,7 @@ #include "common/v8_value_converter_impl.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/web_contents.h" +#include "content/public/browser/render_process_host.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" @@ -397,6 +398,21 @@ v8::Handle Window::Stop(const v8::Arguments &args) { } // static +v8::Handle Window::GetRoutingID(const v8::Arguments &args) { + Window* self = ObjectWrap::Unwrap(args.This()); + + return v8::Integer::New(self->window_->GetWebContents()->GetRoutingID()); +} + +// static +v8::Handle Window::GetProcessID(const v8::Arguments &args) { + Window* self = ObjectWrap::Unwrap(args.This()); + + return v8::Integer::New( + self->window_->GetWebContents()->GetRenderProcessHost()->GetID()); +} + +// static v8::Handle Window::LoadURL(const v8::Arguments &args) { Window* self = ObjectWrap::Unwrap(args.This()); @@ -576,6 +592,8 @@ void Window::Initialize(v8::Handle target) { NODE_SET_PROTOTYPE_METHOD(t, "isLoading", IsLoading); NODE_SET_PROTOTYPE_METHOD(t, "isWaitingForResponse", IsWaitingForResponse); NODE_SET_PROTOTYPE_METHOD(t, "stop", Stop); + NODE_SET_PROTOTYPE_METHOD(t, "getRoutingID", GetRoutingID); + NODE_SET_PROTOTYPE_METHOD(t, "getProcessID", GetProcessID); NODE_SET_PROTOTYPE_METHOD(t, "loadURL", LoadURL); NODE_SET_PROTOTYPE_METHOD(t, "getURL", GetURL); diff --git a/browser/api/atom_api_window.h b/browser/api/atom_api_window.h index 4fc32a9..25f16b3 100644 --- a/browser/api/atom_api_window.h +++ b/browser/api/atom_api_window.h @@ -76,6 +76,8 @@ class Window : public EventEmitter, static v8::Handle IsLoading(const v8::Arguments &args); static v8::Handle IsWaitingForResponse(const v8::Arguments &args); static v8::Handle Stop(const v8::Arguments &args); + static v8::Handle GetRoutingID(const v8::Arguments &args); + static v8::Handle GetProcessID(const v8::Arguments &args); // APIs for NavigationController. static v8::Handle LoadURL(const v8::Arguments &args); diff --git a/browser/api/lib/ipc.coffee b/browser/api/lib/ipc.coffee index 5f3b3a4..108bc30 100644 --- a/browser/api/lib/ipc.coffee +++ b/browser/api/lib/ipc.coffee @@ -7,6 +7,9 @@ class Ipc extends EventEmitter @emit('message', args...) send: (process_id, routing_id, args...) -> - send(process_id, routing_id, 'ATOM_INTERNAL_MESSAGE', args...) + @sendChannel(process_id, routing_id, 'ATOM_INTERNAL_MESSAGE', args...) + + sendChannel: (args...) -> + send(args...) module.exports = new Ipc diff --git a/browser/default_app/main.js b/browser/default_app/main.js index 12873bf..f5e43ab 100644 --- a/browser/default_app/main.js +++ b/browser/default_app/main.js @@ -4,8 +4,8 @@ var Window = require('window'); var mainWindow = null; +// Echo every message back. ipc.on('message', function(process_id, routing_id) { - console.log('message from', process_id, routing_id); ipc.send.apply(ipc, arguments); }); diff --git a/renderer/api/lib/ipc.coffee b/renderer/api/lib/ipc.coffee index c36dd03..884cab7 100644 --- a/renderer/api/lib/ipc.coffee +++ b/renderer/api/lib/ipc.coffee @@ -7,6 +7,9 @@ class Ipc extends EventEmitter @emit('message', args...) send: (args...) -> - send('ATOM_INTERNAL_MESSAGE', args...) + @sendChannel('ATOM_INTERNAL_MESSAGE', args...) + + sendChannel: (args...) -> + send(args...) module.exports = new Ipc