Add getRoutingID and getProcessID for window API.
This commit is contained in:
parent
16244e42e0
commit
d28f51fb9c
5 changed files with 29 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include "common/v8_value_converter_impl.h"
|
#include "common/v8_value_converter_impl.h"
|
||||||
#include "content/public/browser/navigation_entry.h"
|
#include "content/public/browser/navigation_entry.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
|
#include "content/public/browser/render_process_host.h"
|
||||||
#include "ui/gfx/point.h"
|
#include "ui/gfx/point.h"
|
||||||
#include "ui/gfx/rect.h"
|
#include "ui/gfx/rect.h"
|
||||||
#include "ui/gfx/size.h"
|
#include "ui/gfx/size.h"
|
||||||
|
@ -396,6 +397,21 @@ v8::Handle<v8::Value> Window::Stop(const v8::Arguments &args) {
|
||||||
return v8::Undefined();
|
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
|
// static
|
||||||
v8::Handle<v8::Value> Window::LoadURL(const v8::Arguments &args) {
|
v8::Handle<v8::Value> Window::LoadURL(const v8::Arguments &args) {
|
||||||
Window* self = ObjectWrap::Unwrap<Window>(args.This());
|
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, "isLoading", IsLoading);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "isWaitingForResponse", IsWaitingForResponse);
|
NODE_SET_PROTOTYPE_METHOD(t, "isWaitingForResponse", IsWaitingForResponse);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "stop", Stop);
|
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, "loadURL", LoadURL);
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "getURL", GetURL);
|
NODE_SET_PROTOTYPE_METHOD(t, "getURL", GetURL);
|
||||||
|
|
|
@ -76,6 +76,8 @@ class Window : public EventEmitter,
|
||||||
static v8::Handle<v8::Value> IsLoading(const v8::Arguments &args);
|
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> IsWaitingForResponse(const v8::Arguments &args);
|
||||||
static v8::Handle<v8::Value> Stop(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.
|
// APIs for NavigationController.
|
||||||
static v8::Handle<v8::Value> LoadURL(const v8::Arguments &args);
|
static v8::Handle<v8::Value> LoadURL(const v8::Arguments &args);
|
||||||
|
|
|
@ -7,6 +7,9 @@ class Ipc extends EventEmitter
|
||||||
@emit('message', args...)
|
@emit('message', args...)
|
||||||
|
|
||||||
send: (process_id, routing_id, 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
|
module.exports = new Ipc
|
||||||
|
|
|
@ -4,8 +4,8 @@ var Window = require('window');
|
||||||
|
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
|
||||||
|
// Echo every message back.
|
||||||
ipc.on('message', function(process_id, routing_id) {
|
ipc.on('message', function(process_id, routing_id) {
|
||||||
console.log('message from', process_id, routing_id);
|
|
||||||
ipc.send.apply(ipc, arguments);
|
ipc.send.apply(ipc, arguments);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ class Ipc extends EventEmitter
|
||||||
@emit('message', args...)
|
@emit('message', args...)
|
||||||
|
|
||||||
send: (args...) ->
|
send: (args...) ->
|
||||||
send('ATOM_INTERNAL_MESSAGE', args...)
|
@sendChannel('ATOM_INTERNAL_MESSAGE', args...)
|
||||||
|
|
||||||
|
sendChannel: (args...) ->
|
||||||
|
send(args...)
|
||||||
|
|
||||||
module.exports = new Ipc
|
module.exports = new Ipc
|
||||||
|
|
Loading…
Add table
Reference in a new issue