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

Unified Diff: inspector/InspectorController.cpp

Issue 542055: DevTools: injected script per context(WebCore part) (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/WebCore/
Patch Set: '' Created 10 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « inspector/InspectorController.h ('k') | inspector/InspectorFrontend.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: inspector/InspectorController.cpp
===================================================================
--- inspector/InspectorController.cpp (revision 53180)
+++ inspector/InspectorController.cpp (working copy)
@@ -143,7 +143,6 @@
, m_inspectorBackend(InspectorBackend::create(this))
, m_inspectorFrontendHost(InspectorFrontendHost::create(this, client))
, m_injectedScriptHost(InjectedScriptHost::create(this))
- , m_lastBoundObjectId(1)
#if ENABLE(JAVASCRIPT_DEBUGGER)
, m_debuggerEnabled(false)
, m_attachDebuggerWhenShown(false)
@@ -375,7 +374,7 @@
m_expiredConsoleMessageCount = 0;
m_previousMessage = 0;
m_groupLevel = 0;
- releaseWrapperObjectGroup("console");
+ m_injectedScriptHost->releaseWrapperObjectGroup(0 /* release the group in all scripts */, "console");
if (m_domAgent)
m_domAgent->releaseDanglingNodes();
if (m_frontend)
@@ -500,7 +499,7 @@
{
if (!enabled() || !m_frontend || frame != m_inspectedPage->mainFrame())
return;
- resetInjectedScript();
+ m_injectedScriptHost->discardInjectedScripts();
}
void InspectorController::windowScriptObjectAvailable()
@@ -513,7 +512,6 @@
m_scriptState = scriptStateFromPage(debuggerWorld(), m_page);
ScriptGlobalObject::set(m_scriptState, "InspectorBackend", m_inspectorBackend.get());
ScriptGlobalObject::set(m_scriptState, "InspectorFrontendHost", m_inspectorFrontendHost.get());
- ScriptGlobalObject::set(m_scriptState, "InjectedScriptHost", m_injectedScriptHost.get());
}
void InspectorController::scriptObjectReady()
@@ -526,8 +524,6 @@
if (!ScriptGlobalObject::get(m_scriptState, "WebInspector", webInspectorObj))
return;
ScriptObject injectedScriptObj;
- if (!ScriptGlobalObject::get(m_scriptState, "InjectedScript", injectedScriptObj))
- return;
setFrontendProxyObject(m_scriptState, webInspectorObj, injectedScriptObj);
#if ENABLE(JAVASCRIPT_DEBUGGER)
@@ -545,10 +541,9 @@
m_client->inspectorWindowObjectCleared();
}
-void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject injectedScriptObj)
+void InspectorController::setFrontendProxyObject(ScriptState* scriptState, ScriptObject webInspectorObj, ScriptObject)
{
m_scriptState = scriptState;
- m_injectedScriptObj = injectedScriptObj;
m_frontend.set(new InspectorFrontend(this, scriptState, webInspectorObj));
releaseDOMAgent();
m_domAgent = InspectorDOMAgent::create(m_frontend.get());
@@ -606,7 +601,6 @@
#endif
closeWindow();
- m_injectedScriptObj = ScriptObject();
releaseDOMAgent();
m_frontend.set(0);
m_timelineAgent = 0;
@@ -715,8 +709,6 @@
m_frontend->reset();
m_domAgent->reset();
- m_objectGroups.clear();
- m_idToWrappedObject.clear();
}
void InspectorController::pruneResources(ResourcesMap* resourceMap, DocumentLoader* loaderToKeep)
@@ -1591,8 +1583,14 @@
void InspectorController::didPause()
{
- ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "getCallFrames");
- ScriptValue callFrames = function.call();
+ JavaScriptCallFrame* callFrame = m_injectedScriptHost->currentCallFrame();
+ ScriptState* scriptState = callFrame->scopeChain()->globalObject->globalExec();
+ ASSERT(scriptState);
+ ScriptObject injectedScriptObj = m_injectedScriptHost->injectedScriptFor(scriptState);
+ ScriptFunctionCall function(scriptState, injectedScriptObj, "getCallFrames");
+ ScriptValue callFramesValue = function.call();
+ String callFrames = callFramesValue.toString(scriptState);
+
m_frontend->pausedScript(callFrames);
}
@@ -1820,50 +1818,6 @@
return ElementsPanel;
}
-ScriptValue InspectorController::wrapObject(const ScriptValue& quarantinedObject, const String& objectGroup)
-{
- ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "createProxyObject");
- function.appendArgument(quarantinedObject);
- if (quarantinedObject.isObject()) {
- long id = m_lastBoundObjectId++;
- String objectId = String::format("object#%ld", id);
- m_idToWrappedObject.set(objectId, quarantinedObject);
- ObjectGroupsMap::iterator it = m_objectGroups.find(objectGroup);
- if (it == m_objectGroups.end())
- it = m_objectGroups.set(objectGroup, Vector<String>()).first;
- it->second.append(objectId);
- function.appendArgument(objectId);
- }
- ScriptValue wrapper = function.call();
- return wrapper;
-}
-
-ScriptValue InspectorController::unwrapObject(const String& objectId)
-{
- HashMap<String, ScriptValue>::iterator it = m_idToWrappedObject.find(objectId);
- if (it != m_idToWrappedObject.end())
- return it->second;
- return ScriptValue();
-}
-
-void InspectorController::releaseWrapperObjectGroup(const String& objectGroup)
-{
- ObjectGroupsMap::iterator groupIt = m_objectGroups.find(objectGroup);
- if (groupIt == m_objectGroups.end())
- return;
-
- Vector<String>& groupIds = groupIt->second;
- for (Vector<String>::iterator it = groupIds.begin(); it != groupIds.end(); ++it)
- m_idToWrappedObject.remove(*it);
- m_objectGroups.remove(groupIt);
-}
-
-void InspectorController::resetInjectedScript()
-{
- ScriptFunctionCall function(m_scriptState, m_injectedScriptObj, "reset");
- function.call();
-}
-
void InspectorController::deleteCookie(const String& cookieName, const String& domain)
{
ResourcesMap::iterator resourcesEnd = m_resources.end();
@@ -1892,6 +1846,27 @@
m_domAgent->didModifyDOMAttr(element);
}
-} // namespace WebCore
+ScriptObject InspectorController::injectedScriptForNodeId(long id)
+{
+
+ Frame* frame = 0;
+ if (id) {
+ ASSERT(m_domAgent);
+ Node* node = m_domAgent->nodeForId(id);
+ if (node) {
+ Document* document = node->ownerDocument();
+ if (document)
+ frame = document->frame();
+ }
+ } else
+ frame = m_inspectedPage->mainFrame();
+
+ if (frame)
+ return m_injectedScriptHost->injectedScriptFor(frame->script()->mainWorldScriptState());
+
+ return ScriptObject();
+}
+
+} // namespace WebCore
#endif // ENABLE(INSPECTOR)
« no previous file with comments | « inspector/InspectorController.h ('k') | inspector/InspectorFrontend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698