| 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef InjectedScript_h | 31 #ifndef InjectedScript_h |
| 32 #define InjectedScript_h | 32 #define InjectedScript_h |
| 33 | 33 |
| 34 #include "platform/inspector_protocol/Allocator.h" | 34 #include "platform/inspector_protocol/Allocator.h" |
| 35 #include "platform/inspector_protocol/TypeBuilder.h" | 35 #include "platform/inspector_protocol/TypeBuilder.h" |
| 36 #include "platform/v8_inspector/InjectedScriptNative.h" | 36 #include "platform/v8_inspector/InjectedScriptNative.h" |
| 37 #include "platform/v8_inspector/InspectedContext.h" | 37 #include "platform/v8_inspector/InspectedContext.h" |
| 38 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 38 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
| 39 | 40 |
| 40 #include <v8.h> | 41 #include <v8.h> |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 class InjectedScriptHost; | 45 class InjectedScriptHost; |
| 45 class RemoteObjectId; | 46 class RemoteObjectId; |
| 46 class V8FunctionCall; | 47 class V8FunctionCall; |
| 47 class V8InspectorSessionImpl; | 48 class V8InspectorSessionImpl; |
| 48 | 49 |
| 49 namespace protocol { | 50 namespace protocol { |
| 50 class DictionaryValue; | 51 class DictionaryValue; |
| 51 } | 52 } |
| 52 | 53 |
| 53 using protocol::Maybe; | 54 using protocol::Maybe; |
| 54 | 55 |
| 55 class InjectedScript final { | 56 class InjectedScript final { |
| 56 PROTOCOL_DISALLOW_COPY(InjectedScript); | 57 PROTOCOL_DISALLOW_COPY(InjectedScript); |
| 57 public: | 58 public: |
| 58 static PassOwnPtr<InjectedScript> create(InspectedContext*, InjectedScriptHo
st*); | 59 static PassOwnPtr<InjectedScript> create(InspectedContext*, InjectedScriptHo
st*); |
| 59 ~InjectedScript(); | 60 ~InjectedScript(); |
| 60 | 61 |
| 62 InspectedContext* context() const { return m_context; } |
| 63 |
| 61 void getProperties(ErrorString*, v8::Local<v8::Object>, const String16& grou
pName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, Ow
nPtr<protocol::Array<protocol::Runtime::PropertyDescriptor>>* result, Maybe<prot
ocol::Runtime::ExceptionDetails>*); | 64 void getProperties(ErrorString*, v8::Local<v8::Object>, const String16& grou
pName, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, Ow
nPtr<protocol::Array<protocol::Runtime::PropertyDescriptor>>* result, Maybe<prot
ocol::Runtime::ExceptionDetails>*); |
| 62 void releaseObject(const String16& objectId); | 65 void releaseObject(const String16& objectId); |
| 63 | 66 |
| 64 PassOwnPtr<protocol::Runtime::RemoteObject> wrapObject(ErrorString*, v8::Loc
al<v8::Value>, const String16& groupName, bool forceValueType = false, bool gene
ratePreview = false) const; | 67 PassOwnPtr<protocol::Runtime::RemoteObject> wrapObject(ErrorString*, v8::Loc
al<v8::Value>, const String16& groupName, bool forceValueType = false, bool gene
ratePreview = false) const; |
| 65 bool wrapObjectProperty(ErrorString*, v8::Local<v8::Object>, v8::Local<v8::V
alue> key, const String16& groupName, bool forceValueType = false, bool generate
Preview = false) const; | 68 bool wrapObjectProperty(ErrorString*, v8::Local<v8::Object>, v8::Local<v8::V
alue> key, const String16& groupName, bool forceValueType = false, bool generate
Preview = false) const; |
| 66 bool wrapPropertyInArray(ErrorString*, v8::Local<v8::Array>, v8::Local<v8::S
tring> property, const String16& groupName, bool forceValueType = false, bool ge
neratePreview = false) const; | 69 bool wrapPropertyInArray(ErrorString*, v8::Local<v8::Array>, v8::Local<v8::S
tring> property, const String16& groupName, bool forceValueType = false, bool ge
neratePreview = false) const; |
| 67 bool wrapObjectsInArray(ErrorString*, v8::Local<v8::Array>, const String16&
groupName, bool forceValueType = false, bool generatePreview = false) const; | 70 bool wrapObjectsInArray(ErrorString*, v8::Local<v8::Array>, const String16&
groupName, bool forceValueType = false, bool generatePreview = false) const; |
| 71 PassOwnPtr<protocol::Runtime::RemoteObject> wrapTable(v8::Local<v8::Value> t
able, v8::Local<v8::Value> columns) const; |
| 68 | 72 |
| 69 PassOwnPtr<protocol::Runtime::RemoteObject> wrapTable(v8::Local<v8::Value> t
able, v8::Local<v8::Value> columns) const; | |
| 70 bool findObject(ErrorString*, const RemoteObjectId&, v8::Local<v8::Value>*)
const; | 73 bool findObject(ErrorString*, const RemoteObjectId&, v8::Local<v8::Value>*)
const; |
| 71 String16 objectGroupName(const RemoteObjectId&) const; | 74 String16 objectGroupName(const RemoteObjectId&) const; |
| 72 void releaseObjectGroup(const String16&); | 75 void releaseObjectGroup(const String16&); |
| 73 | |
| 74 void setCustomObjectFormatterEnabled(bool); | 76 void setCustomObjectFormatterEnabled(bool); |
| 75 | |
| 76 InspectedContext* context() const { return m_context; } | |
| 77 v8::Isolate* isolate() const; | |
| 78 bool canAccessInspectedWindow() const; | |
| 79 | |
| 80 bool setLastEvaluationResult(ErrorString*, v8::Local<v8::Value>); | |
| 81 v8::MaybeLocal<v8::Value> resolveCallArgument(ErrorString*, protocol::Runtim
e::CallArgument*); | 77 v8::MaybeLocal<v8::Value> resolveCallArgument(ErrorString*, protocol::Runtim
e::CallArgument*); |
| 82 | 78 |
| 83 v8::MaybeLocal<v8::Object> commandLineAPI(ErrorString*) const; | |
| 84 v8::MaybeLocal<v8::Object> remoteObjectAPI(ErrorString*, const String16& gro
upName) const; | |
| 85 | |
| 86 PassOwnPtr<protocol::Runtime::ExceptionDetails> createExceptionDetails(v8::L
ocal<v8::Message>); | 79 PassOwnPtr<protocol::Runtime::ExceptionDetails> createExceptionDetails(v8::L
ocal<v8::Message>); |
| 87 void wrapEvaluateResult(ErrorString*, | 80 void wrapEvaluateResult(ErrorString*, |
| 88 v8::MaybeLocal<v8::Value> maybeResultValue, | 81 v8::MaybeLocal<v8::Value> maybeResultValue, |
| 89 const v8::TryCatch&, | 82 const v8::TryCatch&, |
| 90 const String16& objectGroup, | 83 const String16& objectGroup, |
| 91 bool returnByValue, | 84 bool returnByValue, |
| 92 bool generatePreview, | 85 bool generatePreview, |
| 93 OwnPtr<protocol::Runtime::RemoteObject>* result, | 86 OwnPtr<protocol::Runtime::RemoteObject>* result, |
| 94 Maybe<bool>* wasThrown, | 87 Maybe<bool>* wasThrown, |
| 95 Maybe<protocol::Runtime::ExceptionDetails>*); | 88 Maybe<protocol::Runtime::ExceptionDetails>*); |
| 96 | 89 |
| 97 class Scope { | 90 class Scope { |
| 98 public: | 91 public: |
| 99 bool initialize(); | 92 bool initialize(); |
| 100 void installGlobalObjectExtension(v8::MaybeLocal<v8::Object> extension); | 93 bool installCommandLineAPI(); |
| 94 bool installRemoteObjectAPI(const String16& objectGroupName); |
| 95 void ignoreExceptionsAndMuteConsole(); |
| 101 v8::Local<v8::Context> context() const { return m_context; } | 96 v8::Local<v8::Context> context() const { return m_context; } |
| 102 InjectedScript* injectedScript() const { return m_injectedScript; } | 97 InjectedScript* injectedScript() const { return m_injectedScript; } |
| 103 const v8::TryCatch& tryCatch() const { return m_tryCatch; } | 98 const v8::TryCatch& tryCatch() const { return m_tryCatch; } |
| 104 | 99 |
| 105 protected: | 100 protected: |
| 106 Scope(ErrorString*, V8DebuggerImpl*, int contextGroupId); | 101 Scope(ErrorString*, V8DebuggerImpl*, int contextGroupId); |
| 107 ~Scope(); | 102 ~Scope(); |
| 108 virtual void findInjectedScript(V8InspectorSessionImpl*) = 0; | 103 virtual void findInjectedScript(V8InspectorSessionImpl*) = 0; |
| 109 | 104 |
| 110 ErrorString* m_errorString; | 105 ErrorString* m_errorString; |
| 111 V8DebuggerImpl* m_debugger; | 106 V8DebuggerImpl* m_debugger; |
| 112 int m_contextGroupId; | 107 int m_contextGroupId; |
| 113 InjectedScript* m_injectedScript; | 108 InjectedScript* m_injectedScript; |
| 114 | 109 |
| 115 private: | 110 private: |
| 116 void cleanup(); | 111 void cleanup(); |
| 112 V8DebuggerImpl::PauseOnExceptionsState setPauseOnExceptionsState(V8Debug
gerImpl::PauseOnExceptionsState); |
| 113 bool installGlobalObjectExtension(V8FunctionCall&); |
| 117 | 114 |
| 118 v8::HandleScope m_handleScope; | 115 v8::HandleScope m_handleScope; |
| 119 v8::TryCatch m_tryCatch; | 116 v8::TryCatch m_tryCatch; |
| 120 v8::Local<v8::Context> m_context; | 117 v8::Local<v8::Context> m_context; |
| 121 v8::Local<v8::Symbol> m_extensionSymbol; | 118 v8::Local<v8::Symbol> m_extensionSymbol; |
| 122 v8::MaybeLocal<v8::Object> m_global; | 119 v8::MaybeLocal<v8::Object> m_global; |
| 120 bool m_ignoreExceptionsAndMuteConsole; |
| 121 V8DebuggerImpl::PauseOnExceptionsState m_previousPauseOnExceptionsState; |
| 123 }; | 122 }; |
| 124 | 123 |
| 125 class ContextScope: public Scope { | 124 class ContextScope: public Scope { |
| 126 PROTOCOL_DISALLOW_COPY(ContextScope); | 125 PROTOCOL_DISALLOW_COPY(ContextScope); |
| 127 public: | 126 public: |
| 128 ContextScope(ErrorString*, V8DebuggerImpl*, int contextGroupId, int exec
utionContextId); | 127 ContextScope(ErrorString*, V8DebuggerImpl*, int contextGroupId, int exec
utionContextId); |
| 129 ~ContextScope(); | 128 ~ContextScope(); |
| 130 private: | 129 private: |
| 131 void findInjectedScript(V8InspectorSessionImpl*) override; | 130 void findInjectedScript(V8InspectorSessionImpl*) override; |
| 132 int m_executionContextId; | 131 int m_executionContextId; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 153 ~CallFrameScope(); | 152 ~CallFrameScope(); |
| 154 size_t frameOrdinal() const { return m_frameOrdinal; } | 153 size_t frameOrdinal() const { return m_frameOrdinal; } |
| 155 private: | 154 private: |
| 156 void findInjectedScript(V8InspectorSessionImpl*) override; | 155 void findInjectedScript(V8InspectorSessionImpl*) override; |
| 157 String16 m_remoteCallFrameId; | 156 String16 m_remoteCallFrameId; |
| 158 size_t m_frameOrdinal; | 157 size_t m_frameOrdinal; |
| 159 }; | 158 }; |
| 160 | 159 |
| 161 private: | 160 private: |
| 162 InjectedScript(InspectedContext*, v8::Local<v8::Object>, PassOwnPtr<Injected
ScriptNative>); | 161 InjectedScript(InspectedContext*, v8::Local<v8::Object>, PassOwnPtr<Injected
ScriptNative>); |
| 163 | 162 bool canAccessInspectedWindow() const; |
| 163 bool setLastEvaluationResult(ErrorString*, v8::Local<v8::Value>); |
| 164 v8::Local<v8::Value> v8Value() const; | 164 v8::Local<v8::Value> v8Value() const; |
| 165 v8::MaybeLocal<v8::Value> wrapValue(ErrorString*, v8::Local<v8::Value>, cons
t String16& groupName, bool forceValueType, bool generatePreview) const; | 165 v8::MaybeLocal<v8::Value> wrapValue(ErrorString*, v8::Local<v8::Value>, cons
t String16& groupName, bool forceValueType, bool generatePreview) const; |
| 166 v8::MaybeLocal<v8::Object> callFunctionReturnObject(ErrorString*, V8Function
Call&) const; | |
| 167 | 166 |
| 168 InspectedContext* m_context; | 167 InspectedContext* m_context; |
| 169 v8::Global<v8::Value> m_value; | 168 v8::Global<v8::Value> m_value; |
| 170 OwnPtr<InjectedScriptNative> m_native; | 169 OwnPtr<InjectedScriptNative> m_native; |
| 171 }; | 170 }; |
| 172 | 171 |
| 173 } // namespace blink | 172 } // namespace blink |
| 174 | 173 |
| 175 #endif | 174 #endif |
| OLD | NEW |