| OLD | NEW |
| (Empty) |
| 1 #include "config.h" | |
| 2 #include "bindings/core/dart/DartInspectorRuntimeAgent.h" | |
| 3 | |
| 4 #include "bindings/common/ScriptState.h" | |
| 5 #include "bindings/core/dart/DartInjectedScript.h" | |
| 6 #include "bindings/core/dart/DartInjectedScriptManager.h" | |
| 7 #include "bindings/core/dart/DartScriptDebugServer.h" | |
| 8 #include "core/inspector/InjectedScript.h" | |
| 9 #include "core/inspector/InspectorState.h" | |
| 10 #include "platform/JSONValues.h" | |
| 11 | |
| 12 using blink::TypeBuilder::Runtime::ExecutionContextDescription; | |
| 13 | |
| 14 namespace blink { | |
| 15 | |
| 16 static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(Scrip
tDebugServer::PauseOnExceptionsState newState) | |
| 17 { | |
| 18 DartScriptDebugServer& scriptDebugServer = DartScriptDebugServer::shared(); | |
| 19 ScriptDebugServer::PauseOnExceptionsState presentState = scriptDebugServer.p
auseOnExceptionsState(); | |
| 20 if (presentState != newState) | |
| 21 scriptDebugServer.setPauseOnExceptionsState(newState); | |
| 22 return presentState; | |
| 23 } | |
| 24 | |
| 25 DartInspectorRuntimeAgent::DartInspectorRuntimeAgent(DartInjectedScriptManager*
injectedScriptManager, InspectorRuntimeAgent* inspectorRuntimeAgent) | |
| 26 { | |
| 27 m_injectedScriptManager = injectedScriptManager; | |
| 28 m_inspectorRuntimeAgent = inspectorRuntimeAgent; | |
| 29 } | |
| 30 | |
| 31 DartInjectedScript* DartInspectorRuntimeAgent::injectedScriptForEval(ErrorString
* errorString, const int* executionContextId) | |
| 32 { | |
| 33 if (!executionContextId) { | |
| 34 return 0; | |
| 35 } | |
| 36 DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScript
ForId(*executionContextId); | |
| 37 if (injectedScript == 0) | |
| 38 *errorString = "Execution context with given id not found."; | |
| 39 return injectedScript; | |
| 40 } | |
| 41 | |
| 42 void DartInspectorRuntimeAgent::evaluate(ErrorString* errorString, const String&
expression, const String* const objectGroup, const bool* const includeCommandLi
neAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const int* execut
ionContextId, const bool* const returnByValue, const bool* generatePreview, RefP
tr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wa
sThrown, RefPtr<TypeBuilder::Debugger::ExceptionDetails>& exceptionDetails) | |
| 43 { | |
| 44 DartInjectedScript* injectedScript = injectedScriptForEval(errorString, exec
utionContextId); | |
| 45 if (!injectedScript) | |
| 46 return; | |
| 47 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = S
criptDebugServer::DontPauseOnExceptions; | |
| 48 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | |
| 49 previousPauseOnExceptionsState = setPauseOnExceptionsState(ScriptDebugSe
rver::DontPauseOnExceptions); | |
| 50 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | |
| 51 m_inspectorRuntimeAgent->muteConsole(); | |
| 52 | |
| 53 injectedScript->evaluate(errorString, expression, objectGroup ? *objectGroup
: "", asBool(includeCommandLineAPI), asBool(returnByValue), asBool(generatePrev
iew), &result, wasThrown, &exceptionDetails); | |
| 54 | |
| 55 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { | |
| 56 m_inspectorRuntimeAgent->unmuteConsole(); | |
| 57 setPauseOnExceptionsState(previousPauseOnExceptionsState); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 void DartInspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const S
tring& objectId, const String& expression, const RefPtr<JSONArray>* const option
alArguments, const bool* const doNotPauseOnExceptionsAndMuteConsole, const bool*
const returnByValue, const bool* generatePreview, RefPtr<TypeBuilder::Runtime::
RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) | |
| 62 { | |
| 63 DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScript
ForObjectId(objectId); | |
| 64 if (!injectedScript) { | |
| 65 *errorString = "Inspected frame has gone"; | |
| 66 return; | |
| 67 } | |
| 68 String arguments; | |
| 69 if (optionalArguments) | |
| 70 arguments = (*optionalArguments)->toJSONString(); | |
| 71 | |
| 72 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = S
criptDebugServer::DontPauseOnExceptions; | |
| 73 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | |
| 74 previousPauseOnExceptionsState = setPauseOnExceptionsState(ScriptDebugSe
rver::DontPauseOnExceptions); | |
| 75 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) | |
| 76 m_inspectorRuntimeAgent->muteConsole(); | |
| 77 | |
| 78 injectedScript->callFunctionOn(errorString, objectId, expression, arguments,
asBool(returnByValue), asBool(generatePreview), &result, wasThrown); | |
| 79 | |
| 80 if (asBool(doNotPauseOnExceptionsAndMuteConsole)) { | |
| 81 m_inspectorRuntimeAgent->unmuteConsole(); | |
| 82 setPauseOnExceptionsState(previousPauseOnExceptionsState); | |
| 83 } | |
| 84 | |
| 85 } | |
| 86 | |
| 87 void DartInspectorRuntimeAgent::getCompletions(ErrorString* errorString, const S
tring& expression, const int* executionContextId, RefPtr<TypeBuilder::Array<Stri
ng> >& result) | |
| 88 { | |
| 89 DartInjectedScript* injectedScript = injectedScriptForEval(errorString, exec
utionContextId); | |
| 90 if (!injectedScript) | |
| 91 return; | |
| 92 | |
| 93 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
etPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions); | |
| 94 m_inspectorRuntimeAgent->muteConsole(); | |
| 95 | |
| 96 injectedScript->getCompletions(errorString, expression, &result); | |
| 97 | |
| 98 m_inspectorRuntimeAgent->unmuteConsole(); | |
| 99 setPauseOnExceptionsState(previousPauseOnExceptionsState); | |
| 100 | |
| 101 } | |
| 102 | |
| 103 void DartInspectorRuntimeAgent::getProperties(ErrorString* errorString, const St
ring& objectId, const bool* ownProperties, const bool* accessorPropertiesOnly, R
efPtr<TypeBuilder::Array<TypeBuilder::Runtime::PropertyDescriptor> >& result, Re
fPtr<TypeBuilder::Array<TypeBuilder::Runtime::InternalPropertyDescriptor> >& int
ernalProperties) | |
| 104 { | |
| 105 DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScript
ForObjectId(objectId); | |
| 106 if (!injectedScript) { | |
| 107 *errorString = "Inspected frame has gone"; | |
| 108 return; | |
| 109 } | |
| 110 | |
| 111 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
etPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions); | |
| 112 m_inspectorRuntimeAgent->muteConsole(); | |
| 113 | |
| 114 injectedScript->getProperties(errorString, objectId, asBool(ownProperties),
asBool(accessorPropertiesOnly), &result); | |
| 115 | |
| 116 if (!asBool(accessorPropertiesOnly)) | |
| 117 injectedScript->getInternalProperties(errorString, objectId, &internalPr
operties); | |
| 118 | |
| 119 m_inspectorRuntimeAgent->unmuteConsole(); | |
| 120 setPauseOnExceptionsState(previousPauseOnExceptionsState); | |
| 121 } | |
| 122 | |
| 123 void DartInspectorRuntimeAgent::getProperty(ErrorString* errorString, const Stri
ng& objectId, const RefPtr<JSONArray>& propertyPath, RefPtr<TypeBuilder::Runtime
::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown) | |
| 124 { | |
| 125 DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScript
ForObjectId(objectId); | |
| 126 if (!injectedScript) { | |
| 127 *errorString = "Inspected frame has gone"; | |
| 128 return; | |
| 129 } | |
| 130 | |
| 131 ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = s
etPauseOnExceptionsState(ScriptDebugServer::DontPauseOnExceptions); | |
| 132 m_inspectorRuntimeAgent->muteConsole(); | |
| 133 | |
| 134 injectedScript->getProperty(errorString, objectId, propertyPath, &result, wa
sThrown); | |
| 135 | |
| 136 m_inspectorRuntimeAgent->unmuteConsole(); | |
| 137 setPauseOnExceptionsState(previousPauseOnExceptionsState); | |
| 138 } | |
| 139 | |
| 140 void DartInspectorRuntimeAgent::releaseObject(ErrorString*, const String& object
Id) | |
| 141 { | |
| 142 DartInjectedScript* injectedScript = m_injectedScriptManager->injectedScript
ForObjectId(objectId); | |
| 143 if (injectedScript) | |
| 144 injectedScript->releaseObject(objectId); | |
| 145 } | |
| 146 | |
| 147 void DartInspectorRuntimeAgent::releaseObjectGroup(ErrorString*, const String& o
bjectGroup) | |
| 148 { | |
| 149 m_injectedScriptManager->releaseObjectGroup(objectGroup); | |
| 150 } | |
| 151 | |
| 152 int DartInspectorRuntimeAgent::addExecutionContextToFrontendHelper(ScriptState*
scriptState, bool isPageContext, const String& name, const String& frameId) | |
| 153 { | |
| 154 return m_injectedScriptManager->injectedScriptIdFor(scriptState); | |
| 155 } | |
| 156 | |
| 157 } // namespace blink | |
| OLD | NEW |