Enable getting a window according to its attached devtools.

This commit is contained in:
Cheng Zhao 2014-04-04 22:28:18 +08:00
parent 86ebd6e8e3
commit f5fc26d8fc
3 changed files with 25 additions and 0 deletions

View file

@ -503,6 +503,19 @@ void Window::IsCrashed(const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(self->window_->GetWebContents()->IsCrashed());
}
// static
void Window::GetDevTools(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
content::WebContents* web_contents = self->window_->GetDevToolsWebContents();
v8::Local<v8::Object> devtools = v8::Object::New();
devtools->Set(ToV8Value("processId"),
ToV8Value(web_contents->GetRenderProcessHost()->GetID()));
devtools->Set(ToV8Value("routingId"),
ToV8Value(web_contents->GetRoutingID()));
args.GetReturnValue().Set(devtools);
}
// static
void Window::LoadURL(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNWRAP_WINDOW_AND_CHECK;
@ -686,6 +699,8 @@ void Window::Initialize(v8::Handle<v8::Object> target) {
NODE_SET_PROTOTYPE_METHOD(t, "getProcessId", GetProcessID);
NODE_SET_PROTOTYPE_METHOD(t, "isCrashed", IsCrashed);
NODE_SET_PROTOTYPE_METHOD(t, "getDevTools", GetDevTools);
NODE_SET_PROTOTYPE_METHOD(t, "loadUrl", LoadURL);
NODE_SET_PROTOTYPE_METHOD(t, "getUrl", GetURL);
NODE_SET_PROTOTYPE_METHOD(t, "canGoBack", CanGoBack);