| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 20 matching lines...) Expand all Loading... |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 | 32 |
| 33 #if ENABLE(INSPECTOR) | 33 #if ENABLE(INSPECTOR) |
| 34 | 34 |
| 35 #include "PageRuntimeAgent.h" | 35 #include "PageRuntimeAgent.h" |
| 36 | 36 |
| 37 #include "Console.h" | 37 #include "Console.h" |
| 38 #include "Document.h" | 38 #include "Document.h" |
| 39 #include "InjectedScript.h" | 39 #include "InjectedScript.h" |
| 40 #include "InjectedScriptManager.h" | 40 #include "InjectedScriptManager.h" |
| 41 #include "InspectorAgent.h" | |
| 42 #include "InspectorPageAgent.h" | 41 #include "InspectorPageAgent.h" |
| 43 #include "InspectorState.h" | 42 #include "InspectorState.h" |
| 44 #include "InstrumentingAgents.h" | 43 #include "InstrumentingAgents.h" |
| 45 #include "Page.h" | 44 #include "Page.h" |
| 46 #include "SecurityOrigin.h" | 45 #include "SecurityOrigin.h" |
| 47 | 46 |
| 48 using WebCore::TypeBuilder::Runtime::ExecutionContextDescription; | 47 using WebCore::TypeBuilder::Runtime::ExecutionContextDescription; |
| 49 | 48 |
| 50 namespace WebCore { | 49 namespace WebCore { |
| 51 | 50 |
| 52 namespace PageRuntimeAgentState { | 51 namespace PageRuntimeAgentState { |
| 53 static const char runtimeEnabled[] = "runtimeEnabled"; | 52 static const char runtimeEnabled[] = "runtimeEnabled"; |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, Ins
pectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, In
spectorPageAgent* pageAgent, InspectorAgent* inspectorAgent) | 55 PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, Ins
pectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, In
spectorPageAgent* pageAgent) |
| 57 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager) | 56 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager) |
| 58 , m_inspectedPage(page) | 57 , m_inspectedPage(page) |
| 59 , m_pageAgent(pageAgent) | 58 , m_pageAgent(pageAgent) |
| 60 , m_inspectorAgent(inspectorAgent) | |
| 61 , m_frontend(0) | 59 , m_frontend(0) |
| 60 , m_mainWorldContextCreated(false) |
| 62 { | 61 { |
| 62 m_instrumentingAgents->setPageRuntimeAgent(this); |
| 63 } | 63 } |
| 64 | 64 |
| 65 PageRuntimeAgent::~PageRuntimeAgent() | 65 PageRuntimeAgent::~PageRuntimeAgent() |
| 66 { | 66 { |
| 67 m_instrumentingAgents->setPageRuntimeAgent(0); |
| 67 } | 68 } |
| 68 | 69 |
| 69 void PageRuntimeAgent::setFrontend(InspectorFrontend* frontend) | 70 void PageRuntimeAgent::setFrontend(InspectorFrontend* frontend) |
| 70 { | 71 { |
| 71 m_frontend = frontend->runtime(); | 72 m_frontend = frontend->runtime(); |
| 72 m_instrumentingAgents->setPageRuntimeAgent(this); | |
| 73 } | 73 } |
| 74 | 74 |
| 75 void PageRuntimeAgent::clearFrontend() | 75 void PageRuntimeAgent::clearFrontend() |
| 76 { | 76 { |
| 77 m_instrumentingAgents->setPageRuntimeAgent(0); | |
| 78 m_frontend = 0; | 77 m_frontend = 0; |
| 79 String errorString; | 78 String errorString; |
| 80 disable(&errorString); | 79 disable(&errorString); |
| 81 } | 80 } |
| 82 | 81 |
| 83 void PageRuntimeAgent::restore() | 82 void PageRuntimeAgent::restore() |
| 84 { | 83 { |
| 85 if (m_state->getBoolean(PageRuntimeAgentState::runtimeEnabled)) { | 84 if (m_state->getBoolean(PageRuntimeAgentState::runtimeEnabled)) { |
| 86 String error; | 85 String error; |
| 87 enable(&error); | 86 enable(&error); |
| 88 } | 87 } |
| 89 } | 88 } |
| 90 | 89 |
| 91 void PageRuntimeAgent::enable(ErrorString* errorString) | 90 void PageRuntimeAgent::enable(ErrorString* errorString) |
| 92 { | 91 { |
| 93 if (m_enabled) | 92 if (m_enabled) |
| 94 return; | 93 return; |
| 95 | 94 |
| 96 InspectorRuntimeAgent::enable(errorString); | 95 InspectorRuntimeAgent::enable(errorString); |
| 97 m_state->setBoolean(PageRuntimeAgentState::runtimeEnabled, true); | 96 m_state->setBoolean(PageRuntimeAgentState::runtimeEnabled, true); |
| 98 // Only report existing contexts if the page did commit load, otherwise we m
ay | 97 // Only report existing contexts if the page did commit load, otherwise we m
ay |
| 99 // unintentionally initialize contexts in the frames which may trigger some
listeners | 98 // unintentionally initialize contexts in the frames which may trigger some
listeners |
| 100 // that are expected to be triggered only after the load is committed, see h
ttp://crbug.com/131623 | 99 // that are expected to be triggered only after the load is committed, see h
ttp://crbug.com/131623 |
| 101 if (m_inspectorAgent->didCommitLoadFired()) | 100 if (m_mainWorldContextCreated) |
| 102 reportExecutionContextCreation(); | 101 reportExecutionContextCreation(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 void PageRuntimeAgent::disable(ErrorString* errorString) | 104 void PageRuntimeAgent::disable(ErrorString* errorString) |
| 106 { | 105 { |
| 107 if (!m_enabled) | 106 if (!m_enabled) |
| 108 return; | 107 return; |
| 109 | 108 |
| 110 InspectorRuntimeAgent::disable(errorString); | 109 InspectorRuntimeAgent::disable(errorString); |
| 111 m_state->setBoolean(PageRuntimeAgentState::runtimeEnabled, false); | 110 m_state->setBoolean(PageRuntimeAgentState::runtimeEnabled, false); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void PageRuntimeAgent::didClearWindowObject(Frame* frame) | 113 void PageRuntimeAgent::didCreateMainWorldContext(Frame* frame) |
| 115 { | 114 { |
| 115 m_mainWorldContextCreated = true; |
| 116 |
| 116 if (!m_enabled) | 117 if (!m_enabled) |
| 117 return; | 118 return; |
| 118 ASSERT(m_frontend); | 119 ASSERT(m_frontend); |
| 119 String frameId = m_pageAgent->frameId(frame); | 120 String frameId = m_pageAgent->frameId(frame); |
| 120 ScriptState* scriptState = mainWorldScriptState(frame); | 121 ScriptState* scriptState = mainWorldScriptState(frame); |
| 121 notifyContextCreated(frameId, scriptState, 0, true); | 122 notifyContextCreated(frameId, scriptState, 0, true); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void PageRuntimeAgent::didCreateIsolatedContext(Frame* frame, ScriptState* scrip
tState, SecurityOrigin* origin) | 125 void PageRuntimeAgent::didCreateIsolatedContext(Frame* frame, ScriptState* scrip
tState, SecurityOrigin* origin) |
| 125 { | 126 { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 .setId(executionContextId) | 181 .setId(executionContextId) |
| 181 .setIsPageContext(isPageContext) | 182 .setIsPageContext(isPageContext) |
| 182 .setName(name) | 183 .setName(name) |
| 183 .setFrameId(frameId) | 184 .setFrameId(frameId) |
| 184 .release()); | 185 .release()); |
| 185 } | 186 } |
| 186 | 187 |
| 187 } // namespace WebCore | 188 } // namespace WebCore |
| 188 | 189 |
| 189 #endif // ENABLE(INSPECTOR) | 190 #endif // ENABLE(INSPECTOR) |
| OLD | NEW |