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 13 matching lines...) Expand all Loading... | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/inspector/PageRuntimeAgent.h" | 32 #include "core/inspector/PageRuntimeAgent.h" |
33 | 33 |
34 #include "bindings/dart/DartController.h" | |
35 #include "bindings/dart/DartHandleProxy.h" | |
34 #include "bindings/v8/DOMWrapperWorld.h" | 36 #include "bindings/v8/DOMWrapperWorld.h" |
35 #include "bindings/v8/ScriptController.h" | 37 #include "bindings/v8/ScriptController.h" |
36 #include "core/inspector/InjectedScript.h" | 38 #include "core/inspector/InjectedScript.h" |
37 #include "core/inspector/InjectedScriptManager.h" | 39 #include "core/inspector/InjectedScriptManager.h" |
38 #include "core/inspector/InspectorPageAgent.h" | 40 #include "core/inspector/InspectorPageAgent.h" |
39 #include "core/inspector/InspectorState.h" | 41 #include "core/inspector/InspectorState.h" |
40 #include "core/inspector/InstrumentingAgents.h" | 42 #include "core/inspector/InstrumentingAgents.h" |
41 #include "core/page/Frame.h" | 43 #include "core/page/Frame.h" |
42 #include "core/page/Page.h" | 44 #include "core/page/Page.h" |
43 #include "core/page/PageConsole.h" | 45 #include "core/page/PageConsole.h" |
44 #include "weborigin/SecurityOrigin.h" | 46 #include "weborigin/SecurityOrigin.h" |
45 | 47 |
48 #include <dart_api.h> | |
vsm
2013/09/30 22:08:03
We should really avoid including this outside of b
Jacob
2013/10/01 00:07:05
Worse... I didn't even use this import anymore. I
| |
49 | |
46 using WebCore::TypeBuilder::Runtime::ExecutionContextDescription; | 50 using WebCore::TypeBuilder::Runtime::ExecutionContextDescription; |
47 | 51 |
48 namespace WebCore { | 52 namespace WebCore { |
49 | 53 |
50 namespace PageRuntimeAgentState { | 54 namespace PageRuntimeAgentState { |
51 static const char runtimeEnabled[] = "runtimeEnabled"; | 55 static const char runtimeEnabled[] = "runtimeEnabled"; |
52 }; | 56 }; |
53 | 57 |
54 PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, Ins pectorCompositeState* state, InjectedScriptManager* injectedScriptManager, Scrip tDebugServer* scriptDebugServer, Page* page, InspectorPageAgent* pageAgent) | 58 PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, Ins pectorCompositeState* state, InjectedScriptManager* injectedScriptManager, Scrip tDebugServer* scriptDebugServer, Page* page, InspectorPageAgent* pageAgent) |
55 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager, s criptDebugServer) | 59 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager, s criptDebugServer) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
161 void PageRuntimeAgent::reportExecutionContextCreation() | 165 void PageRuntimeAgent::reportExecutionContextCreation() |
162 { | 166 { |
163 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; | 167 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; |
164 for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree ()->traverseNext()) { | 168 for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree ()->traverseNext()) { |
165 if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) | 169 if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) |
166 continue; | 170 continue; |
167 String frameId = m_pageAgent->frameId(frame); | 171 String frameId = m_pageAgent->frameId(frame); |
168 | 172 |
169 ScriptState* scriptState = mainWorldScriptState(frame); | 173 ScriptState* scriptState = mainWorldScriptState(frame); |
170 notifyContextCreated(frameId, scriptState, 0, true); | 174 notifyContextCreated(frameId, scriptState, 0, true); |
175 notifyDartContextCreated(frameId, scriptState); | |
176 | |
171 frame->script()->collectIsolatedContexts(isolatedContexts); | 177 frame->script()->collectIsolatedContexts(isolatedContexts); |
172 if (isolatedContexts.isEmpty()) | 178 if (isolatedContexts.isEmpty()) |
173 continue; | 179 continue; |
174 for (size_t i = 0; i< isolatedContexts.size(); i++) | 180 for (size_t i = 0; i< isolatedContexts.size(); i++) |
175 notifyContextCreated(frameId, isolatedContexts[i].first, isolatedCon texts[i].second, false); | 181 notifyContextCreated(frameId, isolatedContexts[i].first, isolatedCon texts[i].second, false); |
176 isolatedContexts.clear(); | 182 isolatedContexts.clear(); |
177 } | 183 } |
178 } | 184 } |
179 | 185 |
186 void PageRuntimeAgent::notifyDartContextCreated(const String& frameId, ScriptSta te* v8ScriptState) | |
187 { | |
188 ScriptExecutionContext* scriptExecutionContext = v8ScriptState->scriptExecut ionContext(); | |
189 DartController* dartController = DartController::retrieve(scriptExecutionCon text); | |
190 if (dartController) { | |
191 Vector<ScriptState*> scriptStates; | |
192 dartController->collectScriptStates(v8ScriptState, scriptStates); | |
193 for (size_t i = 0; i< scriptStates.size(); i++) | |
194 notifyContextCreated(frameId, scriptStates[i], 0, false); | |
195 } | |
196 } | |
197 | |
180 void PageRuntimeAgent::notifyContextCreated(const String& frameId, ScriptState* scriptState, SecurityOrigin* securityOrigin, bool isPageContext) | 198 void PageRuntimeAgent::notifyContextCreated(const String& frameId, ScriptState* scriptState, SecurityOrigin* securityOrigin, bool isPageContext) |
181 { | 199 { |
182 ASSERT(securityOrigin || isPageContext); | 200 // FIXME: should Dart scripts have a security origin? |
201 ASSERT(securityOrigin || isPageContext || !scriptState->isJavaScript()); | |
183 int executionContextId = injectedScriptManager()->injectedScriptIdFor(script State); | 202 int executionContextId = injectedScriptManager()->injectedScriptIdFor(script State); |
184 String name = securityOrigin ? securityOrigin->toRawString() : ""; | 203 String name = scriptState->name() ? *scriptState->name() : (securityOrigin ? securityOrigin->toRawString() : ""); |
204 | |
185 m_frontend->executionContextCreated(ExecutionContextDescription::create() | 205 m_frontend->executionContextCreated(ExecutionContextDescription::create() |
186 .setId(executionContextId) | 206 .setId(executionContextId) |
187 .setIsPageContext(isPageContext) | 207 .setIsPageContext(isPageContext) |
188 .setName(name) | 208 .setName(name) |
189 .setFrameId(frameId) | 209 .setFrameId(frameId) |
190 .release()); | 210 .release()); |
191 } | 211 } |
192 | 212 |
193 } // namespace WebCore | 213 } // namespace WebCore |
194 | 214 |
OLD | NEW |