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" |
11 #include "Frame.h" | 11 #include "Frame.h" |
12 #include "InspectorController.h" | 12 #include "InspectorController.h" |
13 #include "Node.h" | 13 #include "Node.h" |
14 #include "Page.h" | 14 #include "Page.h" |
15 #include "PlatformString.h" | 15 #include "PlatformString.h" |
16 #include "SecurityOrigin.h" | 16 #include "SecurityOrigin.h" |
17 #include <wtf/OwnPtr.h> | 17 #include <wtf/OwnPtr.h> |
18 #include <wtf/Vector.h> | 18 #include <wtf/Vector.h> |
19 #undef LOG | 19 #undef LOG |
20 | 20 |
21 #include "V8Binding.h" | 21 #include "V8Binding.h" |
| 22 #include "v8_custom.h" |
22 #include "v8_proxy.h" | 23 #include "v8_proxy.h" |
23 #include "v8_utility.h" | 24 #include "v8_utility.h" |
24 #include "base/string_util.h" | 25 #include "base/string_util.h" |
25 #include "base/values.h" | 26 #include "base/values.h" |
26 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" |
27 #include "webkit/glue/devtools/debugger_agent.h" | 28 #include "webkit/glue/devtools/debugger_agent.h" |
28 #include "webkit/glue/devtools/devtools_rpc_js.h" | 29 #include "webkit/glue/devtools/devtools_rpc_js.h" |
29 #include "webkit/glue/devtools/dom_agent.h" | 30 #include "webkit/glue/devtools/dom_agent.h" |
30 #include "webkit/glue/devtools/net_agent.h" | 31 #include "webkit/glue/devtools/net_agent.h" |
31 #include "webkit/glue/devtools/tools_agent.h" | 32 #include "webkit/glue/devtools/tools_agent.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 v8::Handle<v8::Value>(), | 106 v8::Handle<v8::Value>(), |
106 default_signature), | 107 default_signature), |
107 static_cast<v8::PropertyAttribute>(v8::DontDelete)); | 108 static_cast<v8::PropertyAttribute>(v8::DontDelete)); |
108 proto->Set( | 109 proto->Set( |
109 v8::String::New("loaded"), | 110 v8::String::New("loaded"), |
110 v8::FunctionTemplate::New( | 111 v8::FunctionTemplate::New( |
111 WebDevToolsClientImpl::JsLoaded, | 112 WebDevToolsClientImpl::JsLoaded, |
112 v8::Handle<v8::Value>(), | 113 v8::Handle<v8::Value>(), |
113 default_signature), | 114 default_signature), |
114 static_cast<v8::PropertyAttribute>(v8::DontDelete)); | 115 static_cast<v8::PropertyAttribute>(v8::DontDelete)); |
| 116 proto->Set( |
| 117 v8::String::New("search"), |
| 118 v8::FunctionTemplate::New( |
| 119 WebDevToolsClientImpl::JsSearch, |
| 120 v8::Handle<v8::Value>(), |
| 121 default_signature), |
| 122 static_cast<v8::PropertyAttribute>(v8::DontDelete)); |
115 host_template_->SetClassName(v8::String::New("DevToolsHost")); | 123 host_template_->SetClassName(v8::String::New("DevToolsHost")); |
116 } | 124 } |
117 | 125 |
118 // static | 126 // static |
119 WebDevToolsClient* WebDevToolsClient::Create( | 127 WebDevToolsClient* WebDevToolsClient::Create( |
120 WebView* view, | 128 WebView* view, |
121 WebDevToolsClientDelegate* delegate) { | 129 WebDevToolsClientDelegate* delegate) { |
122 return new WebDevToolsClientImpl(static_cast<WebViewImpl*>(view), delegate); | 130 return new WebDevToolsClientImpl(static_cast<WebViewImpl*>(view), delegate); |
123 } | 131 } |
124 | 132 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 String mime_type = WebCore::toWebCoreStringWithNullCheck(args[0]); | 202 String mime_type = WebCore::toWebCoreStringWithNullCheck(args[0]); |
195 if (mime_type.isEmpty() || exception_catcher.HasCaught()) { | 203 if (mime_type.isEmpty() || exception_catcher.HasCaught()) { |
196 return v8::Undefined(); | 204 return v8::Undefined(); |
197 } | 205 } |
198 String source_string = WebCore::toWebCoreStringWithNullCheck(args[1]); | 206 String source_string = WebCore::toWebCoreStringWithNullCheck(args[1]); |
199 if (source_string.isEmpty() || exception_catcher.HasCaught()) { | 207 if (source_string.isEmpty() || exception_catcher.HasCaught()) { |
200 return v8::Undefined(); | 208 return v8::Undefined(); |
201 } | 209 } |
202 Node* node = V8Proxy::DOMWrapperToNode<Node>(args[2]); | 210 Node* node = V8Proxy::DOMWrapperToNode<Node>(args[2]); |
203 if (!node || !node->attached()) { | 211 if (!node || !node->attached()) { |
| 212 return v8::Undefined(); |
204 } | 213 } |
205 | 214 |
206 Page* page = V8Proxy::retrieveActiveFrame()->page(); | 215 Page* page = V8Proxy::retrieveActiveFrame()->page(); |
207 InspectorController* inspectorController = page->inspectorController(); | 216 InspectorController* inspectorController = page->inspectorController(); |
208 return WebCore::v8Boolean(inspectorController-> | 217 return WebCore::v8Boolean(inspectorController-> |
209 addSourceToFrame(mime_type, source_string, node)); | 218 addSourceToFrame(mime_type, source_string, node)); |
210 } | 219 } |
211 | 220 |
212 // static | 221 // static |
213 v8::Handle<v8::Value> WebDevToolsClientImpl::JsLoaded( | 222 v8::Handle<v8::Value> WebDevToolsClientImpl::JsLoaded( |
214 const v8::Arguments& args) { | 223 const v8::Arguments& args) { |
215 Page* page = V8Proxy::retrieveActiveFrame()->page(); | 224 Page* page = V8Proxy::retrieveActiveFrame()->page(); |
216 WebDevToolsClientImpl* client = page_to_client_.get(page); | 225 WebDevToolsClientImpl* client = page_to_client_.get(page); |
217 client->loaded_ = true; | 226 client->loaded_ = true; |
218 | 227 |
219 // Grant the devtools page the ability to have source view iframes. | 228 // Grant the devtools page the ability to have source view iframes. |
220 SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin(); | 229 SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin(); |
221 origin->grantUniversalAccess(); | 230 origin->grantUniversalAccess(); |
222 | 231 |
223 for (Vector<std::string>::iterator it = | 232 for (Vector<std::string>::iterator it = |
224 client->pending_incoming_messages_.begin(); | 233 client->pending_incoming_messages_.begin(); |
225 it != client->pending_incoming_messages_.end(); | 234 it != client->pending_incoming_messages_.end(); |
226 ++it) { | 235 ++it) { |
227 client->DispatchMessageFromAgent(*it); | 236 client->DispatchMessageFromAgent(*it); |
228 } | 237 } |
229 client->pending_incoming_messages_.clear(); | 238 client->pending_incoming_messages_.clear(); |
230 return v8::Undefined(); | 239 return v8::Undefined(); |
231 } | 240 } |
| 241 |
| 242 // static |
| 243 v8::Handle<v8::Value> WebDevToolsClientImpl::JsSearch( |
| 244 const v8::Arguments& args) { |
| 245 return WebCore::V8Custom::v8InspectorControllerSearchCallback(args); |
| 246 } |
OLD | NEW |