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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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); | 49 setFunctionProperty(context, injectedScriptHost, "collectionEntries", V8Inje
ctedScriptHost::collectionEntriesCallback, debuggerExternal); |
50 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8
InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); | 50 setFunctionProperty(context, injectedScriptHost, "getInternalProperties", V8
InjectedScriptHost::getInternalPropertiesCallback, debuggerExternal); |
51 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun
ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE
xternal); | 51 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun
ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE
xternal); |
52 setFunctionProperty(context, injectedScriptHost, "setNonEnumProperty", V8Inj
ectedScriptHost::setNonEnumPropertyCallback, debuggerExternal); | |
53 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos
t::bindCallback, debuggerExternal); | 52 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos
t::bindCallback, debuggerExternal); |
54 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec
tedScriptHost::proxyTargetValueCallback, debuggerExternal); | 53 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec
tedScriptHost::proxyTargetValueCallback, debuggerExternal); |
55 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri
ptHost::prototypeCallback, debuggerExternal); | 54 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri
ptHost::prototypeCallback, debuggerExternal); |
56 return injectedScriptHost; | 55 return injectedScriptHost; |
57 } | 56 } |
58 | 57 |
59 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) | 58 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
60 { | 59 { |
61 if (info.Length() < 1 || !info[0]->IsObject()) | 60 if (info.Length() < 1 || !info[0]->IsObject()) |
62 return; | 61 return; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 client->muteWarningsAndDeprecations(); | 187 client->muteWarningsAndDeprecations(); |
189 | 188 |
190 v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrot
asks); | 189 v8::MicrotasksScope microtasks(isolate, v8::MicrotasksScope::kDoNotRunMicrot
asks); |
191 v8::Local<v8::Value> result; | 190 v8::Local<v8::Value> result; |
192 if (function->Call(context, receiver, argc, argv.get()).ToLocal(&result)) | 191 if (function->Call(context, receiver, argc, argv.get()).ToLocal(&result)) |
193 info.GetReturnValue().Set(result); | 192 info.GetReturnValue().Set(result); |
194 | 193 |
195 client->unmuteWarningsAndDeprecations(); | 194 client->unmuteWarningsAndDeprecations(); |
196 } | 195 } |
197 | 196 |
198 void V8InjectedScriptHost::setNonEnumPropertyCallback(const v8::FunctionCallback
Info<v8::Value>& info) | |
199 { | |
200 if (info.Length() < 3 || !info[0]->IsObject() || !info[1]->IsString()) | |
201 return; | |
202 | |
203 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | |
204 v8::Maybe<bool> success = object->DefineOwnProperty(info.GetIsolate()->GetCu
rrentContext(), info[1].As<v8::String>(), info[2], v8::DontEnum); | |
205 DCHECK(!success.IsNothing()); | |
206 } | |
207 | |
208 void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value
>& info) | 197 void V8InjectedScriptHost::bindCallback(const v8::FunctionCallbackInfo<v8::Value
>& info) |
209 { | 198 { |
210 if (info.Length() < 2 || !info[1]->IsString()) | 199 if (info.Length() < 2 || !info[1]->IsString()) |
211 return; | 200 return; |
212 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); | 201 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec
tedScriptHost(info.Holder()); |
213 if (!injectedScriptNative) | 202 if (!injectedScriptNative) |
214 return; | 203 return; |
215 | 204 |
216 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); | 205 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); |
217 String16 groupName = toProtocolStringWithTypeCheck(v8groupName); | 206 String16 groupName = toProtocolStringWithTypeCheck(v8groupName); |
(...skipping 18 matching lines...) Expand all Loading... |
236 DCHECK(info.Length() > 0 && info[0]->IsObject()); | 225 DCHECK(info.Length() > 0 && info[0]->IsObject()); |
237 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); | 226 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); |
238 } | 227 } |
239 | 228 |
240 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate) | 229 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate) |
241 { | 230 { |
242 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug
ger#scopeExtension")); | 231 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug
ger#scopeExtension")); |
243 } | 232 } |
244 | 233 |
245 } // namespace blink | 234 } // namespace blink |
OLD | NEW |