Add getRoutingID and getProcessID for window API.

This commit is contained in:
Cheng Zhao 2013-04-23 17:21:34 +08:00
parent 16244e42e0
commit d28f51fb9c
5 changed files with 29 additions and 3 deletions

View file

@ -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"
@ -396,6 +397,21 @@ v8::Handle<v8::Value> Window::Stop(const v8::Arguments &args) {
return v8::Undefined();
}
// static
v8::Handle<v8::Value> Window::GetRoutingID(const v8::Arguments &args) {
Window* self = ObjectWrap::Unwrap<Window>(args.This());
return v8::Integer::New(self->window_->GetWebContents()->GetRoutingID());
}
// static
v8::Handle<v8::Value> Window::GetProcessID(const v8::Arguments &args) {
Window* self = ObjectWrap::Unwrap<Window>(args.This());
return v8::Integer::New(
self->window_->GetWebContents()->GetRenderProcessHost()->GetID());
}
// static
v8::Handle<v8::Value> Window::LoadURL(const v8::Arguments &args) {
Window* self = ObjectWrap::Unwrap<Window>(args.This());
@ -576,6 +592,8 @@ void Window::Initialize(v8::Handle<v8::Object> 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);

View file

@ -76,6 +76,8 @@ class Window : public EventEmitter,
static v8::Handle<v8::Value> IsLoading(const v8::Arguments &args);
static v8::Handle<v8::Value> IsWaitingForResponse(const v8::Arguments &args);
static v8::Handle<v8::Value> Stop(const v8::Arguments &args);
static v8::Handle<v8::Value> GetRoutingID(const v8::Arguments &args);
static v8::Handle<v8::Value> GetProcessID(const v8::Arguments &args);
// APIs for NavigationController.
static v8::Handle<v8::Value> LoadURL(const v8::Arguments &args);

View file

@ -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

View file

@ -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);
});

View file

@ -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