| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 | 33 |
| 34 #include "core/inspector/InjectedScript.h" | 34 #include "core/inspector/InjectedScript.h" |
| 35 | 35 |
| 36 #include "bindings/core/v8/ScriptFunctionCall.h" | 36 #include "bindings/core/v8/ScriptFunctionCall.h" |
| 37 #include "bindings/core/v8/V8Binding.h" | 37 #include "bindings/core/v8/V8Binding.h" |
| 38 #include "core/inspector/InjectedScriptHost.h" | 38 #include "core/inspector/InjectedScriptHost.h" |
| 39 #include "core/inspector/InspectorInstrumentation.h" | |
| 40 #include "core/inspector/InspectorTraceEvents.h" | 39 #include "core/inspector/InspectorTraceEvents.h" |
| 41 #include "core/inspector/JSONParser.h" | 40 #include "core/inspector/JSONParser.h" |
| 42 #include "core/inspector/RemoteObjectId.h" | 41 #include "core/inspector/RemoteObjectId.h" |
| 43 #include "platform/JSONValues.h" | 42 #include "platform/JSONValues.h" |
| 44 #include "wtf/text/WTFString.h" | 43 #include "wtf/text/WTFString.h" |
| 45 | 44 |
| 46 using blink::TypeBuilder::Array; | 45 using blink::TypeBuilder::Array; |
| 47 using blink::TypeBuilder::Debugger::CallFrame; | 46 using blink::TypeBuilder::Debugger::CallFrame; |
| 48 using blink::TypeBuilder::Debugger::CollectionEntry; | 47 using blink::TypeBuilder::Debugger::CollectionEntry; |
| 49 using blink::TypeBuilder::Debugger::FunctionDetails; | 48 using blink::TypeBuilder::Debugger::FunctionDetails; |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } | 436 } |
| 438 | 437 |
| 439 const ScriptValue& InjectedScript::injectedScriptObject() const | 438 const ScriptValue& InjectedScript::injectedScriptObject() const |
| 440 { | 439 { |
| 441 return m_injectedScriptObject; | 440 return m_injectedScriptObject; |
| 442 } | 441 } |
| 443 | 442 |
| 444 ScriptValue InjectedScript::callFunctionWithEvalEnabled(ScriptFunctionCall& func
tion, bool& hadException) const | 443 ScriptValue InjectedScript::callFunctionWithEvalEnabled(ScriptFunctionCall& func
tion, bool& hadException) const |
| 445 { | 444 { |
| 446 ASSERT(!isEmpty()); | 445 ASSERT(!isEmpty()); |
| 447 ExecutionContext* executionContext = m_injectedScriptObject.scriptState()->e
xecutionContext(); | |
| 448 ScriptState::Scope scope(m_injectedScriptObject.scriptState()); | |
| 449 v8::Local<v8::Function> functionObj = function.function(); | |
| 450 DevToolsFunctionInfo info(functionObj); | |
| 451 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willCallFu
nction(executionContext, info); | |
| 452 | 446 |
| 453 ScriptState* scriptState = m_injectedScriptObject.scriptState(); | 447 ScriptState* scriptState = m_injectedScriptObject.scriptState(); |
| 454 bool evalIsDisabled = false; | 448 ScriptState::Scope scope(scriptState); |
| 455 if (scriptState) { | 449 bool evalIsDisabled = !scriptState->evalEnabled(); |
| 456 evalIsDisabled = !scriptState->evalEnabled(); | 450 // Temporarily enable allow evals for inspector. |
| 457 // Temporarily enable allow evals for inspector. | 451 if (evalIsDisabled) |
| 458 if (evalIsDisabled) | 452 scriptState->setEvalEnabled(true); |
| 459 scriptState->setEvalEnabled(true); | |
| 460 } | |
| 461 | 453 |
| 462 ScriptValue resultValue = function.call(hadException); | 454 ScriptValue resultValue = function.call(hadException); |
| 463 | 455 |
| 464 if (evalIsDisabled) | 456 if (evalIsDisabled) |
| 465 scriptState->setEvalEnabled(false); | 457 scriptState->setEvalEnabled(false); |
| 466 | 458 |
| 467 InspectorInstrumentation::didCallFunction(cookie); | |
| 468 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); | 459 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); |
| 469 return resultValue; | 460 return resultValue; |
| 470 } | 461 } |
| 471 | 462 |
| 472 void InjectedScript::makeCall(ScriptFunctionCall& function, RefPtr<JSONValue>* r
esult) | 463 void InjectedScript::makeCall(ScriptFunctionCall& function, RefPtr<JSONValue>* r
esult) |
| 473 { | 464 { |
| 474 if (isEmpty() || !canAccessInspectedWindow()) { | 465 if (isEmpty() || !canAccessInspectedWindow()) { |
| 475 *result = JSONValue::null(); | 466 *result = JSONValue::null(); |
| 476 return; | 467 return; |
| 477 } | 468 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 String text = !message.IsEmpty() ? toCoreStringWithUndefinedOrNullCheck(
message->Get()) : "Internal error"; | 523 String text = !message.IsEmpty() ? toCoreStringWithUndefinedOrNullCheck(
message->Get()) : "Internal error"; |
| 533 *exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().se
tText(text); | 524 *exceptionDetails = TypeBuilder::Debugger::ExceptionDetails::create().se
tText(text); |
| 534 } else { | 525 } else { |
| 535 *result = toJSONValue(resultValue); | 526 *result = toJSONValue(resultValue); |
| 536 if (!*result) | 527 if (!*result) |
| 537 *result = JSONString::create(String::format("Object has too long ref
erence chain(must not be longer than %d)", JSONValue::maxDepth)); | 528 *result = JSONString::create(String::format("Object has too long ref
erence chain(must not be longer than %d)", JSONValue::maxDepth)); |
| 538 } | 529 } |
| 539 } | 530 } |
| 540 | 531 |
| 541 } // namespace blink | 532 } // namespace blink |
| 542 | |
| OLD | NEW |