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

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

Issue 2030453002: [DevTools] Support CommandLineAPI in workers and Node.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 findInjectedScript(session); 398 findInjectedScript(session);
399 if (!m_injectedScript) 399 if (!m_injectedScript)
400 return false; 400 return false;
401 m_context = m_injectedScript->context()->context(); 401 m_context = m_injectedScript->context()->context();
402 m_context->Enter(); 402 m_context->Enter();
403 return true; 403 return true;
404 } 404 }
405 405
406 bool InjectedScript::Scope::installCommandLineAPI() 406 bool InjectedScript::Scope::installCommandLineAPI()
407 { 407 {
408 DCHECK(m_injectedScript && !m_context.IsEmpty() && m_global.IsEmpty()); 408 DCHECK(m_injectedScript && !m_context.IsEmpty() && m_installedAPI.IsEmpty()) ;
409 m_extensionPrivate = V8Debugger::scopeExtensionPrivate(m_debugger->isolate() ); 409 m_installedAPI = V8Console::installCommandLineAPI(m_context, m_context->Glob al(), m_injectedScript->commandLineAPI());
410 v8::Local<v8::Object> global = m_context->Global();
411 if (!global->SetPrivate(m_context, m_extensionPrivate, m_injectedScript->com mandLineAPI()).FromMaybe(false)) {
412 *m_errorString = "Internal error";
413 return false;
414 }
415 m_global = global;
416 return true; 410 return true;
417 } 411 }
418 412
419 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole() 413 void InjectedScript::Scope::ignoreExceptionsAndMuteConsole()
420 { 414 {
421 DCHECK(!m_ignoreExceptionsAndMuteConsole); 415 DCHECK(!m_ignoreExceptionsAndMuteConsole);
422 m_ignoreExceptionsAndMuteConsole = true; 416 m_ignoreExceptionsAndMuteConsole = true;
423 m_debugger->client()->muteConsole(); 417 m_debugger->client()->muteConsole();
424 m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8DebuggerImpl: :DontPauseOnExceptions); 418 m_previousPauseOnExceptionsState = setPauseOnExceptionsState(V8DebuggerImpl: :DontPauseOnExceptions);
425 } 419 }
(...skipping 10 matching lines...) Expand all
436 430
437 void InjectedScript::Scope::pretendUserGesture() 431 void InjectedScript::Scope::pretendUserGesture()
438 { 432 {
439 DCHECK(!m_userGesture); 433 DCHECK(!m_userGesture);
440 m_userGesture = true; 434 m_userGesture = true;
441 m_debugger->client()->beginUserGesture(); 435 m_debugger->client()->beginUserGesture();
442 } 436 }
443 437
444 void InjectedScript::Scope::cleanup() 438 void InjectedScript::Scope::cleanup()
445 { 439 {
446 v8::Local<v8::Object> global; 440 v8::Local<v8::Object> installedAPI;
447 if (m_global.ToLocal(&global)) { 441 if (m_installedAPI.ToLocal(&installedAPI)) {
448 DCHECK(!m_context.IsEmpty()); 442 DCHECK(!m_context.IsEmpty());
449 global->DeletePrivate(m_context, m_extensionPrivate); 443 V8Console::clearCommandLineAPI(m_context, m_context->Global(), installed API);
450 m_global = v8::MaybeLocal<v8::Object>(); 444 m_installedAPI = v8::MaybeLocal<v8::Object>();
451 } 445 }
452 if (!m_context.IsEmpty()) { 446 if (!m_context.IsEmpty()) {
453 m_context->Exit(); 447 m_context->Exit();
454 m_context.Clear(); 448 m_context.Clear();
455 } 449 }
456 } 450 }
457 451
458 InjectedScript::Scope::~Scope() 452 InjectedScript::Scope::~Scope()
459 { 453 {
460 if (m_ignoreExceptionsAndMuteConsole) { 454 if (m_ignoreExceptionsAndMuteConsole) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session) 512 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl* session)
519 { 513 {
520 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err orString, m_remoteCallFrameId); 514 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err orString, m_remoteCallFrameId);
521 if (!remoteId) 515 if (!remoteId)
522 return; 516 return;
523 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); 517 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal());
524 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() ); 518 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get() );
525 } 519 }
526 520
527 } // namespace blink 521 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698