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