OLD | NEW |
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 383 |
384 InjectedScript::Scope::Scope(ErrorString* errorString, V8DebuggerImpl* debugger,
int contextGroupId) | 384 InjectedScript::Scope::Scope(ErrorString* errorString, V8DebuggerImpl* debugger,
int contextGroupId) |
385 : m_errorString(errorString) | 385 : m_errorString(errorString) |
386 , m_debugger(debugger) | 386 , m_debugger(debugger) |
387 , m_contextGroupId(contextGroupId) | 387 , m_contextGroupId(contextGroupId) |
388 , m_injectedScript(nullptr) | 388 , m_injectedScript(nullptr) |
389 , m_handleScope(debugger->isolate()) | 389 , m_handleScope(debugger->isolate()) |
390 , m_tryCatch(debugger->isolate()) | 390 , m_tryCatch(debugger->isolate()) |
391 , m_ignoreExceptionsAndMuteConsole(false) | 391 , m_ignoreExceptionsAndMuteConsole(false) |
392 , m_previousPauseOnExceptionsState(V8DebuggerImpl::DontPauseOnExceptions) | 392 , m_previousPauseOnExceptionsState(V8DebuggerImpl::DontPauseOnExceptions) |
| 393 , m_userGesture(false) |
393 { | 394 { |
394 } | 395 } |
395 | 396 |
396 bool InjectedScript::Scope::initialize() | 397 bool InjectedScript::Scope::initialize() |
397 { | 398 { |
398 cleanup(); | 399 cleanup(); |
399 // TODO(dgozman): what if we reattach to the same context group during evalu
ate? Introduce a session id? | 400 // TODO(dgozman): what if we reattach to the same context group during evalu
ate? Introduce a session id? |
400 V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_conte
xtGroupId); | 401 V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_conte
xtGroupId); |
401 if (!session) { | 402 if (!session) { |
402 *m_errorString = "Internal error"; | 403 *m_errorString = "Internal error"; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 V8DebuggerImpl::PauseOnExceptionsState InjectedScript::Scope::setPauseOnExceptio
nsState(V8DebuggerImpl::PauseOnExceptionsState newState) | 459 V8DebuggerImpl::PauseOnExceptionsState InjectedScript::Scope::setPauseOnExceptio
nsState(V8DebuggerImpl::PauseOnExceptionsState newState) |
459 { | 460 { |
460 if (!m_debugger->enabled()) | 461 if (!m_debugger->enabled()) |
461 return newState; | 462 return newState; |
462 V8DebuggerImpl::PauseOnExceptionsState presentState = m_debugger->getPauseOn
ExceptionsState(); | 463 V8DebuggerImpl::PauseOnExceptionsState presentState = m_debugger->getPauseOn
ExceptionsState(); |
463 if (presentState != newState) | 464 if (presentState != newState) |
464 m_debugger->setPauseOnExceptionsState(newState); | 465 m_debugger->setPauseOnExceptionsState(newState); |
465 return presentState; | 466 return presentState; |
466 } | 467 } |
467 | 468 |
| 469 void InjectedScript::Scope::pretendUserGesture() |
| 470 { |
| 471 ASSERT(!m_userGesture); |
| 472 m_userGesture = true; |
| 473 m_debugger->client()->beginUserGesture(); |
| 474 } |
| 475 |
468 void InjectedScript::Scope::cleanup() | 476 void InjectedScript::Scope::cleanup() |
469 { | 477 { |
470 v8::Local<v8::Object> global; | 478 v8::Local<v8::Object> global; |
471 if (m_global.ToLocal(&global)) { | 479 if (m_global.ToLocal(&global)) { |
472 ASSERT(!m_context.IsEmpty()); | 480 ASSERT(!m_context.IsEmpty()); |
473 global->DeletePrivate(m_context, m_extensionPrivate); | 481 global->DeletePrivate(m_context, m_extensionPrivate); |
474 m_global = v8::MaybeLocal<v8::Object>(); | 482 m_global = v8::MaybeLocal<v8::Object>(); |
475 } | 483 } |
476 if (!m_context.IsEmpty()) { | 484 if (!m_context.IsEmpty()) { |
477 m_context->Exit(); | 485 m_context->Exit(); |
478 m_context.Clear(); | 486 m_context.Clear(); |
479 } | 487 } |
480 } | 488 } |
481 | 489 |
482 InjectedScript::Scope::~Scope() | 490 InjectedScript::Scope::~Scope() |
483 { | 491 { |
484 if (m_ignoreExceptionsAndMuteConsole) { | 492 if (m_ignoreExceptionsAndMuteConsole) { |
485 setPauseOnExceptionsState(m_previousPauseOnExceptionsState); | 493 setPauseOnExceptionsState(m_previousPauseOnExceptionsState); |
486 m_debugger->client()->unmuteConsole(); | 494 m_debugger->client()->unmuteConsole(); |
487 } | 495 } |
| 496 if (m_userGesture) |
| 497 m_debugger->client()->endUserGesture(); |
488 cleanup(); | 498 cleanup(); |
489 } | 499 } |
490 | 500 |
491 InjectedScript::ContextScope::ContextScope(ErrorString* errorString, V8DebuggerI
mpl* debugger, int contextGroupId, int executionContextId) | 501 InjectedScript::ContextScope::ContextScope(ErrorString* errorString, V8DebuggerI
mpl* debugger, int contextGroupId, int executionContextId) |
492 : InjectedScript::Scope(errorString, debugger, contextGroupId) | 502 : InjectedScript::Scope(errorString, debugger, contextGroupId) |
493 , m_executionContextId(executionContextId) | 503 , m_executionContextId(executionContextId) |
494 { | 504 { |
495 } | 505 } |
496 | 506 |
497 InjectedScript::ContextScope::~ContextScope() | 507 InjectedScript::ContextScope::~ContextScope() |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) | 550 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) |
541 { | 551 { |
542 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString,
m_remoteCallFrameId); | 552 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_errorString,
m_remoteCallFrameId); |
543 if (!remoteId) | 553 if (!remoteId) |
544 return; | 554 return; |
545 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 555 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
546 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); | 556 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); |
547 } | 557 } |
548 | 558 |
549 } // namespace blink | 559 } // namespace blink |
OLD | NEW |