OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 DartApiScope apiScope; | 264 DartApiScope apiScope; |
265 | 265 |
266 for (DebuggerObjectMap::iterator it = m_objects.begin(); it != m_objects.end
(); ++it) { | 266 for (DebuggerObjectMap::iterator it = m_objects.begin(); it != m_objects.end
(); ++it) { |
267 delete it->value; | 267 delete it->value; |
268 } | 268 } |
269 | 269 |
270 if (m_consoleApi) | 270 if (m_consoleApi) |
271 Dart_DeletePersistentHandle(m_consoleApi); | 271 Dart_DeletePersistentHandle(m_consoleApi); |
272 } | 272 } |
273 | 273 |
274 // Copied from V8injectedScriptManager. | |
275 v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(PassRefPtrWillBeRawPtr<I
njectedScriptHost> host, InjectedScriptManager* injectedScriptManager, v8::Handl
e<v8::Context> creationContext, v8::Isolate* isolate) | |
276 { | |
277 // TODO(jacobr): is this correct. | |
278 v8::Local<v8::FunctionTemplate> wrapperTemplate = host->wrapperTemplate(isol
ate); | |
279 ASSERT(!wrapperTemplate.IsEmpty()); | |
280 if (wrapperTemplate.IsEmpty()) { | |
281 // Hopefully this isn't needed. | |
282 wrapperTemplate = V8InjectedScriptHost::createWrapperTemplate(isolate); | |
283 host->setWrapperTemplate(wrapperTemplate, isolate); | |
284 } | |
285 | |
286 return V8InjectedScriptHost::wrap(wrapperTemplate, creationContext, host); | |
287 } | |
288 | |
289 Dart_Handle DartInjectedScript::consoleApi() | 274 Dart_Handle DartInjectedScript::consoleApi() |
290 { | 275 { |
291 if (!m_consoleApi) { | 276 if (!m_consoleApi) { |
292 V8Scope v8scope(DartDOMData::current()); | 277 V8Scope v8scope(DartDOMData::current()); |
293 v8::Local<v8::Object> scriptHostWrapper = createInjectedScriptHostV8Wrap
per(m_host, m_injectedScriptManager, m_scriptState->v8ScriptState()->context(),
v8::Isolate::GetCurrent()); | 278 Dart_Handle injecteScriptV8 = JsInterop::toDart(m_injectedScriptManager-
>injectedScriptFor(m_scriptState->v8ScriptState()).injectedScriptObject().v8Valu
e(), false); |
294 | 279 Dart_Handle consoleApi = DartUtilities::invokeUtilsMethod("consoleApi",
1, &injecteScriptV8); |
295 Dart_Handle host = JsInterop::toDart(scriptHostWrapper, false); | |
296 Dart_SetPeer(host, this); | |
297 Dart_Handle consoleApi = DartUtilities::invokeUtilsMethod("consoleApi",
1, &host); | |
298 ASSERT(!Dart_IsError(consoleApi)); | 280 ASSERT(!Dart_IsError(consoleApi)); |
299 m_consoleApi = Dart_NewPersistentHandle(consoleApi); | 281 m_consoleApi = Dart_NewPersistentHandle(consoleApi); |
300 } | 282 } |
301 return m_consoleApi; | 283 return m_consoleApi; |
302 } | 284 } |
303 | 285 |
304 Dart_Handle DartInjectedScript::evaluateHelper(Dart_Handle target, const String&
rawExpression, Dart_Handle localVariables, bool includeCommandLineAPI, Dart_Han
dle& exception) | 286 Dart_Handle DartInjectedScript::evaluateHelper(Dart_Handle target, const String&
rawExpression, Dart_Handle localVariables, bool includeCommandLineAPI, Dart_Han
dle& exception) |
305 { | 287 { |
306 DartDOMData* domData = DartDOMData::current(); | 288 DartDOMData* domData = DartDOMData::current(); |
307 ALLOW_UNUSED_LOCAL(domData); | 289 ALLOW_UNUSED_LOCAL(domData); |
(...skipping 11 matching lines...) Expand all Loading... |
319 ASSERT(!exception); | 301 ASSERT(!exception); |
320 } | 302 } |
321 | 303 |
322 ScriptState* scriptState = DartUtilities::v8ScriptStateForCurrentIsolate
(); | 304 ScriptState* scriptState = DartUtilities::v8ScriptStateForCurrentIsolate
(); |
323 for (unsigned i = 0; i < 6; i++) { | 305 for (unsigned i = 0; i < 6; i++) { |
324 ScriptValue value = m_host->inspectedObject(i)->get(scriptState); | 306 ScriptValue value = m_host->inspectedObject(i)->get(scriptState); |
325 v8::TryCatch tryCatch; | 307 v8::TryCatch tryCatch; |
326 v8::Handle<v8::Value> v8Value = value.v8Value(); | 308 v8::Handle<v8::Value> v8Value = value.v8Value(); |
327 if (v8Value.IsEmpty()) | 309 if (v8Value.IsEmpty()) |
328 break; | 310 break; |
329 Dart_Handle dartValue = DartHandleProxy::unwrapValue(v8Value); | 311 Dart_Handle dartValue = JsInterop::toDart(v8Value, true); |
330 ASSERT(!Dart_IsError(dartValue)); | 312 ASSERT(!Dart_IsError(dartValue)); |
331 if (Dart_IsNull(dartValue)) | 313 if (Dart_IsError(dartValue) || Dart_IsNull(dartValue)) |
332 continue; | 314 continue; |
333 locals.append(DartUtilities::stringToDartString(String::format("$%d"
, i))); | 315 locals.append(DartUtilities::stringToDartString(String::format("$%d"
, i))); |
334 locals.append(dartValue); | 316 locals.append(dartValue); |
335 } | 317 } |
336 | 318 |
337 Dart_Handle list = consoleApi(); | 319 Dart_Handle list = consoleApi(); |
338 intptr_t length = 0; | 320 intptr_t length = 0; |
339 ASSERT(Dart_IsList(list)); | 321 ASSERT(Dart_IsList(list)); |
340 Dart_Handle ret = Dart_ListLength(list, &length); | 322 Dart_Handle ret = Dart_ListLength(list, &length); |
341 ALLOW_UNUSED_LOCAL(ret); | 323 ALLOW_UNUSED_LOCAL(ret); |
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 RefPtr<JSONValue> parsedObjectId = parseJSON(objectId); | 1438 RefPtr<JSONValue> parsedObjectId = parseJSON(objectId); |
1457 if (parsedObjectId && parsedObjectId->type() == JSONValue::TypeObject) { | 1439 if (parsedObjectId && parsedObjectId->type() == JSONValue::TypeObject) { |
1458 bool isDart = false; | 1440 bool isDart = false; |
1459 bool success = parsedObjectId->asObject()-> getBoolean("isDart", &isDart
); | 1441 bool success = parsedObjectId->asObject()-> getBoolean("isDart", &isDart
); |
1460 return success && isDart; | 1442 return success && isDart; |
1461 } | 1443 } |
1462 return false; | 1444 return false; |
1463 } | 1445 } |
1464 | 1446 |
1465 } // namespace blink | 1447 } // namespace blink |
OLD | NEW |