| 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" |
| 34 #include "bindings/v8/DOMWrapperWorld.h" | 35 #include "bindings/v8/DOMWrapperWorld.h" |
| 35 #include "bindings/v8/ScriptController.h" | 36 #include "bindings/v8/ScriptController.h" |
| 36 #include "core/inspector/InjectedScript.h" | 37 #include "core/inspector/InjectedScript.h" |
| 37 #include "core/inspector/InjectedScriptManager.h" | 38 #include "core/inspector/InjectedScriptManager.h" |
| 38 #include "core/inspector/InspectorPageAgent.h" | 39 #include "core/inspector/InspectorPageAgent.h" |
| 39 #include "core/inspector/InspectorState.h" | 40 #include "core/inspector/InspectorState.h" |
| 40 #include "core/inspector/InstrumentingAgents.h" | 41 #include "core/inspector/InstrumentingAgents.h" |
| 41 #include "core/page/Frame.h" | 42 #include "core/page/Frame.h" |
| 42 #include "core/page/Page.h" | 43 #include "core/page/Page.h" |
| 43 #include "core/page/PageConsole.h" | 44 #include "core/page/PageConsole.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 void PageRuntimeAgent::reportExecutionContextCreation() | 162 void PageRuntimeAgent::reportExecutionContextCreation() |
| 162 { | 163 { |
| 163 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; | 164 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; |
| 164 for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree
()->traverseNext()) { | 165 for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree
()->traverseNext()) { |
| 165 if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) | 166 if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) |
| 166 continue; | 167 continue; |
| 167 String frameId = m_pageAgent->frameId(frame); | 168 String frameId = m_pageAgent->frameId(frame); |
| 168 | 169 |
| 169 ScriptState* scriptState = mainWorldScriptState(frame); | 170 ScriptState* scriptState = mainWorldScriptState(frame); |
| 170 notifyContextCreated(frameId, scriptState, 0, true); | 171 notifyContextCreated(frameId, scriptState, 0, true); |
| 172 notifyDartContextCreated(frameId, scriptState); |
| 173 |
| 171 frame->script()->collectIsolatedContexts(isolatedContexts); | 174 frame->script()->collectIsolatedContexts(isolatedContexts); |
| 172 if (isolatedContexts.isEmpty()) | 175 if (isolatedContexts.isEmpty()) |
| 173 continue; | 176 continue; |
| 174 for (size_t i = 0; i< isolatedContexts.size(); i++) | 177 for (size_t i = 0; i< isolatedContexts.size(); i++) |
| 175 notifyContextCreated(frameId, isolatedContexts[i].first, isolatedCon
texts[i].second, false); | 178 notifyContextCreated(frameId, isolatedContexts[i].first, isolatedCon
texts[i].second, false); |
| 176 isolatedContexts.clear(); | 179 isolatedContexts.clear(); |
| 177 } | 180 } |
| 178 } | 181 } |
| 179 | 182 |
| 183 void PageRuntimeAgent::notifyDartContextCreated(const String& frameId, ScriptSta
te* v8ScriptState) |
| 184 { |
| 185 ScriptExecutionContext* scriptExecutionContext = v8ScriptState->scriptExecut
ionContext(); |
| 186 DartController* dartController = DartController::retrieve(scriptExecutionCon
text); |
| 187 if (dartController) { |
| 188 Vector<ScriptState*> scriptStates; |
| 189 dartController->collectScriptStates(v8ScriptState, scriptStates); |
| 190 for (size_t i = 0; i< scriptStates.size(); i++) |
| 191 notifyContextCreated(frameId, scriptStates[i], 0, false); |
| 192 } |
| 193 } |
| 194 |
| 180 void PageRuntimeAgent::notifyContextCreated(const String& frameId, ScriptState*
scriptState, SecurityOrigin* securityOrigin, bool isPageContext) | 195 void PageRuntimeAgent::notifyContextCreated(const String& frameId, ScriptState*
scriptState, SecurityOrigin* securityOrigin, bool isPageContext) |
| 181 { | 196 { |
| 182 ASSERT(securityOrigin || isPageContext); | 197 // FIXME(dartbug.com/13801): remove the check for |
| 198 // !scriptState->isJavaScript() once Dart scripts have correct security |
| 199 // origins. |
| 200 ASSERT(securityOrigin || isPageContext || !scriptState->isJavaScript()); |
| 183 int executionContextId = injectedScriptManager()->injectedScriptIdFor(script
State); | 201 int executionContextId = injectedScriptManager()->injectedScriptIdFor(script
State); |
| 184 String name = securityOrigin ? securityOrigin->toRawString() : ""; | 202 String name = scriptState->name() ? *scriptState->name() : (securityOrigin ?
securityOrigin->toRawString() : ""); |
| 203 |
| 185 m_frontend->executionContextCreated(ExecutionContextDescription::create() | 204 m_frontend->executionContextCreated(ExecutionContextDescription::create() |
| 186 .setId(executionContextId) | 205 .setId(executionContextId) |
| 187 .setIsPageContext(isPageContext) | 206 .setIsPageContext(isPageContext) |
| 188 .setName(name) | 207 .setName(name) |
| 189 .setFrameId(frameId) | 208 .setFrameId(frameId) |
| 190 .release()); | 209 .release()); |
| 191 } | 210 } |
| 192 | 211 |
| 193 } // namespace WebCore | 212 } // namespace WebCore |
| 194 | 213 |
| OLD | NEW |