| 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 22 matching lines...) Expand all Loading... |
| 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/InspectorIdentifiers.h" |
| 43 #include "core/inspector/InspectorPageAgent.h" | |
| 44 #include "core/inspector/InstrumentingAgents.h" | 43 #include "core/inspector/InstrumentingAgents.h" |
| 45 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
| 46 #include "platform/weborigin/SecurityOrigin.h" | 45 #include "platform/weborigin/SecurityOrigin.h" |
| 47 | 46 |
| 48 namespace blink { | 47 namespace blink { |
| 49 | 48 |
| 50 static int s_nextDebuggerId = 1; | 49 static int s_nextDebuggerId = 1; |
| 51 | 50 |
| 52 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager,
Client* client, ScriptDebugServer* scriptDebugServer, InspectorPageAgent* pageA
gent) | 51 PageRuntimeAgent::PageRuntimeAgent(LocalFrame* inspectedFrame, InjectedScriptMan
ager* injectedScriptManager, Client* client, ScriptDebugServer* scriptDebugServe
r) |
| 53 : InspectorRuntimeAgent(injectedScriptManager, scriptDebugServer, client) | 52 : InspectorRuntimeAgent(injectedScriptManager, scriptDebugServer, client) |
| 54 , m_pageAgent(pageAgent) | 53 , m_inspectedFrame(inspectedFrame) |
| 55 , m_mainWorldContextCreated(false) | 54 , m_mainWorldContextCreated(false) |
| 56 , m_debuggerId(s_nextDebuggerId++) | 55 , m_debuggerId(s_nextDebuggerId++) |
| 57 { | 56 { |
| 58 } | 57 } |
| 59 | 58 |
| 60 PageRuntimeAgent::~PageRuntimeAgent() | 59 PageRuntimeAgent::~PageRuntimeAgent() |
| 61 { | 60 { |
| 62 #if !ENABLE(OILPAN) | 61 #if !ENABLE(OILPAN) |
| 63 m_instrumentingAgents->setPageRuntimeAgent(0); | 62 m_instrumentingAgents->setPageRuntimeAgent(0); |
| 64 #endif | 63 #endif |
| 65 } | 64 } |
| 66 | 65 |
| 67 DEFINE_TRACE(PageRuntimeAgent) | 66 DEFINE_TRACE(PageRuntimeAgent) |
| 68 { | 67 { |
| 69 visitor->trace(m_pageAgent); | 68 visitor->trace(m_inspectedFrame); |
| 70 InspectorRuntimeAgent::trace(visitor); | 69 InspectorRuntimeAgent::trace(visitor); |
| 71 } | 70 } |
| 72 | 71 |
| 73 void PageRuntimeAgent::init() | 72 void PageRuntimeAgent::init() |
| 74 { | 73 { |
| 75 m_instrumentingAgents->setPageRuntimeAgent(this); | 74 m_instrumentingAgents->setPageRuntimeAgent(this); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void PageRuntimeAgent::enable(ErrorString* errorString) | 77 void PageRuntimeAgent::enable(ErrorString* errorString) |
| 79 { | 78 { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (it == m_scriptStateToId.end()) | 122 if (it == m_scriptStateToId.end()) |
| 124 return; | 123 return; |
| 125 int id = it->value; | 124 int id = it->value; |
| 126 m_scriptStateToId.remove(scriptState); | 125 m_scriptStateToId.remove(scriptState); |
| 127 frontend()->executionContextDestroyed(id); | 126 frontend()->executionContextDestroyed(id); |
| 128 } | 127 } |
| 129 | 128 |
| 130 InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString,
const int* executionContextId) | 129 InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString,
const int* executionContextId) |
| 131 { | 130 { |
| 132 if (!executionContextId) { | 131 if (!executionContextId) { |
| 133 ScriptState* scriptState = ScriptState::forMainWorld(m_pageAgent->inspec
tedFrame()); | 132 ScriptState* scriptState = ScriptState::forMainWorld(m_inspectedFrame); |
| 134 InjectedScript result = injectedScriptManager()->injectedScriptFor(scrip
tState); | 133 InjectedScript result = injectedScriptManager()->injectedScriptFor(scrip
tState); |
| 135 if (result.isEmpty()) | 134 if (result.isEmpty()) |
| 136 *errorString = "Internal error: main world execution context not fou
nd."; | 135 *errorString = "Internal error: main world execution context not fou
nd."; |
| 137 return result; | 136 return result; |
| 138 } | 137 } |
| 139 InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId
(*executionContextId); | 138 InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId
(*executionContextId); |
| 140 if (injectedScript.isEmpty()) | 139 if (injectedScript.isEmpty()) |
| 141 *errorString = "Execution context with given id not found."; | 140 *errorString = "Execution context with given id not found."; |
| 142 return injectedScript; | 141 return injectedScript; |
| 143 } | 142 } |
| 144 | 143 |
| 145 void PageRuntimeAgent::muteConsole() | 144 void PageRuntimeAgent::muteConsole() |
| 146 { | 145 { |
| 147 FrameConsole::mute(); | 146 FrameConsole::mute(); |
| 148 } | 147 } |
| 149 | 148 |
| 150 void PageRuntimeAgent::unmuteConsole() | 149 void PageRuntimeAgent::unmuteConsole() |
| 151 { | 150 { |
| 152 FrameConsole::unmute(); | 151 FrameConsole::unmute(); |
| 153 } | 152 } |
| 154 | 153 |
| 155 void PageRuntimeAgent::reportExecutionContextCreation() | 154 void PageRuntimeAgent::reportExecutionContextCreation() |
| 156 { | 155 { |
| 157 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; | 156 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; |
| 158 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { | 157 for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseN
ext(m_inspectedFrame)) { |
| 159 if (!frame->isLocalFrame()) | 158 if (!frame->isLocalFrame()) |
| 160 continue; | 159 continue; |
| 161 LocalFrame* localFrame = toLocalFrame(frame); | 160 LocalFrame* localFrame = toLocalFrame(frame); |
| 162 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) | 161 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) |
| 163 continue; | 162 continue; |
| 164 String frameId = InspectorIdentifiers<LocalFrame>::identifier(localFrame
); | 163 String frameId = InspectorIdentifiers<LocalFrame>::identifier(localFrame
); |
| 165 | 164 |
| 166 // Ensure execution context is created. | 165 // Ensure execution context is created. |
| 167 // If initializeMainWorld returns true, then is registered by didCreateS
criptContext | 166 // If initializeMainWorld returns true, then is registered by didCreateS
criptContext |
| 168 if (!localFrame->script().initializeMainWorld()) | 167 if (!localFrame->script().initializeMainWorld()) |
| 169 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame),
true, "", frameId); | 168 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame),
true, "", frameId); |
| 170 localFrame->script().collectIsolatedContexts(isolatedContexts); | 169 localFrame->script().collectIsolatedContexts(isolatedContexts); |
| 171 if (isolatedContexts.isEmpty()) | 170 if (isolatedContexts.isEmpty()) |
| 172 continue; | 171 continue; |
| 173 for (const auto& pair : isolatedContexts) { | 172 for (const auto& pair : isolatedContexts) { |
| 174 String originString = pair.second ? pair.second->toRawString() : ""; | 173 String originString = pair.second ? pair.second->toRawString() : ""; |
| 175 addExecutionContextToFrontend(pair.first, false, originString, frame
Id); | 174 addExecutionContextToFrontend(pair.first, false, originString, frame
Id); |
| 176 } | 175 } |
| 177 isolatedContexts.clear(); | 176 isolatedContexts.clear(); |
| 178 } | 177 } |
| 179 } | 178 } |
| 180 | 179 |
| 181 } // namespace blink | 180 } // namespace blink |
| 182 | 181 |
| OLD | NEW |