| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "Document.h" | 9 #include "Document.h" |
| 10 #include "DOMWindow.h" | 10 #include "DOMWindow.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return; | 92 return; |
| 93 } | 93 } |
| 94 v8::HandleScope scope; | 94 v8::HandleScope scope; |
| 95 v8::Local<v8::FunctionTemplate> local_template = | 95 v8::Local<v8::FunctionTemplate> local_template = |
| 96 v8::FunctionTemplate::New(V8Proxy::CheckNewLegal); | 96 v8::FunctionTemplate::New(V8Proxy::CheckNewLegal); |
| 97 host_template_ = v8::Persistent<v8::FunctionTemplate>::New(local_template); | 97 host_template_ = v8::Persistent<v8::FunctionTemplate>::New(local_template); |
| 98 | 98 |
| 99 v8::Local<v8::Signature> default_signature = | 99 v8::Local<v8::Signature> default_signature = |
| 100 v8::Signature::New(host_template_); | 100 v8::Signature::New(host_template_); |
| 101 v8::Local<v8::ObjectTemplate> proto = host_template_->PrototypeTemplate(); | 101 v8::Local<v8::ObjectTemplate> proto = host_template_->PrototypeTemplate(); |
| 102 proto->Set( | 102 InitProtoFunction(proto, |
| 103 v8::String::New("addSourceToFrame"), | 103 "addSourceToFrame", |
| 104 v8::FunctionTemplate::New( | 104 WebDevToolsClientImpl::JsAddSourceToFrame, |
| 105 WebDevToolsClientImpl::JsAddSourceToFrame, | 105 default_signature); |
| 106 v8::Handle<v8::Value>(), | 106 InitProtoFunction(proto, |
| 107 default_signature), | 107 "loaded", |
| 108 static_cast<v8::PropertyAttribute>(v8::DontDelete)); | 108 WebDevToolsClientImpl::JsLoaded, |
| 109 proto->Set( | 109 default_signature); |
| 110 v8::String::New("loaded"), | 110 InitProtoFunction(proto, |
| 111 v8::FunctionTemplate::New( | 111 "search", |
| 112 WebDevToolsClientImpl::JsLoaded, | 112 WebCore::V8Custom::v8InspectorControllerSearchCallback, |
| 113 v8::Handle<v8::Value>(), | 113 default_signature); |
| 114 default_signature), | 114 InitProtoFunction(proto, |
| 115 static_cast<v8::PropertyAttribute>(v8::DontDelete)); | 115 "activateWindow", |
| 116 proto->Set( | 116 WebDevToolsClientImpl::JsActivateWindow, |
| 117 v8::String::New("search"), | 117 default_signature); |
| 118 v8::FunctionTemplate::New( | |
| 119 WebDevToolsClientImpl::JsSearch, | |
| 120 v8::Handle<v8::Value>(), | |
| 121 default_signature), | |
| 122 static_cast<v8::PropertyAttribute>(v8::DontDelete)); | |
| 123 host_template_->SetClassName(v8::String::New("DevToolsHost")); | 118 host_template_->SetClassName(v8::String::New("DevToolsHost")); |
| 124 } | 119 } |
| 125 | 120 |
| 126 // static | 121 // static |
| 122 void WebDevToolsClientImpl::InitProtoFunction( |
| 123 v8::Handle<v8::ObjectTemplate> proto, |
| 124 const char* name, |
| 125 v8::InvocationCallback callback, |
| 126 v8::Handle<v8::Signature> signature) { |
| 127 proto->Set( |
| 128 v8::String::New(name), |
| 129 v8::FunctionTemplate::New( |
| 130 callback, |
| 131 v8::Handle<v8::Value>(), |
| 132 signature), |
| 133 static_cast<v8::PropertyAttribute>(v8::DontDelete)); |
| 134 } |
| 135 |
| 136 // static |
| 127 WebDevToolsClient* WebDevToolsClient::Create( | 137 WebDevToolsClient* WebDevToolsClient::Create( |
| 128 WebView* view, | 138 WebView* view, |
| 129 WebDevToolsClientDelegate* delegate) { | 139 WebDevToolsClientDelegate* delegate) { |
| 130 return new WebDevToolsClientImpl(static_cast<WebViewImpl*>(view), delegate); | 140 return new WebDevToolsClientImpl(static_cast<WebViewImpl*>(view), delegate); |
| 131 } | 141 } |
| 132 | 142 |
| 133 WebDevToolsClientImpl::WebDevToolsClientImpl( | 143 WebDevToolsClientImpl::WebDevToolsClientImpl( |
| 134 WebViewImpl* web_view_impl, | 144 WebViewImpl* web_view_impl, |
| 135 WebDevToolsClientDelegate* delegate) | 145 WebDevToolsClientDelegate* delegate) |
| 136 : web_view_impl_(web_view_impl), | 146 : web_view_impl_(web_view_impl), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 client->pending_incoming_messages_.begin(); | 243 client->pending_incoming_messages_.begin(); |
| 234 it != client->pending_incoming_messages_.end(); | 244 it != client->pending_incoming_messages_.end(); |
| 235 ++it) { | 245 ++it) { |
| 236 client->DispatchMessageFromAgent(*it); | 246 client->DispatchMessageFromAgent(*it); |
| 237 } | 247 } |
| 238 client->pending_incoming_messages_.clear(); | 248 client->pending_incoming_messages_.clear(); |
| 239 return v8::Undefined(); | 249 return v8::Undefined(); |
| 240 } | 250 } |
| 241 | 251 |
| 242 // static | 252 // static |
| 243 v8::Handle<v8::Value> WebDevToolsClientImpl::JsSearch( | 253 v8::Handle<v8::Value> WebDevToolsClientImpl::JsActivateWindow( |
| 244 const v8::Arguments& args) { | 254 const v8::Arguments& args) { |
| 245 return WebCore::V8Custom::v8InspectorControllerSearchCallback(args); | 255 Page* page = V8Proxy::retrieveActiveFrame()->page(); |
| 256 WebDevToolsClientImpl* client = page_to_client_.get(page); |
| 257 client->delegate_->ActivateWindow(); |
| 258 return v8::Undefined(); |
| 246 } | 259 } |
| OLD | NEW |