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

Unified Diff: Source/core/inspector/InspectorDOMAgent.cpp

Issue 303653008: DevTools: implement enable/disable commands in DOMAgent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/devtools/front_end/sdk/DOMModel.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorDOMAgent.cpp
diff --git a/Source/core/inspector/InspectorDOMAgent.cpp b/Source/core/inspector/InspectorDOMAgent.cpp
index fbe6ed5797eeb0fea71238d912c6b95cfba2cb91..765a44fd6bb9116a21573741822a2c22fc1cb6bb 100644
--- a/Source/core/inspector/InspectorDOMAgent.cpp
+++ b/Source/core/inspector/InspectorDOMAgent.cpp
@@ -88,7 +88,7 @@ namespace WebCore {
using namespace HTMLNames;
namespace DOMAgentState {
-static const char documentRequested[] = "documentRequested";
+static const char domAgentEnabled[] = "domAgentEnabled";
};
static const size_t maxTextSize = 10000;
@@ -268,7 +268,7 @@ void InspectorDOMAgent::clearFrontend()
m_frontend = 0;
m_instrumentingAgents->setInspectorDOMAgent(0);
- m_state->setBoolean(DOMAgentState::documentRequested, false);
+ disable(0);
reset();
}
@@ -311,7 +311,7 @@ void InspectorDOMAgent::setDocument(Document* doc)
m_document = doc;
- if (!m_state->getBoolean(DOMAgentState::documentRequested))
+ if (!enabled())
return;
// Immediately communicate 0 document or document that has finished loading.
@@ -481,9 +481,30 @@ Element* InspectorDOMAgent::assertEditableElement(ErrorString* errorString, int
return element;
}
+void InspectorDOMAgent::enable(ErrorString*)
+{
+ if (enabled())
+ return;
+ m_state->setBoolean(DOMAgentState::domAgentEnabled, true);
+}
+
+bool InspectorDOMAgent::enabled() const
+{
+ return m_state->getBoolean(DOMAgentState::domAgentEnabled);
+}
+
+void InspectorDOMAgent::disable(ErrorString*)
+{
+ if (!enabled())
+ return;
+ m_state->setBoolean(DOMAgentState::domAgentEnabled, false);
+ reset();
+}
+
void InspectorDOMAgent::getDocument(ErrorString* errorString, RefPtr<TypeBuilder::DOM::Node>& root)
{
- m_state->setBoolean(DOMAgentState::documentRequested, true);
+ // Backward compatibility. Mark agent as enabled when it requests document.
+ enable(errorString);
if (!m_document) {
*errorString = "Document is not available";
@@ -1715,7 +1736,7 @@ void InspectorDOMAgent::domContentLoadedEventFired(LocalFrame* frame)
// Re-push document once it is loaded.
discardFrontendBindings();
- if (m_state->getBoolean(DOMAgentState::documentRequested))
+ if (enabled())
m_frontend->documentUpdated();
}
« no previous file with comments | « Source/core/inspector/InspectorDOMAgent.h ('k') | Source/devtools/front_end/sdk/DOMModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698