Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: webkit/glue/webdevtoolsfrontend_impl.cc

Issue 330029: DevTools: Remove base/ dependencies from glue/devtools (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webdevtoolsfrontend_impl.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "InspectorBackend.h" 12 #include "InspectorBackend.h"
13 #include "InspectorController.h" 13 #include "InspectorController.h"
14 #include "Node.h" 14 #include "Node.h"
15 #include "Page.h" 15 #include "Page.h"
16 #include "PlatformString.h" 16 #include "PlatformString.h"
17 #include "SecurityOrigin.h" 17 #include "SecurityOrigin.h"
18 #include "Settings.h" 18 #include "Settings.h"
19 #include "V8Binding.h" 19 #include "V8Binding.h"
20 #include "V8CustomBinding.h" 20 #include "V8CustomBinding.h"
21 #include "V8Proxy.h" 21 #include "V8Proxy.h"
22 #include "V8Utilities.h" 22 #include "V8Utilities.h"
23 #include <wtf/OwnPtr.h> 23 #include <wtf/OwnPtr.h>
24 #include <wtf/Vector.h> 24 #include <wtf/Vector.h>
25 #undef LOG 25 #undef LOG
26 26
27 #include "base/string_util.h" 27 #include "webkit/api/public/WebDevtoolsFrontendClient.h"
28 #include "webkit/api/public/WebFrame.h" 28 #include "webkit/api/public/WebFrame.h"
29 #include "webkit/api/public/WebScriptSource.h" 29 #include "webkit/api/public/WebScriptSource.h"
30 #include "webkit/glue/devtools/bound_object.h" 30 #include "webkit/glue/devtools/bound_object.h"
31 #include "webkit/glue/devtools/debugger_agent.h" 31 #include "webkit/glue/devtools/debugger_agent.h"
32 #include "webkit/glue/devtools/devtools_rpc_js.h" 32 #include "webkit/glue/devtools/devtools_rpc_js.h"
33 #include "webkit/glue/devtools/tools_agent.h" 33 #include "webkit/glue/devtools/tools_agent.h"
34 #include "webkit/glue/glue_util.h" 34 #include "webkit/glue/glue_util.h"
35 #include "webkit/glue/webdevtoolsclient_delegate.h" 35 #include "webkit/glue/webdevtoolsfrontend_impl.h"
36 #include "webkit/glue/webdevtoolsclient_impl.h"
37 #include "webkit/glue/webview_impl.h" 36 #include "webkit/glue/webview_impl.h"
38 37
39 using namespace WebCore; 38 using namespace WebCore;
39 using WebKit::WebDevToolsFrontend;
40 using WebKit::WebDevToolsFrontendClient;
40 using WebKit::WebFrame; 41 using WebKit::WebFrame;
41 using WebKit::WebScriptSource; 42 using WebKit::WebScriptSource;
42 using WebKit::WebString; 43 using WebKit::WebString;
43 using WebKit::WebView; 44 using WebKit::WebView;
44 45
45 static v8::Local<v8::String> ToV8String(const String& s) { 46 static v8::Local<v8::String> ToV8String(const String& s) {
46 if (s.isNull()) 47 if (s.isNull())
47 return v8::Local<v8::String>(); 48 return v8::Local<v8::String>();
48 49
49 return v8::String::New(reinterpret_cast<const uint16_t*>(s.characters()), 50 return v8::String::New(reinterpret_cast<const uint16_t*>(s.characters()),
(...skipping 11 matching lines...) Expand all
61 String mime_type; 62 String mime_type;
62 RefPtr<Node> frame; 63 RefPtr<Node> frame;
63 }; 64 };
64 65
65 ToolsAgentNativeDelegateImpl(WebFrameImpl* frame) : frame_(frame) {} 66 ToolsAgentNativeDelegateImpl(WebFrameImpl* frame) : frame_(frame) {}
66 virtual ~ToolsAgentNativeDelegateImpl() {} 67 virtual ~ToolsAgentNativeDelegateImpl() {}
67 68
68 // ToolsAgentNativeDelegate implementation. 69 // ToolsAgentNativeDelegate implementation.
69 virtual void DidGetResourceContent(int request_id, const String& content) { 70 virtual void DidGetResourceContent(int request_id, const String& content) {
70 if (!resource_content_requests_.contains(request_id)) { 71 if (!resource_content_requests_.contains(request_id)) {
71 NOTREACHED(); 72 ASSERT_NOT_REACHED();
72 return; 73 return;
73 } 74 }
74 ResourceContentRequestData request = 75 ResourceContentRequestData request =
75 resource_content_requests_.take(request_id); 76 resource_content_requests_.take(request_id);
76 77
77 InspectorController* ic = frame_->frame()->page()->inspectorController(); 78 InspectorController* ic = frame_->frame()->page()->inspectorController();
78 if (request.frame && request.frame->attached()) { 79 if (request.frame && request.frame->attached()) {
79 ic->inspectorBackend()->addSourceToFrame(request.mime_type, 80 ic->inspectorBackend()->addSourceToFrame(request.mime_type,
80 content, 81 content,
81 request.frame.get()); 82 request.frame.get());
82 } 83 }
83 } 84 }
84 85
85 bool WaitingForResponse(int resource_id, Node* frame) { 86 bool WaitingForResponse(int resource_id, Node* frame) {
86 if (resource_content_requests_.contains(resource_id)) { 87 if (resource_content_requests_.contains(resource_id)) {
87 DCHECK(resource_content_requests_.get(resource_id).frame.get() == frame) 88 ASSERT(resource_content_requests_.get(resource_id).frame.get() == frame);
88 << "Only one frame is expected to display given resource";
89 return true; 89 return true;
90 } 90 }
91 return false; 91 return false;
92 } 92 }
93 93
94 void RequestSent(int resource_id, String mime_type, Node* frame) { 94 void RequestSent(int resource_id, String mime_type, Node* frame) {
95 ResourceContentRequestData data; 95 ResourceContentRequestData data;
96 data.mime_type = mime_type; 96 data.mime_type = mime_type;
97 data.frame = frame; 97 data.frame = frame;
98 DCHECK(!resource_content_requests_.contains(resource_id)); 98 ASSERT(!resource_content_requests_.contains(resource_id));
99 resource_content_requests_.set(resource_id, data); 99 resource_content_requests_.set(resource_id, data);
100 } 100 }
101 101
102 private: 102 private:
103 WebFrameImpl* frame_; 103 WebFrameImpl* frame_;
104 HashMap<int, ResourceContentRequestData> resource_content_requests_; 104 HashMap<int, ResourceContentRequestData> resource_content_requests_;
105 DISALLOW_COPY_AND_ASSIGN(ToolsAgentNativeDelegateImpl); 105 DISALLOW_COPY_AND_ASSIGN(ToolsAgentNativeDelegateImpl);
106 }; 106 };
107 107
108 // static 108 // static
109 WebDevToolsClient* WebDevToolsClient::Create( 109 WebDevToolsFrontend* WebDevToolsFrontend::create(
110 WebView* view, 110 WebView* view,
111 WebDevToolsClientDelegate* delegate, 111 WebDevToolsFrontendClient* client,
112 const WebString& application_locale) { 112 const WebString& application_locale) {
113 return new WebDevToolsClientImpl( 113 return new WebDevToolsFrontendImpl(
114 static_cast<WebViewImpl*>(view), 114 static_cast<WebViewImpl*>(view),
115 delegate, 115 client,
116 webkit_glue::WebStringToString(application_locale)); 116 webkit_glue::WebStringToString(application_locale));
117 } 117 }
118 118
119 WebDevToolsClientImpl::WebDevToolsClientImpl( 119 WebDevToolsFrontendImpl::WebDevToolsFrontendImpl(
120 WebViewImpl* web_view_impl, 120 WebViewImpl* web_view_impl,
121 WebDevToolsClientDelegate* delegate, 121 WebDevToolsFrontendClient* client,
122 const String& application_locale) 122 const String& application_locale)
123 : web_view_impl_(web_view_impl), 123 : web_view_impl_(web_view_impl),
124 delegate_(delegate), 124 client_(client),
125 application_locale_(application_locale), 125 application_locale_(application_locale),
126 loaded_(false) { 126 loaded_(false) {
127 WebFrameImpl* frame = web_view_impl_->main_frame(); 127 WebFrameImpl* frame = web_view_impl_->main_frame();
128 v8::HandleScope scope; 128 v8::HandleScope scope;
129 v8::Handle<v8::Context> frame_context = V8Proxy::context(frame->frame()); 129 v8::Handle<v8::Context> frame_context = V8Proxy::context(frame->frame());
130 130
131 debugger_agent_obj_.set(new JsDebuggerAgentBoundObj( 131 debugger_agent_obj_.set(new JsDebuggerAgentBoundObj(
132 this, frame_context, "RemoteDebuggerAgent")); 132 this, frame_context, "RemoteDebuggerAgent"));
133 tools_agent_obj_.set( 133 tools_agent_obj_.set(
134 new JsToolsAgentBoundObj(this, frame_context, "RemoteToolsAgent")); 134 new JsToolsAgentBoundObj(this, frame_context, "RemoteToolsAgent"));
135 135
136 // Debugger commands should be sent using special method. 136 // Debugger commands should be sent using special method.
137 debugger_command_executor_obj_.set( 137 debugger_command_executor_obj_.set(
138 new BoundObject(frame_context, this, "RemoteDebuggerCommandExecutor")); 138 new BoundObject(frame_context, this, "RemoteDebuggerCommandExecutor"));
139 debugger_command_executor_obj_->AddProtoFunction( 139 debugger_command_executor_obj_->AddProtoFunction(
140 "DebuggerCommand", 140 "DebuggerCommand",
141 WebDevToolsClientImpl::JsDebuggerCommand); 141 WebDevToolsFrontendImpl::JsDebuggerCommand);
142 debugger_command_executor_obj_->Build(); 142 debugger_command_executor_obj_->Build();
143 143
144 dev_tools_host_.set(new BoundObject(frame_context, this, "DevToolsHost")); 144 dev_tools_host_.set(new BoundObject(frame_context, this, "DevToolsHost"));
145 dev_tools_host_->AddProtoFunction( 145 dev_tools_host_->AddProtoFunction(
146 "reset", 146 "reset",
147 WebDevToolsClientImpl::JsReset); 147 WebDevToolsFrontendImpl::JsReset);
148 dev_tools_host_->AddProtoFunction( 148 dev_tools_host_->AddProtoFunction(
149 "addSourceToFrame", 149 "addSourceToFrame",
150 WebDevToolsClientImpl::JsAddSourceToFrame); 150 WebDevToolsFrontendImpl::JsAddSourceToFrame);
151 dev_tools_host_->AddProtoFunction( 151 dev_tools_host_->AddProtoFunction(
152 "addResourceSourceToFrame", 152 "addResourceSourceToFrame",
153 WebDevToolsClientImpl::JsAddResourceSourceToFrame); 153 WebDevToolsFrontendImpl::JsAddResourceSourceToFrame);
154 dev_tools_host_->AddProtoFunction( 154 dev_tools_host_->AddProtoFunction(
155 "loaded", 155 "loaded",
156 WebDevToolsClientImpl::JsLoaded); 156 WebDevToolsFrontendImpl::JsLoaded);
157 dev_tools_host_->AddProtoFunction( 157 dev_tools_host_->AddProtoFunction(
158 "search", 158 "search",
159 WebCore::V8Custom::v8InspectorBackendSearchCallback); 159 WebCore::V8Custom::v8InspectorBackendSearchCallback);
160 dev_tools_host_->AddProtoFunction( 160 dev_tools_host_->AddProtoFunction(
161 "getPlatform", 161 "getPlatform",
162 WebDevToolsClientImpl::JsGetPlatform); 162 WebDevToolsFrontendImpl::JsGetPlatform);
163 dev_tools_host_->AddProtoFunction( 163 dev_tools_host_->AddProtoFunction(
164 "activateWindow", 164 "activateWindow",
165 WebDevToolsClientImpl::JsActivateWindow); 165 WebDevToolsFrontendImpl::JsActivateWindow);
166 dev_tools_host_->AddProtoFunction( 166 dev_tools_host_->AddProtoFunction(
167 "closeWindow", 167 "closeWindow",
168 WebDevToolsClientImpl::JsCloseWindow); 168 WebDevToolsFrontendImpl::JsCloseWindow);
169 dev_tools_host_->AddProtoFunction( 169 dev_tools_host_->AddProtoFunction(
170 "dockWindow", 170 "dockWindow",
171 WebDevToolsClientImpl::JsDockWindow); 171 WebDevToolsFrontendImpl::JsDockWindow);
172 dev_tools_host_->AddProtoFunction( 172 dev_tools_host_->AddProtoFunction(
173 "undockWindow", 173 "undockWindow",
174 WebDevToolsClientImpl::JsUndockWindow); 174 WebDevToolsFrontendImpl::JsUndockWindow);
175 dev_tools_host_->AddProtoFunction( 175 dev_tools_host_->AddProtoFunction(
176 "toggleInspectElementMode", 176 "toggleInspectElementMode",
177 WebDevToolsClientImpl::JsToggleInspectElementMode); 177 WebDevToolsFrontendImpl::JsToggleInspectElementMode);
178 dev_tools_host_->AddProtoFunction( 178 dev_tools_host_->AddProtoFunction(
179 "getApplicationLocale", 179 "getApplicationLocale",
180 WebDevToolsClientImpl::JsGetApplicationLocale); 180 WebDevToolsFrontendImpl::JsGetApplicationLocale);
181 dev_tools_host_->AddProtoFunction( 181 dev_tools_host_->AddProtoFunction(
182 "hiddenPanels", 182 "hiddenPanels",
183 WebDevToolsClientImpl::JsHiddenPanels); 183 WebDevToolsFrontendImpl::JsHiddenPanels);
184 dev_tools_host_->Build(); 184 dev_tools_host_->Build();
185 } 185 }
186 186
187 WebDevToolsClientImpl::~WebDevToolsClientImpl() { 187 WebDevToolsFrontendImpl::~WebDevToolsFrontendImpl() {
188 } 188 }
189 189
190 void WebDevToolsClientImpl::DispatchMessageFromAgent( 190 void WebDevToolsFrontendImpl::dispatchMessageFromAgent(
191 const WebString& class_name, 191 const WebString& class_name,
192 const WebString& method_name, 192 const WebString& method_name,
193 const WebString& param1, 193 const WebString& param1,
194 const WebString& param2, 194 const WebString& param2,
195 const WebString& param3) { 195 const WebString& param3) {
196 if (ToolsAgentNativeDelegateDispatch::Dispatch( 196 if (ToolsAgentNativeDelegateDispatch::Dispatch(
197 tools_agent_native_delegate_impl_.get(), 197 tools_agent_native_delegate_impl_.get(),
198 webkit_glue::WebStringToString(class_name), 198 webkit_glue::WebStringToString(class_name),
199 webkit_glue::WebStringToString(method_name), 199 webkit_glue::WebStringToString(method_name),
200 webkit_glue::WebStringToString(param1), 200 webkit_glue::WebStringToString(param1),
201 webkit_glue::WebStringToString(param2), 201 webkit_glue::WebStringToString(param2),
202 webkit_glue::WebStringToString(param3))) { 202 webkit_glue::WebStringToString(param3))) {
203 return; 203 return;
204 } 204 }
205 205
206 Vector<String> v; 206 Vector<String> v;
207 v.append(webkit_glue::WebStringToString(class_name)); 207 v.append(webkit_glue::WebStringToString(class_name));
208 v.append(webkit_glue::WebStringToString(method_name)); 208 v.append(webkit_glue::WebStringToString(method_name));
209 v.append(webkit_glue::WebStringToString(param1)); 209 v.append(webkit_glue::WebStringToString(param1));
210 v.append(webkit_glue::WebStringToString(param2)); 210 v.append(webkit_glue::WebStringToString(param2));
211 v.append(webkit_glue::WebStringToString(param3)); 211 v.append(webkit_glue::WebStringToString(param3));
212 if (!loaded_) { 212 if (!loaded_) {
213 pending_incoming_messages_.append(v); 213 pending_incoming_messages_.append(v);
214 return; 214 return;
215 } 215 }
216 ExecuteScript(v); 216 ExecuteScript(v);
217 } 217 }
218 218
219 void WebDevToolsClientImpl::AddResourceSourceToFrame(int resource_id, 219 void WebDevToolsFrontendImpl::AddResourceSourceToFrame(int resource_id,
220 String mime_type, 220 String mime_type,
221 Node* frame) { 221 Node* frame) {
222 if (tools_agent_native_delegate_impl_->WaitingForResponse(resource_id, 222 if (tools_agent_native_delegate_impl_->WaitingForResponse(resource_id,
223 frame)) { 223 frame)) {
224 return; 224 return;
225 } 225 }
226 tools_agent_obj_->GetResourceContent(resource_id, resource_id); 226 tools_agent_obj_->GetResourceContent(resource_id, resource_id);
227 tools_agent_native_delegate_impl_->RequestSent(resource_id, mime_type, frame); 227 tools_agent_native_delegate_impl_->RequestSent(resource_id, mime_type, frame);
228 } 228 }
229 229
230 void WebDevToolsClientImpl::ExecuteScript(const Vector<String>& v) { 230 void WebDevToolsFrontendImpl::ExecuteScript(const Vector<String>& v) {
231 WebFrameImpl* frame = web_view_impl_->main_frame(); 231 WebFrameImpl* frame = web_view_impl_->main_frame();
232 v8::HandleScope scope; 232 v8::HandleScope scope;
233 v8::Handle<v8::Context> frame_context = V8Proxy::context(frame->frame()); 233 v8::Handle<v8::Context> frame_context = V8Proxy::context(frame->frame());
234 v8::Context::Scope context_scope(frame_context); 234 v8::Context::Scope context_scope(frame_context);
235 v8::Handle<v8::Value> dispatch_function = 235 v8::Handle<v8::Value> dispatch_function =
236 frame_context->Global()->Get(v8::String::New("devtools$$dispatch")); 236 frame_context->Global()->Get(v8::String::New("devtools$$dispatch"));
237 ASSERT(dispatch_function->IsFunction()); 237 ASSERT(dispatch_function->IsFunction());
238 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatch_fu nction); 238 v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(dispatch_fu nction);
239 v8::Handle<v8::Value> args[] = { 239 v8::Handle<v8::Value> args[] = {
240 ToV8String(v.at(0)), 240 ToV8String(v.at(0)),
241 ToV8String(v.at(1)), 241 ToV8String(v.at(1)),
242 ToV8String(v.at(2)), 242 ToV8String(v.at(2)),
243 ToV8String(v.at(3)), 243 ToV8String(v.at(3)),
244 ToV8String(v.at(4)), 244 ToV8String(v.at(4)),
245 }; 245 };
246 function->Call(frame_context->Global(), 5, args); 246 function->Call(frame_context->Global(), 5, args);
247 } 247 }
248 248
249 void WebDevToolsClientImpl::SendRpcMessage(const String& class_name, 249 void WebDevToolsFrontendImpl::SendRpcMessage(const String& class_name,
250 const String& method_name, 250 const String& method_name,
251 const String& param1, 251 const String& param1,
252 const String& param2, 252 const String& param2,
253 const String& param3) { 253 const String& param3) {
254 delegate_->SendMessageToAgent( 254 client_->sendMessageToAgent(
255 webkit_glue::StringToWebString(class_name), 255 webkit_glue::StringToWebString(class_name),
256 webkit_glue::StringToWebString(method_name), 256 webkit_glue::StringToWebString(method_name),
257 webkit_glue::StringToWebString(param1), 257 webkit_glue::StringToWebString(param1),
258 webkit_glue::StringToWebString(param2), 258 webkit_glue::StringToWebString(param2),
259 webkit_glue::StringToWebString(param3)); 259 webkit_glue::StringToWebString(param3));
260 } 260 }
261 261
262 // static 262 // static
263 v8::Handle<v8::Value> WebDevToolsClientImpl::JsReset( 263 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsReset(
264 const v8::Arguments& args) { 264 const v8::Arguments& args) {
265 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 265 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
266 v8::External::Cast(*args.Data())->Value()); 266 v8::External::Cast(*args.Data())->Value());
267 WebFrameImpl* frame = client->web_view_impl_->main_frame(); 267 WebFrameImpl* frame = frontend->web_view_impl_->main_frame();
268 client->tools_agent_native_delegate_impl_.set( 268 frontend->tools_agent_native_delegate_impl_.set(
269 new ToolsAgentNativeDelegateImpl(frame)); 269 new ToolsAgentNativeDelegateImpl(frame));
270 return v8::Undefined(); 270 return v8::Undefined();
271 } 271 }
272 272
273 // static 273 // static
274 v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddSourceToFrame( 274 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsAddSourceToFrame(
275 const v8::Arguments& args) { 275 const v8::Arguments& args) {
276 if (args.Length() < 2) { 276 if (args.Length() < 2) {
277 return v8::Undefined(); 277 return v8::Undefined();
278 } 278 }
279 279
280 v8::TryCatch exception_catcher; 280 v8::TryCatch exception_catcher;
281 281
282 String mime_type = WebCore::toWebCoreStringWithNullCheck(args[0]); 282 String mime_type = WebCore::toWebCoreStringWithNullCheck(args[0]);
283 if (mime_type.isEmpty() || exception_catcher.HasCaught()) { 283 if (mime_type.isEmpty() || exception_catcher.HasCaught()) {
284 return v8::Undefined(); 284 return v8::Undefined();
285 } 285 }
286 String source_string = WebCore::toWebCoreStringWithNullCheck(args[1]); 286 String source_string = WebCore::toWebCoreStringWithNullCheck(args[1]);
287 if (source_string.isEmpty() || exception_catcher.HasCaught()) { 287 if (source_string.isEmpty() || exception_catcher.HasCaught()) {
288 return v8::Undefined(); 288 return v8::Undefined();
289 } 289 }
290 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(args[2]); 290 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(args[2]);
291 Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(wrapper); 291 Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(wrapper);
292 if (!node || !node->attached()) { 292 if (!node || !node->attached()) {
293 return v8::Undefined(); 293 return v8::Undefined();
294 } 294 }
295 295
296 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page(); 296 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page();
297 InspectorController* inspectorController = page->inspectorController(); 297 InspectorController* inspectorController = page->inspectorController();
298 return WebCore::v8Boolean(inspectorController->inspectorBackend()-> 298 return WebCore::v8Boolean(inspectorController->inspectorBackend()->
299 addSourceToFrame(mime_type, source_string, node)); 299 addSourceToFrame(mime_type, source_string, node));
300 } 300 }
301 301
302 // static 302 // static
303 v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddResourceSourceToFrame( 303 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsAddResourceSourceToFrame(
304 const v8::Arguments& args) { 304 const v8::Arguments& args) {
305 int resource_id = static_cast<int>(args[0]->NumberValue()); 305 int resource_id = static_cast<int>(args[0]->NumberValue());
306 String mime_type = WebCore::toWebCoreStringWithNullCheck(args[1]); 306 String mime_type = WebCore::toWebCoreStringWithNullCheck(args[1]);
307 if (mime_type.isEmpty()) { 307 if (mime_type.isEmpty()) {
308 return v8::Undefined(); 308 return v8::Undefined();
309 } 309 }
310 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(args[2]); 310 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(args[2]);
311 Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(wrapper); 311 Node* node = V8DOMWrapper::convertDOMWrapperToNode<Node>(wrapper);
312 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 312 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
313 v8::External::Cast(*args.Data())->Value()); 313 v8::External::Cast(*args.Data())->Value());
314 client->AddResourceSourceToFrame(resource_id, mime_type, node); 314 frontend->AddResourceSourceToFrame(resource_id, mime_type, node);
315 return v8::Undefined(); 315 return v8::Undefined();
316 } 316 }
317 317
318 // static 318 // static
319 v8::Handle<v8::Value> WebDevToolsClientImpl::JsLoaded( 319 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsLoaded(
320 const v8::Arguments& args) { 320 const v8::Arguments& args) {
321 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 321 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
322 v8::External::Cast(*args.Data())->Value()); 322 v8::External::Cast(*args.Data())->Value());
323 client->loaded_ = true; 323 frontend->loaded_ = true;
324 324
325 // Grant the devtools page the ability to have source view iframes. 325 // Grant the devtools page the ability to have source view iframes.
326 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page(); 326 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page();
327 SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin(); 327 SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin();
328 origin->grantUniversalAccess(); 328 origin->grantUniversalAccess();
329 329
330 for (Vector<Vector<String> >::iterator it = 330 for (Vector<Vector<String> >::iterator it =
331 client->pending_incoming_messages_.begin(); 331 frontend->pending_incoming_messages_.begin();
332 it != client->pending_incoming_messages_.end(); 332 it != frontend->pending_incoming_messages_.end();
333 ++it) { 333 ++it) {
334 client->ExecuteScript(*it); 334 frontend->ExecuteScript(*it);
335 } 335 }
336 client->pending_incoming_messages_.clear(); 336 frontend->pending_incoming_messages_.clear();
337 return v8::Undefined(); 337 return v8::Undefined();
338 } 338 }
339 339
340 // static 340 // static
341 v8::Handle<v8::Value> WebDevToolsClientImpl::JsGetPlatform( 341 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsGetPlatform(
342 const v8::Arguments& args) { 342 const v8::Arguments& args) {
343 #if defined OS_MACOSX 343 #if defined OS_MACOSX
344 return v8String("mac-leopard"); 344 return v8String("mac-leopard");
345 #elif defined OS_LINUX 345 #elif defined OS_LINUX
346 return v8String("linux"); 346 return v8String("linux");
347 #else 347 #else
348 return v8String("windows"); 348 return v8String("windows");
349 #endif 349 #endif
350 } 350 }
351 351
352 // static 352 // static
353 v8::Handle<v8::Value> WebDevToolsClientImpl::JsActivateWindow( 353 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsActivateWindow(
354 const v8::Arguments& args) { 354 const v8::Arguments& args) {
355 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 355 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
356 v8::External::Cast(*args.Data())->Value()); 356 v8::External::Cast(*args.Data())->Value());
357 client->delegate_->ActivateWindow(); 357 frontend->client_->activateWindow();
358 return v8::Undefined(); 358 return v8::Undefined();
359 } 359 }
360 360
361 // static 361 // static
362 v8::Handle<v8::Value> WebDevToolsClientImpl::JsCloseWindow( 362 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsCloseWindow(
363 const v8::Arguments& args) { 363 const v8::Arguments& args) {
364 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 364 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
365 v8::External::Cast(*args.Data())->Value()); 365 v8::External::Cast(*args.Data())->Value());
366 client->delegate_->CloseWindow(); 366 frontend->client_->closeWindow();
367 return v8::Undefined(); 367 return v8::Undefined();
368 } 368 }
369 369
370 // static 370 // static
371 v8::Handle<v8::Value> WebDevToolsClientImpl::JsDockWindow( 371 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsDockWindow(
372 const v8::Arguments& args) { 372 const v8::Arguments& args) {
373 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 373 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
374 v8::External::Cast(*args.Data())->Value()); 374 v8::External::Cast(*args.Data())->Value());
375 client->delegate_->DockWindow(); 375 frontend->client_->dockWindow();
376 return v8::Undefined(); 376 return v8::Undefined();
377 } 377 }
378 378
379 // static 379 // static
380 v8::Handle<v8::Value> WebDevToolsClientImpl::JsUndockWindow( 380 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsUndockWindow(
381 const v8::Arguments& args) { 381 const v8::Arguments& args) {
382 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 382 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
383 v8::External::Cast(*args.Data())->Value()); 383 v8::External::Cast(*args.Data())->Value());
384 client->delegate_->UndockWindow(); 384 frontend->client_->undockWindow();
385 return v8::Undefined(); 385 return v8::Undefined();
386 } 386 }
387 387
388 // static 388 // static
389 v8::Handle<v8::Value> WebDevToolsClientImpl::JsToggleInspectElementMode( 389 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsToggleInspectElementMode(
390 const v8::Arguments& args) { 390 const v8::Arguments& args) {
391 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 391 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
392 v8::External::Cast(*args.Data())->Value()); 392 v8::External::Cast(*args.Data())->Value());
393 int enabled = static_cast<int>(args[0]->BooleanValue()); 393 int enabled = static_cast<int>(args[0]->BooleanValue());
394 client->delegate_->ToggleInspectElementMode(enabled); 394 frontend->client_->toggleInspectElementMode(enabled);
395 return v8::Undefined(); 395 return v8::Undefined();
396 } 396 }
397 397
398 // static 398 // static
399 v8::Handle<v8::Value> WebDevToolsClientImpl::JsGetApplicationLocale( 399 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsGetApplicationLocale(
400 const v8::Arguments& args) { 400 const v8::Arguments& args) {
401 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 401 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
402 v8::External::Cast(*args.Data())->Value()); 402 v8::External::Cast(*args.Data())->Value());
403 return v8String(client->application_locale_); 403 return v8String(frontend->application_locale_);
404 } 404 }
405 405
406 // static 406 // static
407 v8::Handle<v8::Value> WebDevToolsClientImpl::JsHiddenPanels( 407 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsHiddenPanels(
408 const v8::Arguments& args) { 408 const v8::Arguments& args) {
409 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page(); 409 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page();
410 return v8String(page->settings()->databasesEnabled() ? "" : "databases"); 410 return v8String(page->settings()->databasesEnabled() ? "" : "databases");
411 } 411 }
412 412
413 // static 413 // static
414 v8::Handle<v8::Value> WebDevToolsClientImpl::JsDebuggerCommand( 414 v8::Handle<v8::Value> WebDevToolsFrontendImpl::JsDebuggerCommand(
415 const v8::Arguments& args) { 415 const v8::Arguments& args) {
416 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 416 WebDevToolsFrontendImpl* frontend = static_cast<WebDevToolsFrontendImpl*>(
417 v8::External::Cast(*args.Data())->Value()); 417 v8::External::Cast(*args.Data())->Value());
418 String command = WebCore::toWebCoreStringWithNullCheck(args[0]); 418 String command = WebCore::toWebCoreStringWithNullCheck(args[0]);
419 WebString std_command = webkit_glue::StringToWebString(command); 419 WebString std_command = webkit_glue::StringToWebString(command);
420 client->delegate_->SendDebuggerCommandToAgent(std_command); 420 frontend->client_->sendDebuggerCommandToAgent(std_command);
421 return v8::Undefined(); 421 return v8::Undefined();
422 } 422 }
OLDNEW
« no previous file with comments | « webkit/glue/webdevtoolsfrontend_impl.h ('k') | webkit/webkit.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698