| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 if (!remoteObject) | 359 if (!remoteObject) |
| 360 return; | 360 return; |
| 361 *result = std::move(remoteObject); | 361 *result = std::move(remoteObject); |
| 362 if (exceptionDetails) | 362 if (exceptionDetails) |
| 363 *exceptionDetails = createExceptionDetails(tryCatch.Message()); | 363 *exceptionDetails = createExceptionDetails(tryCatch.Message()); |
| 364 if (wasThrown) | 364 if (wasThrown) |
| 365 *wasThrown = true; | 365 *wasThrown = true; |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 | 368 |
| 369 v8::MaybeLocal<v8::Object> InjectedScript::commandLineAPI(ErrorString* errorStri
ng) | 369 v8::Local<v8::Object> InjectedScript::commandLineAPI() |
| 370 { | 370 { |
| 371 v8::Isolate* isolate = m_context->isolate(); | 371 if (m_commandLineAPI.IsEmpty()) |
| 372 if (m_commandLineAPI.IsEmpty()) { | 372 m_commandLineAPI.Reset(m_context->isolate(), V8Console::createCommandLin
eAPI(m_context)); |
| 373 V8FunctionCall function(m_context->debugger(), m_context->context(), v8V
alue(), "installCommandLineAPI"); | |
| 374 function.appendArgument(V8Console::createCommandLineAPI(m_context)); | |
| 375 bool hadException = false; | |
| 376 v8::Local<v8::Value> extension = function.call(hadException, false); | |
| 377 if (hasInternalError(errorString, hadException || extension.IsEmpty() ||
!extension->IsObject())) | |
| 378 return v8::MaybeLocal<v8::Object>(); | |
| 379 m_commandLineAPI.Reset(isolate, extension.As<v8::Object>()); | |
| 380 } | |
| 381 return m_commandLineAPI.Get(m_context->isolate()); | 373 return m_commandLineAPI.Get(m_context->isolate()); |
| 382 } | 374 } |
| 383 | 375 |
| 384 InjectedScript::Scope::Scope(ErrorString* errorString, V8DebuggerImpl* debugger,
int contextGroupId) | 376 InjectedScript::Scope::Scope(ErrorString* errorString, V8DebuggerImpl* debugger,
int contextGroupId) |
| 385 : m_errorString(errorString) | 377 : m_errorString(errorString) |
| 386 , m_debugger(debugger) | 378 , m_debugger(debugger) |
| 387 , m_contextGroupId(contextGroupId) | 379 , m_contextGroupId(contextGroupId) |
| 388 , m_injectedScript(nullptr) | 380 , m_injectedScript(nullptr) |
| 389 , m_handleScope(debugger->isolate()) | 381 , m_handleScope(debugger->isolate()) |
| 390 , m_tryCatch(debugger->isolate()) | 382 , m_tryCatch(debugger->isolate()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 407 if (!m_injectedScript) | 399 if (!m_injectedScript) |
| 408 return false; | 400 return false; |
| 409 m_context = m_injectedScript->context()->context(); | 401 m_context = m_injectedScript->context()->context(); |
| 410 m_context->Enter(); | 402 m_context->Enter(); |
| 411 return true; | 403 return true; |
| 412 } | 404 } |
| 413 | 405 |
| 414 bool InjectedScript::Scope::installCommandLineAPI() | 406 bool InjectedScript::Scope::installCommandLineAPI() |
| 415 { | 407 { |
| 416 DCHECK(m_injectedScript && !m_context.IsEmpty() && m_global.IsEmpty()); | 408 DCHECK(m_injectedScript && !m_context.IsEmpty() && m_global.IsEmpty()); |
| 417 v8::Local<v8::Object> extensionObject; | |
| 418 if (!m_injectedScript->commandLineAPI(m_errorString).ToLocal(&extensionObjec
t)) | |
| 419 return false; | |
| 420 m_extensionPrivate = V8Debugger::scopeExtensionPrivate(m_debugger->isolate()
); | 409 m_extensionPrivate = V8Debugger::scopeExtensionPrivate(m_debugger->isolate()
); |
| 421 v8::Local<v8::Object> global = m_context->Global(); | 410 v8::Local<v8::Object> global = m_context->Global(); |
| 422 if (!global->SetPrivate(m_context, m_extensionPrivate, extensionObject).From
Maybe(false)) { | 411 if (!global->SetPrivate(m_context, m_extensionPrivate, m_injectedScript->com
mandLineAPI()).FromMaybe(false)) { |
| 423 *m_errorString = "Internal error"; | 412 *m_errorString = "Internal error"; |
| 424 return false; | 413 return false; |
| 425 } | 414 } |
| 426 m_global = global; | 415 m_global = global; |
| 427 return true; | 416 return true; |
| 428 } | 417 } |
| 429 | 418 |
| 430 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() | 419 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() |
| 431 { | 420 { |
| 432 ASSERT(!m_ignoreExceptionsAndMuteConsole); | 421 ASSERT(!m_ignoreExceptionsAndMuteConsole); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) | 518 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) |
| 530 { | 519 { |
| 531 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString,
m_remoteCallFrameId); | 520 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString,
m_remoteCallFrameId); |
| 532 if (!remoteId) | 521 if (!remoteId) |
| 533 return; | 522 return; |
| 534 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 523 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
| 535 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); | 524 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); |
| 536 } | 525 } |
| 537 | 526 |
| 538 } // namespace blink | 527 } // namespace blink |
| OLD | NEW |