31 #ifndef V8_INSPECTOR_INJECTED_SCRIPT_H_ 32 #define V8_INSPECTOR_INJECTED_SCRIPT_H_ 34 #include <unordered_map> 35 #include <unordered_set> 37 #include "src/base/macros.h" 38 #include "src/inspector/inspected-context.h" 39 #include "src/inspector/protocol/Forward.h" 40 #include "src/inspector/protocol/Runtime.h" 41 #include "src/inspector/v8-console.h" 42 #include "src/inspector/v8-debugger.h" 44 #include "include/v8.h" 49 class V8InspectorImpl;
50 class V8InspectorSessionImpl;
53 using protocol::Maybe;
54 using protocol::Response;
58 virtual void sendSuccess(
59 std::unique_ptr<protocol::Runtime::RemoteObject> result,
60 protocol::Maybe<protocol::Runtime::ExceptionDetails>
61 exceptionDetails) = 0;
62 virtual void sendFailure(
const protocol::DispatchResponse& response) = 0;
73 Response getProperties(
75 bool accessorPropertiesOnly, WrapMode wrapMode,
76 std::unique_ptr<protocol::Array<protocol::Runtime::PropertyDescriptor>>*
78 Maybe<protocol::Runtime::ExceptionDetails>*);
80 Response getInternalProperties(
83 protocol::Array<protocol::Runtime::InternalPropertyDescriptor>>*
86 void releaseObject(
const String16& objectId);
90 std::unique_ptr<protocol::Runtime::RemoteObject>* result);
94 int maxCustomPreviewDepth,
95 std::unique_ptr<protocol::Runtime::RemoteObject>* result);
96 std::unique_ptr<protocol::Runtime::RemoteObject> wrapTable(
101 const String16& objectGroup, WrapMode wrapMode,
102 std::unique_ptr<EvaluateCallback> callback);
106 void releaseObjectGroup(
const String16&);
107 void setCustomObjectFormatterEnabled(
bool);
108 Response resolveCallArgument(protocol::Runtime::CallArgument*,
111 Response createExceptionDetails(
112 const v8::TryCatch&,
const String16& groupName, WrapMode wrapMode,
113 Maybe<protocol::Runtime::ExceptionDetails>* result);
114 Response wrapEvaluateResult(
116 const String16& objectGroup, WrapMode wrapMode,
117 std::unique_ptr<protocol::Runtime::RemoteObject>* result,
118 Maybe<protocol::Runtime::ExceptionDetails>*);
124 Response initialize();
125 void installCommandLineAPI();
126 void ignoreExceptionsAndMuteConsole();
127 void pretendUserGesture();
128 void allowCodeGenerationFromStrings();
130 InjectedScript* injectedScript()
const {
return m_injectedScript; }
131 const v8::TryCatch& tryCatch()
const {
return m_tryCatch; }
143 v8::debug::ExceptionBreakState setPauseOnExceptionsState(
144 v8::debug::ExceptionBreakState);
147 v8::TryCatch m_tryCatch;
149 std::unique_ptr<V8Console::CommandLineAPIScope> m_commandLineAPIScope;
150 bool m_ignoreExceptionsAndMuteConsole;
151 v8::debug::ExceptionBreakState m_previousPauseOnExceptionsState;
154 int m_contextGroupId;
165 int m_executionContextId;
174 const String16& objectGroupName()
const {
return m_objectGroupName; }
190 size_t frameOrdinal()
const {
return m_frameOrdinal; }
195 size_t m_frameOrdinal;
203 void unbindObject(
int id);
205 static Response bindRemoteObjectIfNeeded(
207 const String16& groupName, protocol::Runtime::RemoteObject* remoteObject);
210 void discardEvaluateCallbacks();
211 std::unique_ptr<EvaluateCallback> takeEvaluateCallback(
218 int m_lastBoundObjectId = 1;
219 std::unordered_map<int, v8::Global<v8::Value>> m_idToWrappedObject;
220 std::unordered_map<int, String16> m_idToObjectGroupName;
221 std::unordered_map<String16, std::vector<int>> m_nameToObjectGroup;
222 std::unordered_set<EvaluateCallback*> m_evaluateCallbacks;
223 bool m_customPreviewEnabled =
false;
230 #endif // V8_INSPECTOR_INJECTED_SCRIPT_H_