| 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 21 matching lines...) Expand all Loading... |
| 32 #include "core/inspector/PageRuntimeAgent.h" | 32 #include "core/inspector/PageRuntimeAgent.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/DOMWrapperWorld.h" | 34 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 35 #include "bindings/core/v8/PageScriptDebugServer.h" | 35 #include "bindings/core/v8/PageScriptDebugServer.h" |
| 36 #include "bindings/core/v8/ScriptController.h" | 36 #include "bindings/core/v8/ScriptController.h" |
| 37 #include "bindings/core/v8/ScriptState.h" | 37 #include "bindings/core/v8/ScriptState.h" |
| 38 #include "core/frame/FrameConsole.h" | 38 #include "core/frame/FrameConsole.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/inspector/InjectedScript.h" | 40 #include "core/inspector/InjectedScript.h" |
| 41 #include "core/inspector/InjectedScriptManager.h" | 41 #include "core/inspector/InjectedScriptManager.h" |
| 42 #include "core/inspector/InspectorIdentifiers.h" |
| 42 #include "core/inspector/InspectorPageAgent.h" | 43 #include "core/inspector/InspectorPageAgent.h" |
| 43 #include "core/inspector/InstrumentingAgents.h" | 44 #include "core/inspector/InstrumentingAgents.h" |
| 44 #include "core/page/Page.h" | 45 #include "core/page/Page.h" |
| 45 #include "platform/weborigin/SecurityOrigin.h" | 46 #include "platform/weborigin/SecurityOrigin.h" |
| 46 | 47 |
| 47 namespace blink { | 48 namespace blink { |
| 48 | 49 |
| 49 static int s_nextDebuggerId = 1; | 50 static int s_nextDebuggerId = 1; |
| 50 | 51 |
| 51 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager,
Client* client, ScriptDebugServer* scriptDebugServer, InspectorPageAgent* pageA
gent) | 52 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager,
Client* client, ScriptDebugServer* scriptDebugServer, InspectorPageAgent* pageA
gent) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 bool isMainWorld = worldId == MainWorldId; | 105 bool isMainWorld = worldId == MainWorldId; |
| 105 | 106 |
| 106 // Name the context for debugging. | 107 // Name the context for debugging. |
| 107 String type = isMainWorld ? "page" : "injected"; | 108 String type = isMainWorld ? "page" : "injected"; |
| 108 PageScriptDebugServer::setContextDebugData(scriptState->context(), type, m_d
ebuggerId); | 109 PageScriptDebugServer::setContextDebugData(scriptState->context(), type, m_d
ebuggerId); |
| 109 | 110 |
| 110 if (!m_enabled) | 111 if (!m_enabled) |
| 111 return; | 112 return; |
| 112 ASSERT(frontend()); | 113 ASSERT(frontend()); |
| 113 String originString = origin ? origin->toRawString() : ""; | 114 String originString = origin ? origin->toRawString() : ""; |
| 114 String frameId = m_pageAgent->frameId(frame); | 115 String frameId = InspectorIdentifiers<LocalFrame>::identifier(frame); |
| 115 addExecutionContextToFrontend(scriptState, isMainWorld, originString, frameI
d); | 116 addExecutionContextToFrontend(scriptState, isMainWorld, originString, frameI
d); |
| 116 } | 117 } |
| 117 | 118 |
| 118 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState*
scriptState) | 119 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState*
scriptState) |
| 119 { | 120 { |
| 120 injectedScriptManager()->discardInjectedScriptFor(scriptState); | 121 injectedScriptManager()->discardInjectedScriptFor(scriptState); |
| 121 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); | 122 ScriptStateToId::iterator it = m_scriptStateToId.find(scriptState); |
| 122 if (it == m_scriptStateToId.end()) | 123 if (it == m_scriptStateToId.end()) |
| 123 return; | 124 return; |
| 124 int id = it->value; | 125 int id = it->value; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 153 | 154 |
| 154 void PageRuntimeAgent::reportExecutionContextCreation() | 155 void PageRuntimeAgent::reportExecutionContextCreation() |
| 155 { | 156 { |
| 156 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; | 157 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; |
| 157 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { | 158 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { |
| 158 if (!frame->isLocalFrame()) | 159 if (!frame->isLocalFrame()) |
| 159 continue; | 160 continue; |
| 160 LocalFrame* localFrame = toLocalFrame(frame); | 161 LocalFrame* localFrame = toLocalFrame(frame); |
| 161 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) | 162 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) |
| 162 continue; | 163 continue; |
| 163 String frameId = m_pageAgent->frameId(localFrame); | 164 String frameId = InspectorIdentifiers<LocalFrame>::identifier(localFrame
); |
| 164 | 165 |
| 165 // Ensure execution context is created. | 166 // Ensure execution context is created. |
| 166 // If initializeMainWorld returns true, then is registered by didCreateS
criptContext | 167 // If initializeMainWorld returns true, then is registered by didCreateS
criptContext |
| 167 if (!localFrame->script().initializeMainWorld()) | 168 if (!localFrame->script().initializeMainWorld()) |
| 168 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame),
true, "", frameId); | 169 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame),
true, "", frameId); |
| 169 localFrame->script().collectIsolatedContexts(isolatedContexts); | 170 localFrame->script().collectIsolatedContexts(isolatedContexts); |
| 170 if (isolatedContexts.isEmpty()) | 171 if (isolatedContexts.isEmpty()) |
| 171 continue; | 172 continue; |
| 172 for (const auto& pair : isolatedContexts) { | 173 for (const auto& pair : isolatedContexts) { |
| 173 String originString = pair.second ? pair.second->toRawString() : ""; | 174 String originString = pair.second ? pair.second->toRawString() : ""; |
| 174 addExecutionContextToFrontend(pair.first, false, originString, frame
Id); | 175 addExecutionContextToFrontend(pair.first, false, originString, frame
Id); |
| 175 } | 176 } |
| 176 isolatedContexts.clear(); | 177 isolatedContexts.clear(); |
| 177 } | 178 } |
| 178 } | 179 } |
| 179 | 180 |
| 180 } // namespace blink | 181 } // namespace blink |
| 181 | 182 |
| OLD | NEW |