| 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 |
| 57 v8::Local<v8::Private> V8InjectedScriptHost::internalEntryPrivate(v8::Isolate* i
solate) |
| 58 { |
| 59 return v8::Private::ForApi(isolate, toV8StringInternalized(isolate, "V8Injec
tedScriptHost#internalEntry")); |
| 60 } |
| 61 |
| 58 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) | 62 void V8InjectedScriptHost::internalConstructorNameCallback(const v8::FunctionCal
lbackInfo<v8::Value>& info) |
| 59 { | 63 { |
| 60 if (info.Length() < 1 || !info[0]->IsObject()) | 64 if (info.Length() < 1 || !info[0]->IsObject()) |
| 61 return; | 65 return; |
| 62 | 66 |
| 63 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | 67 v8::Local<v8::Object> object = info[0].As<v8::Object>(); |
| 64 info.GetReturnValue().Set(object->GetConstructorName()); | 68 info.GetReturnValue().Set(object->GetConstructorName()); |
| 65 } | 69 } |
| 66 | 70 |
| 67 void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac
kInfo<v8::Value>& info) | 71 void V8InjectedScriptHost::formatAccessorsAsProperties(const v8::FunctionCallbac
kInfo<v8::Value>& info) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return; | 124 return; |
| 121 } | 125 } |
| 122 if (value->IsNativeError()) { | 126 if (value->IsNativeError()) { |
| 123 info.GetReturnValue().Set(toV8StringInternalized(isolate, "error")); | 127 info.GetReturnValue().Set(toV8StringInternalized(isolate, "error")); |
| 124 return; | 128 return; |
| 125 } | 129 } |
| 126 if (value->IsProxy()) { | 130 if (value->IsProxy()) { |
| 127 info.GetReturnValue().Set(toV8StringInternalized(isolate, "proxy")); | 131 info.GetReturnValue().Set(toV8StringInternalized(isolate, "proxy")); |
| 128 return; | 132 return; |
| 129 } | 133 } |
| 134 if (value->IsObject()) { |
| 135 v8::Local<v8::Object> obj = value.As<v8::Object>(); |
| 136 if (obj->HasPrivate(isolate->GetCurrentContext(), internalEntryPrivate(i
solate)).FromMaybe(false)) { |
| 137 info.GetReturnValue().Set(toV8StringInternalized(isolate, "internal#
entry")); |
| 138 return; |
| 139 } |
| 140 } |
| 130 String16 subtype = unwrapDebugger(info)->client()->valueSubtype(value); | 141 String16 subtype = unwrapDebugger(info)->client()->valueSubtype(value); |
| 131 if (!subtype.isEmpty()) { | 142 if (!subtype.isEmpty()) { |
| 132 info.GetReturnValue().Set(toV8String(isolate, subtype)); | 143 info.GetReturnValue().Set(toV8String(isolate, subtype)); |
| 133 return; | 144 return; |
| 134 } | 145 } |
| 135 } | 146 } |
| 136 | 147 |
| 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) | 148 void V8InjectedScriptHost::getInternalPropertiesCallback(const v8::FunctionCallb
ackInfo<v8::Value>& info) |
| 147 { | 149 { |
| 148 if (info.Length() < 1 || !info[0]->IsObject()) | 150 if (info.Length() < 1) |
| 149 return; | 151 return; |
| 150 | |
| 151 v8::Local<v8::Object> object = info[0].As<v8::Object>(); | |
| 152 v8::Local<v8::Array> properties; | 152 v8::Local<v8::Array> properties; |
| 153 if (v8::Debug::GetInternalProperties(info.GetIsolate(), object).ToLocal(&pro
perties)) | 153 if (unwrapDebugger(info)->internalProperties(info.GetIsolate()->GetCurrentCo
ntext(), info[0]).ToLocal(&properties)) |
| 154 info.GetReturnValue().Set(properties); | 154 info.GetReturnValue().Set(properties); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun
ctionCallbackInfo<v8::Value>& info) | 157 void V8InjectedScriptHost::suppressWarningsAndCallFunctionCallback(const v8::Fun
ctionCallbackInfo<v8::Value>& info) |
| 158 { | 158 { |
| 159 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { | 159 if (info.Length() < 2 || info.Length() > 3 || !info[0]->IsFunction()) { |
| 160 NOTREACHED(); | 160 NOTREACHED(); |
| 161 return; | 161 return; |
| 162 } | 162 } |
| 163 if (info.Length() > 2 && (!info[2]->IsArray() && !info[2]->IsUndefined())) { | 163 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); | 220 info.GetReturnValue().Set(target); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) | 223 void V8InjectedScriptHost::prototypeCallback(const v8::FunctionCallbackInfo<v8::
Value>& info) |
| 224 { | 224 { |
| 225 DCHECK(info.Length() > 0 && info[0]->IsObject()); | 225 DCHECK(info.Length() > 0 && info[0]->IsObject()); |
| 226 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); | 226 info.GetReturnValue().Set(info[0].As<v8::Object>()->GetPrototype()); |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace blink | 229 } // namespace blink |
| OLD | NEW |