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

Side by Side Diff: Source/core/inspector/V8DebuggerAgent.cpp

Issue 1238103002: [DevTools] Do not report edited resources via Page.getResourceContent. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Nuked concatenated, fixed comments Created 5 years, 4 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "core/inspector/V8DebuggerAgent.h" 6 #include "core/inspector/V8DebuggerAgent.h"
7 7
8 #include "bindings/core/v8/ScriptCallStackFactory.h" 8 #include "bindings/core/v8/ScriptCallStackFactory.h"
9 #include "bindings/core/v8/ScriptRegexp.h" 9 #include "bindings/core/v8/ScriptRegexp.h"
10 #include "bindings/core/v8/ScriptValue.h" 10 #include "bindings/core/v8/ScriptValue.h"
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 return; 578 return;
579 if (!debugger().setScriptSource(scriptId, newContent, asBool(preview), error , errorData, &m_currentCallStack, stackChanged)) 579 if (!debugger().setScriptSource(scriptId, newContent, asBool(preview), error , errorData, &m_currentCallStack, stackChanged))
580 return; 580 return;
581 581
582 newCallFrames = currentCallFrames(); 582 newCallFrames = currentCallFrames();
583 asyncStackTrace = currentAsyncStackTrace(); 583 asyncStackTrace = currentAsyncStackTrace();
584 584
585 ScriptsMap::iterator it = m_scripts.find(scriptId); 585 ScriptsMap::iterator it = m_scripts.find(scriptId);
586 if (it == m_scripts.end()) 586 if (it == m_scripts.end())
587 return; 587 return;
588 String url = it->value.url(); 588 it->value.setSource(newContent);
589 if (url.isEmpty())
590 return;
591 m_editedScripts.set(url, newContent);
592 } 589 }
593 590
594 void V8DebuggerAgent::restartFrame(ErrorString* errorString, const String& callF rameId, RefPtr<Array<CallFrame>>& newCallFrames, RefPtr<StackTrace>& asyncStackT race) 591 void V8DebuggerAgent::restartFrame(ErrorString* errorString, const String& callF rameId, RefPtr<Array<CallFrame>>& newCallFrames, RefPtr<StackTrace>& asyncStackT race)
595 { 592 {
596 if (!isPaused() || m_currentCallStack.IsEmpty()) { 593 if (!isPaused() || m_currentCallStack.IsEmpty()) {
597 *errorString = "Attempt to access callframe when debugger is not on paus e"; 594 *errorString = "Attempt to access callframe when debugger is not on paus e";
598 return; 595 return;
599 } 596 }
600 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId); 597 OwnPtr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(callFrameId);
601 if (!remoteId) { 598 if (!remoteId) {
(...skipping 16 matching lines...) Expand all
618 615
619 void V8DebuggerAgent::getScriptSource(ErrorString* error, const String& scriptId , String* scriptSource) 616 void V8DebuggerAgent::getScriptSource(ErrorString* error, const String& scriptId , String* scriptSource)
620 { 617 {
621 if (!checkEnabled(error)) 618 if (!checkEnabled(error))
622 return; 619 return;
623 ScriptsMap::iterator it = m_scripts.find(scriptId); 620 ScriptsMap::iterator it = m_scripts.find(scriptId);
624 if (it == m_scripts.end()) { 621 if (it == m_scripts.end()) {
625 *error = "No script for id: " + scriptId; 622 *error = "No script for id: " + scriptId;
626 return; 623 return;
627 } 624 }
628
629 String url = it->value.url();
630 if (!url.isEmpty() && getEditedScript(url, scriptSource))
631 return;
632 *scriptSource = it->value.source(); 625 *scriptSource = it->value.source();
633 } 626 }
634 627
635 void V8DebuggerAgent::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<FunctionDetails>& details) 628 void V8DebuggerAgent::getFunctionDetails(ErrorString* errorString, const String& functionId, RefPtr<FunctionDetails>& details)
636 { 629 {
637 if (!checkEnabled(errorString)) 630 if (!checkEnabled(errorString))
638 return; 631 return;
639 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId); 632 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(functionId);
640 if (!remoteId) { 633 if (!remoteId) {
641 *errorString = "Invalid object id"; 634 *errorString = "Invalid object id";
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 // from the old StepFrame. 1408 // from the old StepFrame.
1416 m_skippedStepFrameCount = 0; 1409 m_skippedStepFrameCount = 0;
1417 if (m_scheduledDebuggerStep == NoStep) 1410 if (m_scheduledDebuggerStep == NoStep)
1418 debugger().clearStepping(); 1411 debugger().clearStepping();
1419 else if (m_scheduledDebuggerStep == StepOut) 1412 else if (m_scheduledDebuggerStep == StepOut)
1420 m_skipNextDebuggerStepOut = true; 1413 m_skipNextDebuggerStepOut = true;
1421 } 1414 }
1422 } 1415 }
1423 } 1416 }
1424 1417
1425 bool V8DebuggerAgent::getEditedScript(const String& url, String* content)
1426 {
1427 if (!m_editedScripts.contains(url))
1428 return false;
1429 *content = m_editedScripts.get(url);
1430 return true;
1431 }
1432
1433 PassRefPtr<Array<CallFrame>> V8DebuggerAgent::currentCallFrames() 1418 PassRefPtr<Array<CallFrame>> V8DebuggerAgent::currentCallFrames()
1434 { 1419 {
1435 if (!m_pausedScriptState || m_currentCallStack.IsEmpty()) 1420 if (!m_pausedScriptState || m_currentCallStack.IsEmpty())
1436 return Array<CallFrame>::create(); 1421 return Array<CallFrame>::create();
1437 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m _pausedScriptState.get()); 1422 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(m _pausedScriptState.get());
1438 if (injectedScript.isEmpty()) { 1423 if (injectedScript.isEmpty()) {
1439 ASSERT_NOT_REACHED(); 1424 ASSERT_NOT_REACHED();
1440 return Array<CallFrame>::create(); 1425 return Array<CallFrame>::create();
1441 } 1426 }
1442 1427
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 { 1703 {
1719 m_scheduledDebuggerStep = NoStep; 1704 m_scheduledDebuggerStep = NoStep;
1720 m_scripts.clear(); 1705 m_scripts.clear();
1721 m_breakpointIdToDebuggerBreakpointIds.clear(); 1706 m_breakpointIdToDebuggerBreakpointIds.clear();
1722 resetAsyncCallTracker(); 1707 resetAsyncCallTracker();
1723 promiseTracker().clear(); 1708 promiseTracker().clear();
1724 if (frontend()) 1709 if (frontend())
1725 frontend()->globalObjectCleared(); 1710 frontend()->globalObjectCleared();
1726 } 1711 }
1727 1712
1728 void V8DebuggerAgent::resetModifiedSources()
1729 {
1730 m_editedScripts.clear();
1731 }
1732
1733 DEFINE_TRACE(V8DebuggerAgent) 1713 DEFINE_TRACE(V8DebuggerAgent)
1734 { 1714 {
1735 #if ENABLE(OILPAN) 1715 #if ENABLE(OILPAN)
1736 visitor->trace(m_injectedScriptManager); 1716 visitor->trace(m_injectedScriptManager);
1737 visitor->trace(m_v8AsyncCallTracker); 1717 visitor->trace(m_v8AsyncCallTracker);
1738 visitor->trace(m_promiseTracker); 1718 visitor->trace(m_promiseTracker);
1739 visitor->trace(m_asyncOperations); 1719 visitor->trace(m_asyncOperations);
1740 visitor->trace(m_currentAsyncCallChain); 1720 visitor->trace(m_currentAsyncCallChain);
1741 visitor->trace(m_asyncCallTrackingListeners); 1721 visitor->trace(m_asyncCallTrackingListeners);
1742 #endif 1722 #endif
1743 InspectorBaseAgent::trace(visitor); 1723 InspectorBaseAgent::trace(visitor);
1744 } 1724 }
1745 1725
1746 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> V8DebuggerAgent::createExcep tionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message) 1726 PassRefPtr<TypeBuilder::Debugger::ExceptionDetails> V8DebuggerAgent::createExcep tionDetails(v8::Isolate* isolate, v8::Local<v8::Message> message)
1747 { 1727 {
1748 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe xt(toCoreStringWithUndefinedOrNullCheck(message->Get())); 1728 RefPtr<ExceptionDetails> exceptionDetails = ExceptionDetails::create().setTe xt(toCoreStringWithUndefinedOrNullCheck(message->Get()));
1749 exceptionDetails->setLine(message->GetLineNumber()); 1729 exceptionDetails->setLine(message->GetLineNumber());
1750 exceptionDetails->setColumn(message->GetStartColumn()); 1730 exceptionDetails->setColumn(message->GetStartColumn());
1751 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace(); 1731 v8::Local<v8::StackTrace> messageStackTrace = message->GetStackTrace();
1752 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0) 1732 if (!messageStackTrace.IsEmpty() && messageStackTrace->GetFrameCount() > 0)
1753 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray()); 1733 exceptionDetails->setStackTrace(createScriptCallStack(isolate, messageSt ackTrace, messageStackTrace->GetFrameCount())->buildInspectorArray());
1754 return exceptionDetails.release(); 1734 return exceptionDetails.release();
1755 } 1735 }
1756 1736
1757 } // namespace blink 1737 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698