OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/v8_inspector/V8InjectedScriptHost.h" | 5 #include "platform/v8_inspector/V8InjectedScriptHost.h" |
6 | 6 |
7 #include "platform/inspector_protocol/String16.h" | 7 #include "platform/inspector_protocol/String16.h" |
8 #include "platform/v8_inspector/InjectedScriptNative.h" | 8 #include "platform/v8_inspector/InjectedScriptNative.h" |
9 #include "platform/v8_inspector/V8Compat.h" | 9 #include "platform/v8_inspector/V8Compat.h" |
10 #include "platform/v8_inspector/V8DebuggerImpl.h" | 10 #include "platform/v8_inspector/V8DebuggerImpl.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex
t, V8DebuggerImpl* debugger) | 40 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex
t, V8DebuggerImpl* debugger) |
41 { | 41 { |
42 v8::Isolate* isolate = debugger->isolate(); | 42 v8::Isolate* isolate = debugger->isolate(); |
43 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); | 43 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); |
44 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg
er); | 44 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg
er); |
45 setFunctionProperty(context, injectedScriptHost, "internalConstructorName",
V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal); | 45 setFunctionProperty(context, injectedScriptHost, "internalConstructorName",
V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal); |
46 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie
s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); | 46 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie
s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); |
47 setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedS
criptHost::isTypedArrayCallback, debuggerExternal); | 47 setFunctionProperty(context, injectedScriptHost, "isTypedArray", V8InjectedS
criptHost::isTypedArrayCallback, debuggerExternal); |
48 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript
Host::subtypeCallback, debuggerExternal); | 48 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript
Host::subtypeCallback, debuggerExternal); |
49 setFunctionProperty(context, injectedScriptHost, "collectionEntries", V8Inje
ctedScriptHost::collectionEntriesCallback, debuggerExternal); | |
50 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8
InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); | 49 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8
InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); |
51 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun
ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE
xternal); | 50 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun
ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE
xternal); |
52 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos
t::bindCallback, debuggerExternal); | 51 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos
t::bindCallback, debuggerExternal); |
53 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec
tedScriptHost::proxyTargetValueCallback, debuggerExternal); | 52 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec
tedScriptHost::proxyTargetValueCallback, debuggerExternal); |
54 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri
ptHost::prototypeCallback, debuggerExternal); | 53 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri
ptHost::prototypeCallback, debuggerExternal); |
55 return injectedScriptHost; | 54 return injectedScriptHost; |
56 } | 55 } |
57 | 56 |
58 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) | 57 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
59 { | 58 { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 info.GetReturnValue().Set(toV8StringInternalized(isolate, "proxy")); | 126 info.GetReturnValue().Set(toV8StringInternalized(isolate, "proxy")); |
128 return; | 127 return; |
129 } | 128 } |
130 String16 subtype = unwrapDebugger(info)->client()->valueSubtype(value); | 129 String16 subtype = unwrapDebugger(info)->client()->valueSubtype(value); |
131 if (!subtype.isEmpty()) { | 130 if (!subtype.isEmpty()) { |
132 info.GetReturnValue().Set(toV8String(isolate, subtype)); | 131 info.GetReturnValue().Set(toV8String(isolate, subtype)); |
133 return; | 132 return; |
134 } | 133 } |
135 } | 134 } |
136 | 135 |
137 void V8InjectedScriptHost::collectionEntriesCallback(const v8::FunctionCallbackI
nfo<v8::Value>& info) | |
138 { | |
139 if (info.Length() < 1 || !info[0]->IsObject()) | |
140 return; | |
141 | |
142 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | |
143 info.GetReturnValue().Set(unwrapDebugger(info)->collectionEntries(object)); | |
144 } | |
145 | |
146 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb
ackInfo<v8::Value>& info) | 136 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb
ackInfo<v8::Value>& info) |
147 { | 137 { |
148 if (info.Length() < 1 || !info[0]->IsObject()) | 138 if (info.Length() < 1) |
149 return; | 139 return; |
150 | |
151 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | |
152 v8::Local<v8::Array> properties; | 140 v8::Local<v8::Array> properties; |
153 if (v8::Debug::GetInternalProperties(info.GetIsolate(), object).ToLocal(&pro
perties)) | 141 if (unwrapDebugger(info)->internalProperties(info[0]).ToLocal(&properties)) |
154 info.GetReturnValue().Set(properties); | 142 info.GetReturnValue().Set(properties); |
155 } | 143 } |
156 | 144 |
157 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun
ctionCallbackInfo<v8::Value>& info) | 145 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun
ctionCallbackInfo<v8::Value>& info) |
158 { | 146 { |
159 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { | 147 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { |
160 NOTREACHED(); | 148 NOTREACHED(); |
161 return; | 149 return; |
162 } | 150 } |
163 if (info.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined())) { | 151 if (info.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined())) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 info.GetReturnValue().Set(target); | 208 info.GetReturnValue().Set(target); |
221 } | 209 } |
222 | 210 |
223 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) | 211 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) |
224 { | 212 { |
225 DCHECK(info.Length() > 0 && info[0]->IsObject()); | 213 DCHECK(info.Length() > 0 && info[0]->IsObject()); |
226 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); | 214 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); |
227 } | 215 } |
228 | 216 |
229 } // namespace blink | 217 } // namespace blink |
OLD | NEW |