Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8InjectedScriptHost.cpp

Issue 1823883002: [DevTools] Removed InjectedScriptHost.eval and InjectedScriptHost.objectForId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-get-collection-entries
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 #include "platform/v8_inspector/InjectedScript.h" 9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InjectedScriptHost.h" 10 #include "platform/v8_inspector/InjectedScriptHost.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void V8InjectedScriptHost::inspectCallback(const v8::FunctionCallbackInfo<v8::Va lue>& info) 213 void V8InjectedScriptHost::inspectCallback(const v8::FunctionCallbackInfo<v8::Va lue>& info)
214 { 214 {
215 if (info.Length() < 2) 215 if (info.Length() < 2)
216 return; 216 return;
217 217
218 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); 218 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
219 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(context, info.Holder ()); 219 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(context, info.Holder ());
220 host->inspectImpl(toProtocolValue(context, info[0]), toProtocolValue(context , info[1])); 220 host->inspectImpl(toProtocolValue(context, info[0]), toProtocolValue(context , info[1]));
221 } 221 }
222 222
223 void V8InjectedScriptHost::evalCallback(const v8::FunctionCallbackInfo<v8::Value >& info)
224 {
225 v8::Isolate* isolate = info.GetIsolate();
226 if (info.Length() < 1) {
227 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "One argument expected.")));
228 return;
229 }
230
231 v8::Local<v8::String> expression = info[0]->ToString(isolate);
232 if (expression.IsEmpty()) {
233 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string.")));
234 return;
235 }
236
237 ASSERT(isolate->InContext());
238 v8::TryCatch tryCatch(isolate);
239 v8::Local<v8::Value> result;
240 InjectedScriptHost* host = V8InjectedScriptHost::unwrap(isolate->GetCurrentC ontext(), info.Holder());
241 if (!host->debugger())
242 return;
243 if (!host->debugger()->compileAndRunInternalScript(isolate->GetCurrentContex t(), expression).ToLocal(&result)) {
244 v8SetReturnValue(info, tryCatch.ReThrow());
245 return;
246 }
247 v8SetReturnValue(info, result);
248 }
249
250 static bool getFunctionLocation(const v8::FunctionCallbackInfo<v8::Value>& info, String16* scriptId, int* lineNumber, int* columnNumber) 223 static bool getFunctionLocation(const v8::FunctionCallbackInfo<v8::Value>& info, String16* scriptId, int* lineNumber, int* columnNumber)
251 { 224 {
252 if (info.Length() < 1 || !info[0]->IsFunction()) 225 if (info.Length() < 1 || !info[0]->IsFunction())
253 return false; 226 return false;
254 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]); 227 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(info[0]);
255 *lineNumber = function->GetScriptLineNumber(); 228 *lineNumber = function->GetScriptLineNumber();
256 *columnNumber = function->GetScriptColumnNumber(); 229 *columnNumber = function->GetScriptColumnNumber();
257 if (*lineNumber == v8::Function::kLineOffsetNotFound || *columnNumber == v8: :Function::kLineOffsetNotFound) 230 if (*lineNumber == v8::Function::kLineOffsetNotFound || *columnNumber == v8: :Function::kLineOffsetNotFound)
258 return false; 231 return false;
259 *scriptId = String16::number(function->ScriptId()); 232 *scriptId = String16::number(function->ScriptId());
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder()); 350 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder());
378 if (!injectedScriptNative) 351 if (!injectedScriptNative)
379 return; 352 return;
380 353
381 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); 354 v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate());
382 String16 groupName = toProtocolStringWithTypeCheck(v8groupName); 355 String16 groupName = toProtocolStringWithTypeCheck(v8groupName);
383 int id = injectedScriptNative->bind(info[0], groupName); 356 int id = injectedScriptNative->bind(info[0], groupName);
384 info.GetReturnValue().Set(id); 357 info.GetReturnValue().Set(id);
385 } 358 }
386 359
387 void V8InjectedScriptHost::objectForIdCallback(const v8::FunctionCallbackInfo<v8 ::Value>& info)
388 {
389 if (info.Length() < 1 || !info[0]->IsInt32())
390 return;
391 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder());
392 if (!injectedScriptNative)
393 return;
394 int id = info[0].As<v8::Int32>()->Value();
395 v8::Local<v8::Value> value = injectedScriptNative->objectForId(id);
396 if (!value.IsEmpty())
397 info.GetReturnValue().Set(value);
398 }
399
400 void V8InjectedScriptHost::idToObjectGroupNameCallback(const v8::FunctionCallbac kInfo<v8::Value>& info)
401 {
402 if (info.Length() < 1 || !info[0]->IsInt32())
403 return;
404 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder());
405 if (!injectedScriptNative)
406 return;
407 int id = info[0].As<v8::Int32>()->Value();
408 String16 groupName = injectedScriptNative->groupName(id);
409 if (!groupName.isEmpty())
410 info.GetReturnValue().Set(toV8String(info.GetIsolate(), groupName));
411 }
412
413 v8::Local<v8::Symbol> V8Debugger::scopeExtensionSymbol(v8::Isolate* isolate) 360 v8::Local<v8::Symbol> V8Debugger::scopeExtensionSymbol(v8::Isolate* isolate)
414 { 361 {
415 return v8::Symbol::ForApi(isolate, toV8StringInternalized(isolate, "scopeExt ension")); 362 return v8::Symbol::ForApi(isolate, toV8StringInternalized(isolate, "scopeExt ension"));
416 } 363 }
417 364
418 bool V8Debugger::isCommandLineAPIMethod(const String16& name) 365 bool V8Debugger::isCommandLineAPIMethod(const String16& name)
419 { 366 {
420 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, methods, ()); 367 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, methods, ());
421 if (methods.size() == 0) { 368 if (methods.size() == 0) {
422 const char* members[] = { "$", "$$", "$x", "dir", "dirxml", "keys", "val ues", "profile", "profileEnd", 369 const char* members[] = { "$", "$$", "$x", "dir", "dirxml", "keys", "val ues", "profile", "profileEnd",
(...skipping 26 matching lines...) Expand all
449 {"clearConsoleMessages", V8InjectedScriptHost::clearConsoleMessagesCallback} , 396 {"clearConsoleMessages", V8InjectedScriptHost::clearConsoleMessagesCallback} ,
450 {"inspect", V8InjectedScriptHost::inspectCallback}, 397 {"inspect", V8InjectedScriptHost::inspectCallback},
451 {"inspectedObject", V8InjectedScriptHost::inspectedObjectCallback}, 398 {"inspectedObject", V8InjectedScriptHost::inspectedObjectCallback},
452 {"internalConstructorName", V8InjectedScriptHost::internalConstructorNameCal lback}, 399 {"internalConstructorName", V8InjectedScriptHost::internalConstructorNameCal lback},
453 {"formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsPrope rties}, 400 {"formatAccessorsAsProperties", V8InjectedScriptHost::formatAccessorsAsPrope rties},
454 {"isTypedArray", V8InjectedScriptHost::isTypedArrayCallback}, 401 {"isTypedArray", V8InjectedScriptHost::isTypedArrayCallback},
455 {"subtype", V8InjectedScriptHost::subtypeCallback}, 402 {"subtype", V8InjectedScriptHost::subtypeCallback},
456 {"collectionEntries", V8InjectedScriptHost::collectionEntriesCallback}, 403 {"collectionEntries", V8InjectedScriptHost::collectionEntriesCallback},
457 {"getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallbac k}, 404 {"getInternalProperties", V8InjectedScriptHost::getInternalPropertiesCallbac k},
458 {"getEventListeners", V8InjectedScriptHost::getEventListenersCallback}, 405 {"getEventListeners", V8InjectedScriptHost::getEventListenersCallback},
459 {"eval", V8InjectedScriptHost::evalCallback},
460 {"debugFunction", V8InjectedScriptHost::debugFunctionCallback}, 406 {"debugFunction", V8InjectedScriptHost::debugFunctionCallback},
461 {"undebugFunction", V8InjectedScriptHost::undebugFunctionCallback}, 407 {"undebugFunction", V8InjectedScriptHost::undebugFunctionCallback},
462 {"monitorFunction", V8InjectedScriptHost::monitorFunctionCallback}, 408 {"monitorFunction", V8InjectedScriptHost::monitorFunctionCallback},
463 {"unmonitorFunction", V8InjectedScriptHost::unmonitorFunctionCallback}, 409 {"unmonitorFunction", V8InjectedScriptHost::unmonitorFunctionCallback},
464 {"callFunction", V8InjectedScriptHost::callFunctionCallback}, 410 {"callFunction", V8InjectedScriptHost::callFunctionCallback},
465 {"suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAn dCallFunctionCallback}, 411 {"suppressWarningsAndCallFunction", V8InjectedScriptHost::suppressWarningsAn dCallFunctionCallback},
466 {"setNonEnumProperty", V8InjectedScriptHost::setNonEnumPropertyCallback}, 412 {"setNonEnumProperty", V8InjectedScriptHost::setNonEnumPropertyCallback},
467 {"bind", V8InjectedScriptHost::bindCallback}, 413 {"bind", V8InjectedScriptHost::bindCallback}
468 {"objectForId", V8InjectedScriptHost::objectForIdCallback},
469 {"idToObjectGroupName", V8InjectedScriptHost::idToObjectGroupNameCallback},
470 }; 414 };
471 415
472 } // namespace 416 } // namespace
473 417
474 v8::Local<v8::FunctionTemplate> V8InjectedScriptHost::createWrapperTemplate(v8:: Isolate* isolate) 418 v8::Local<v8::FunctionTemplate> V8InjectedScriptHost::createWrapperTemplate(v8:: Isolate* isolate)
475 { 419 {
476 protocol::Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_AR RAY_LENGTH(V8InjectedScriptHostMethods)); 420 protocol::Vector<InspectorWrapperBase::V8MethodConfiguration> methods(WTF_AR RAY_LENGTH(V8InjectedScriptHostMethods));
477 std::copy(V8InjectedScriptHostMethods, V8InjectedScriptHostMethods + WTF_ARR AY_LENGTH(V8InjectedScriptHostMethods), methods.begin()); 421 std::copy(V8InjectedScriptHostMethods, V8InjectedScriptHostMethods + WTF_ARR AY_LENGTH(V8InjectedScriptHostMethods), methods.begin());
478 protocol::Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes; 422 protocol::Vector<InspectorWrapperBase::V8AttributeConfiguration> attributes;
479 return InjectedScriptHostWrapper::createWrapperTemplate(isolate, methods, at tributes); 423 return InjectedScriptHostWrapper::createWrapperTemplate(isolate, methods, at tributes);
480 } 424 }
481 425
482 v8::Local<v8::Object> V8InjectedScriptHost::wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, InjectedScriptHost* host) 426 v8::Local<v8::Object> V8InjectedScriptHost::wrap(v8::Local<v8::FunctionTemplate> constructorTemplate, v8::Local<v8::Context> context, InjectedScriptHost* host)
483 { 427 {
484 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host); 428 return InjectedScriptHostWrapper::wrap(constructorTemplate, context, host);
485 } 429 }
486 430
487 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object) 431 InjectedScriptHost* V8InjectedScriptHost::unwrap(v8::Local<v8::Context> context, v8::Local<v8::Object> object)
488 { 432 {
489 return InjectedScriptHostWrapper::unwrap(context, object); 433 return InjectedScriptHostWrapper::unwrap(context, object);
490 } 434 }
491 435
492 } // namespace blink 436 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698