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

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

Issue 1917733002: [DevTools] Move part of CommandLineAPI to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 21 matching lines...) Expand all
32 32
33 #include "platform/inspector_protocol/Parser.h" 33 #include "platform/inspector_protocol/Parser.h"
34 #include "platform/inspector_protocol/String16.h" 34 #include "platform/inspector_protocol/String16.h"
35 #include "platform/inspector_protocol/Values.h" 35 #include "platform/inspector_protocol/Values.h"
36 #include "platform/v8_inspector/InjectedScriptHost.h" 36 #include "platform/v8_inspector/InjectedScriptHost.h"
37 #include "platform/v8_inspector/InjectedScriptNative.h" 37 #include "platform/v8_inspector/InjectedScriptNative.h"
38 #include "platform/v8_inspector/InjectedScriptSource.h" 38 #include "platform/v8_inspector/InjectedScriptSource.h"
39 #include "platform/v8_inspector/InspectedContext.h" 39 #include "platform/v8_inspector/InspectedContext.h"
40 #include "platform/v8_inspector/RemoteObjectId.h" 40 #include "platform/v8_inspector/RemoteObjectId.h"
41 #include "platform/v8_inspector/V8Compat.h" 41 #include "platform/v8_inspector/V8Compat.h"
42 #include "platform/v8_inspector/V8Console.h"
42 #include "platform/v8_inspector/V8DebuggerImpl.h" 43 #include "platform/v8_inspector/V8DebuggerImpl.h"
43 #include "platform/v8_inspector/V8FunctionCall.h" 44 #include "platform/v8_inspector/V8FunctionCall.h"
44 #include "platform/v8_inspector/V8InjectedScriptHost.h" 45 #include "platform/v8_inspector/V8InjectedScriptHost.h"
45 #include "platform/v8_inspector/V8InspectorSessionImpl.h" 46 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
46 #include "platform/v8_inspector/V8StackTraceImpl.h" 47 #include "platform/v8_inspector/V8StackTraceImpl.h"
47 #include "platform/v8_inspector/V8StringUtil.h" 48 #include "platform/v8_inspector/V8StringUtil.h"
48 #include "platform/v8_inspector/public/V8Debugger.h" 49 #include "platform/v8_inspector/public/V8Debugger.h"
49 #include "platform/v8_inspector/public/V8DebuggerClient.h" 50 #include "platform/v8_inspector/public/V8DebuggerClient.h"
50 #include "platform/v8_inspector/public/V8ToProtocolValue.h" 51 #include "platform/v8_inspector/public/V8ToProtocolValue.h"
51 52
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (!m_injectedScript) 403 if (!m_injectedScript)
403 return false; 404 return false;
404 m_context = m_injectedScript->context()->context(); 405 m_context = m_injectedScript->context()->context();
405 m_context->Enter(); 406 m_context->Enter();
406 return true; 407 return true;
407 } 408 }
408 409
409 bool InjectedScript::Scope::installCommandLineAPI() 410 bool InjectedScript::Scope::installCommandLineAPI()
410 { 411 {
411 ASSERT(m_injectedScript && !m_context.IsEmpty()); 412 ASSERT(m_injectedScript && !m_context.IsEmpty());
412 V8FunctionCall function(m_debugger, m_context, m_injectedScript->v8Value(), "commandLineAPI"); 413 V8FunctionCall function(m_debugger, m_context, m_injectedScript->v8Value(), "installCommandLineAPI");
414 function.appendArgument(V8Console::createCommandLineAPI(m_context, m_injecte dScript->context()));
dgozman 2016/04/25 18:09:50 InspectedContext is enough to pass.
kozy 2016/04/25 19:31:06 Done.
413 v8::Local<v8::Object> extensionObject; 415 v8::Local<v8::Object> extensionObject;
414 if (!installGlobalObjectExtension(function).ToLocal(&extensionObject)) 416 if (!installGlobalObjectExtension(function).ToLocal(&extensionObject))
415 return false; 417 return false;
416 return extensionObject->Set(m_context, toV8StringInternalized(m_context->Get Isolate(), "$_"), m_injectedScript->lastEvaluationResult()).FromMaybe(false); 418 return extensionObject->Set(m_context, toV8StringInternalized(m_context->Get Isolate(), "$_"), m_injectedScript->lastEvaluationResult()).FromMaybe(false);
417 } 419 }
418 420
419 bool InjectedScript::Scope::installRemoteObjectAPI(const String16& objectGroupNa me) 421 bool InjectedScript::Scope::installRemoteObjectAPI(const String16& objectGroupNa me)
420 { 422 {
421 ASSERT(m_injectedScript && !m_context.IsEmpty()); 423 ASSERT(m_injectedScript && !m_context.IsEmpty());
422 V8FunctionCall function(m_debugger, m_context, m_injectedScript->v8Value(), "remoteObjectAPI"); 424 V8FunctionCall function(m_debugger, m_context, m_injectedScript->v8Value(), "remoteObjectAPI");
423 function.appendArgument(objectGroupName); 425 function.appendArgument(objectGroupName);
424 v8::Local<v8::Object> extensionObject; 426 v8::Local<v8::Object> extensionObject;
425 return installGlobalObjectExtension(function).ToLocal(&extensionObject); 427 return installGlobalObjectExtension(function).ToLocal(&extensionObject);
426 } 428 }
427 429
428 v8::MaybeLocal<v8::Object> InjectedScript::Scope::installGlobalObjectExtension(V 8FunctionCall& function) 430 v8::MaybeLocal<v8::Object> InjectedScript::Scope::installGlobalObjectExtension(V 8FunctionCall& function)
429 { 431 {
430 bool hadException = false; 432 bool hadException = false;
431 v8::Local<v8::Value> extension = function.call(hadException, false); 433 v8::Local<v8::Value> extension = function.call(hadException, false);
432 if (hadException || extension.IsEmpty() || !extension->IsObject()) { 434 if (hadException || extension.IsEmpty() || !extension->IsObject()) {
433 *m_errorString = "Internal error"; 435 *m_errorString = "Internal error";
434 return v8::MaybeLocal<v8::Object>(); 436 return v8::MaybeLocal<v8::Object>();
435 } 437 }
436 438
437 ASSERT(m_global.IsEmpty()); 439 ASSERT(m_global.IsEmpty());
438 m_extensionSymbol = V8Debugger::scopeExtensionSymbol(m_debugger->isolate()); 440 m_extensionPrivate = V8Debugger::scopeExtensionPrivate(m_debugger->isolate() );
439 v8::Local<v8::Object> global = m_context->Global(); 441 v8::Local<v8::Object> global = m_context->Global();
440 if (!global->Set(m_context, m_extensionSymbol, extension).FromMaybe(false)) { 442 if (!global->SetPrivate(m_context, m_extensionPrivate, extension).FromMaybe( false)) {
441 *m_errorString = "Internal error"; 443 *m_errorString = "Internal error";
442 return v8::MaybeLocal<v8::Object>(); 444 return v8::MaybeLocal<v8::Object>();
443 } 445 }
444 446
445 m_global = global; 447 m_global = global;
446 return extension.As<v8::Object>(); 448 return extension.As<v8::Object>();
447 } 449 }
448 450
449 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() 451 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole()
450 { 452 {
(...skipping 11 matching lines...) Expand all
462 if (presentState != newState) 464 if (presentState != newState)
463 m_debugger->setPauseOnExceptionsState(newState); 465 m_debugger->setPauseOnExceptionsState(newState);
464 return presentState; 466 return presentState;
465 } 467 }
466 468
467 void InjectedScript::Scope::cleanup() 469 void InjectedScript::Scope::cleanup()
468 { 470 {
469 v8::Local<v8::Object> global; 471 v8::Local<v8::Object> global;
470 if (m_global.ToLocal(&global)) { 472 if (m_global.ToLocal(&global)) {
471 ASSERT(!m_context.IsEmpty()); 473 ASSERT(!m_context.IsEmpty());
472 global->Delete(m_context, m_extensionSymbol); 474 global->DeletePrivate(m_context, m_extensionPrivate);
473 m_global = v8::MaybeLocal<v8::Object>(); 475 m_global = v8::MaybeLocal<v8::Object>();
474 } 476 }
475 if (!m_context.IsEmpty()) { 477 if (!m_context.IsEmpty()) {
476 m_context->Exit(); 478 m_context->Exit();
477 m_context.Clear(); 479 m_context.Clear();
478 } 480 }
479 } 481 }
480 482
481 InjectedScript::Scope::~Scope() 483 InjectedScript::Scope::~Scope()
482 { 484 {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session) 541 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session)
540 { 542 {
541 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId); 543 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString, m_remoteCallFrameId);
542 if (!remoteId) 544 if (!remoteId)
543 return; 545 return;
544 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); 546 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
545 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() ); 547 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() );
546 } 548 }
547 549
548 } // namespace blink 550 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698