| 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 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace | 39 } // namespace |
| 40 | 40 |
| 41 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex
t, V8DebuggerImpl* debugger) | 41 v8::Local<v8::Object> V8InjectedScriptHost::create(v8::Local<v8::Context> contex
t, V8DebuggerImpl* debugger) |
| 42 { | 42 { |
| 43 v8::Isolate* isolate = debugger->isolate(); | 43 v8::Isolate* isolate = debugger->isolate(); |
| 44 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); | 44 v8::Local<v8::Object> injectedScriptHost = v8::Object::New(isolate); |
| 45 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg
er); | 45 v8::Local<v8::External> debuggerExternal = v8::External::New(isolate, debugg
er); |
| 46 setFunctionProperty(context, injectedScriptHost, "internalConstructorName",
V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal); | 46 setFunctionProperty(context, injectedScriptHost, "internalConstructorName",
V8InjectedScriptHost::internalConstructorNameCallback, debuggerExternal); |
| 47 setFunctionProperty(context, injectedScriptHost, "formatAccessorsAsPropertie
s", V8InjectedScriptHost::formatAccessorsAsProperties, debuggerExternal); | |
| 48 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript
Host::subtypeCallback, debuggerExternal); | 47 setFunctionProperty(context, injectedScriptHost, "subtype", V8InjectedScript
Host::subtypeCallback, debuggerExternal); |
| 49 setFunctionProperty(context, injectedScriptHost, "collectionEntries", V8Inje
ctedScriptHost::collectionEntriesCallback, debuggerExternal); | 48 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, "getEventListeners", V8Inje
ctedScriptHost::getEventListenersCallback, debuggerExternal); | 50 setFunctionProperty(context, injectedScriptHost, "getEventListeners", V8Inje
ctedScriptHost::getEventListenersCallback, debuggerExternal); |
| 52 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun
ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE
xternal); | 51 setFunctionProperty(context, injectedScriptHost, "suppressWarningsAndCallFun
ction", V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback, debuggerE
xternal); |
| 53 setFunctionProperty(context, injectedScriptHost, "setNonEnumProperty", V8Inj
ectedScriptHost::setNonEnumPropertyCallback, debuggerExternal); | 52 setFunctionProperty(context, injectedScriptHost, "setNonEnumProperty", V8Inj
ectedScriptHost::setNonEnumPropertyCallback, debuggerExternal); |
| 54 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos
t::bindCallback, debuggerExternal); | 53 setFunctionProperty(context, injectedScriptHost, "bind", V8InjectedScriptHos
t::bindCallback, debuggerExternal); |
| 55 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec
tedScriptHost::proxyTargetValueCallback, debuggerExternal); | 54 setFunctionProperty(context, injectedScriptHost, "proxyTargetValue", V8Injec
tedScriptHost::proxyTargetValueCallback, debuggerExternal); |
| 56 setFunctionProperty(context, injectedScriptHost, "ownPropertyNames", V8Injec
tedScriptHost::ownPropertyNamesCallback, debuggerExternal); | 55 setFunctionProperty(context, injectedScriptHost, "ownPropertyNames", V8Injec
tedScriptHost::ownPropertyNamesCallback, debuggerExternal); |
| 57 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri
ptHost::prototypeCallback, debuggerExternal); | 56 setFunctionProperty(context, injectedScriptHost, "prototype", V8InjectedScri
ptHost::prototypeCallback, debuggerExternal); |
| 57 setFunctionProperty(context, injectedScriptHost, "hasFunctionSource", V8Inje
ctedScriptHost::hasFunctionSourceCallback, debuggerExternal); |
| 58 return injectedScriptHost; | 58 return injectedScriptHost; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) | 61 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
| 62 { | 62 { |
| 63 if (info.Length() < 1 || !info[0]->IsObject()) | 63 if (info.Length() < 1 || !info[0]->IsObject()) |
| 64 return; | 64 return; |
| 65 | 65 |
| 66 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | 66 v8::Local<v8::Object> object = info[0].As<v8::Object>(); |
| 67 info.GetReturnValue().Set(object->GetConstructorName()); | 67 info.GetReturnValue().Set(object->GetConstructorName()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac
kInfo<v8::Value>& info) | |
| 71 { | |
| 72 if (info.Length() < 1) | |
| 73 return; | |
| 74 | |
| 75 info.GetReturnValue().Set(unwrapDebugger(info)->client()->formatAccessorsAsP
roperties(info[0])); | |
| 76 } | |
| 77 | |
| 78 void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 70 void V8InjectedScriptHost::subtypeCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 79 { | 71 { |
| 80 if (info.Length() < 1) | 72 if (info.Length() < 1) |
| 81 return; | 73 return; |
| 82 | 74 |
| 83 v8::Isolate* isolate = info.GetIsolate(); | 75 v8::Isolate* isolate = info.GetIsolate(); |
| 84 v8::Local<v8::Value> value = info[0]; | 76 v8::Local<v8::Value> value = info[0]; |
| 85 if (value->IsArray() || value->IsTypedArray() || value->IsArgumentsObject())
{ | 77 if (value->IsArray() || value->IsTypedArray() || value->IsArgumentsObject())
{ |
| 86 info.GetReturnValue().Set(toV8StringInternalized(isolate, "array")); | 78 info.GetReturnValue().Set(toV8StringInternalized(isolate, "array")); |
| 87 return; | 79 return; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 313 } |
| 322 info.GetReturnValue().Set(output->AsArray()); | 314 info.GetReturnValue().Set(output->AsArray()); |
| 323 } | 315 } |
| 324 | 316 |
| 325 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) | 317 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) |
| 326 { | 318 { |
| 327 ASSERT(info.Length() > 0 && info[0]->IsObject()); | 319 ASSERT(info.Length() > 0 && info[0]->IsObject()); |
| 328 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); | 320 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); |
| 329 } | 321 } |
| 330 | 322 |
| 323 void V8InjectedScriptHost::hasFunctionSourceCallback(const v8::FunctionCallbackI
nfo<v8::Value>& info) |
| 324 { |
| 325 ASSERT(info.Length() > 0 && info[0]->IsFunction()); |
| 326 v8::Local<v8::Function> function = info[0].As<v8::Function>(); |
| 327 if (function->ScriptId() == v8::UnboundScript::kNoScriptId) { |
| 328 info.GetReturnValue().Set(false); |
| 329 return; |
| 330 } |
| 331 int lineNumber = function->GetScriptLineNumber(); |
| 332 int columnNumber = function->GetScriptColumnNumber(); |
| 333 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F
unction::kLineOffsetNotFound) { |
| 334 info.GetReturnValue().Set(false); |
| 335 return; |
| 336 } |
| 337 info.GetReturnValue().Set(true); |
| 338 } |
| 339 |
| 331 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate) | 340 v8::Local<v8::Private> V8Debugger::scopeExtensionPrivate(v8::Isolate* isolate) |
| 332 { | 341 { |
| 333 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug
ger#scopeExtension")); | 342 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Debug
ger#scopeExtension")); |
| 334 } | 343 } |
| 335 | 344 |
| 336 bool V8Debugger::isRemoteObjectAPIMethod(const String16& name) | 345 bool V8Debugger::isRemoteObjectAPIMethod(const String16& name) |
| 337 { | 346 { |
| 338 return name == "bindRemoteObject"; | 347 return name == "bindRemoteObject"; |
| 339 } | 348 } |
| 340 | 349 |
| 341 } // namespace blink | 350 } // namespace blink |
| OLD | NEW |