| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "platform/v8_inspector/public/V8RuntimeAgent.h" | 42 #include "platform/v8_inspector/public/V8RuntimeAgent.h" |
| 43 #include "platform/weborigin/SecurityOrigin.h" | 43 #include "platform/weborigin/SecurityOrigin.h" |
| 44 | 44 |
| 45 using blink::protocol::Runtime::ExceptionDetails; | 45 using blink::protocol::Runtime::ExceptionDetails; |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 PageRuntimeAgent::PageRuntimeAgent(Client* client, V8Debugger* debugger, Inspect
edFrames* inspectedFrames) | 49 PageRuntimeAgent::PageRuntimeAgent(Client* client, V8Debugger* debugger, Inspect
edFrames* inspectedFrames) |
| 50 : InspectorRuntimeAgent(debugger, client) | 50 : InspectorRuntimeAgent(debugger, client) |
| 51 , m_inspectedFrames(inspectedFrames) | 51 , m_inspectedFrames(inspectedFrames) |
| 52 , m_mainWorldContextCreated(false) | |
| 53 { | 52 { |
| 54 } | 53 } |
| 55 | 54 |
| 56 PageRuntimeAgent::~PageRuntimeAgent() | 55 PageRuntimeAgent::~PageRuntimeAgent() |
| 57 { | 56 { |
| 58 #if !ENABLE(OILPAN) | 57 #if !ENABLE(OILPAN) |
| 59 m_instrumentingAgents->setPageRuntimeAgent(0); | 58 m_instrumentingAgents->setPageRuntimeAgent(0); |
| 60 #endif | 59 #endif |
| 61 } | 60 } |
| 62 | 61 |
| 63 DEFINE_TRACE(PageRuntimeAgent) | 62 DEFINE_TRACE(PageRuntimeAgent) |
| 64 { | 63 { |
| 65 visitor->trace(m_inspectedFrames); | 64 visitor->trace(m_inspectedFrames); |
| 66 InspectorRuntimeAgent::trace(visitor); | 65 InspectorRuntimeAgent::trace(visitor); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void PageRuntimeAgent::init() | |
| 70 { | |
| 71 InspectorRuntimeAgent::init(); | |
| 72 m_instrumentingAgents->setPageRuntimeAgent(this); | |
| 73 } | |
| 74 | |
| 75 void PageRuntimeAgent::enable(ErrorString* errorString) | 68 void PageRuntimeAgent::enable(ErrorString* errorString) |
| 76 { | 69 { |
| 77 if (m_enabled) | 70 if (m_enabled) |
| 78 return; | 71 return; |
| 79 | 72 |
| 80 InspectorRuntimeAgent::enable(errorString); | 73 InspectorRuntimeAgent::enable(errorString); |
| 74 m_instrumentingAgents->setPageRuntimeAgent(this); |
| 81 | 75 |
| 82 // Only report existing contexts if the page did commit load, otherwise we m
ay | 76 // Only report existing contexts if the page did commit load, otherwise we m
ay |
| 83 // unintentionally initialize contexts in the frames which may trigger some
listeners | 77 // unintentionally initialize contexts in the frames which may trigger some
listeners |
| 84 // that are expected to be triggered only after the load is committed, see h
ttp://crbug.com/131623 | 78 // that are expected to be triggered only after the load is committed, see h
ttp://crbug.com/131623 |
| 85 if (m_mainWorldContextCreated) | 79 if (m_client->didCommitLoadFired()) |
| 86 reportExecutionContextCreation(); | 80 reportExecutionContextCreation(); |
| 87 } | 81 } |
| 88 | 82 |
| 89 void PageRuntimeAgent::disable(ErrorString* errorString) | 83 void PageRuntimeAgent::disable(ErrorString* errorString) |
| 90 { | 84 { |
| 91 if (!m_enabled) | 85 if (!m_enabled) |
| 92 return; | 86 return; |
| 87 m_instrumentingAgents->setPageRuntimeAgent(nullptr); |
| 93 InspectorRuntimeAgent::disable(errorString); | 88 InspectorRuntimeAgent::disable(errorString); |
| 94 } | 89 } |
| 95 | 90 |
| 96 void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame) | 91 void PageRuntimeAgent::didClearDocumentOfWindowObject(LocalFrame* frame) |
| 97 { | 92 { |
| 98 m_mainWorldContextCreated = true; | |
| 99 | |
| 100 if (!m_enabled) | |
| 101 return; | |
| 102 ASSERT(frontend()); | 93 ASSERT(frontend()); |
| 103 | |
| 104 if (frame == m_inspectedFrames->root()) | 94 if (frame == m_inspectedFrames->root()) |
| 105 m_v8RuntimeAgent->clearInspectedObjects(); | 95 m_v8RuntimeAgent->clearInspectedObjects(); |
| 106 frame->script().initializeMainWorld(); | 96 frame->script().initializeMainWorld(); |
| 107 } | 97 } |
| 108 | 98 |
| 109 void PageRuntimeAgent::didCreateScriptContext(LocalFrame* frame, ScriptState* sc
riptState, SecurityOrigin* origin, int worldId) | 99 void PageRuntimeAgent::didCreateScriptContext(LocalFrame* frame, ScriptState* sc
riptState, SecurityOrigin* origin, int worldId) |
| 110 { | 100 { |
| 111 if (!m_enabled) | |
| 112 return; | |
| 113 ASSERT(frontend()); | 101 ASSERT(frontend()); |
| 114 bool isMainWorld = worldId == MainWorldId; | 102 bool isMainWorld = worldId == MainWorldId; |
| 115 String originString = origin ? origin->toRawString() : ""; | 103 String originString = origin ? origin->toRawString() : ""; |
| 116 String frameId = IdentifiersFactory::frameId(frame); | 104 String frameId = IdentifiersFactory::frameId(frame); |
| 117 reportExecutionContext(scriptState, isMainWorld, originString, frameId); | 105 reportExecutionContext(scriptState, isMainWorld, originString, frameId); |
| 118 } | 106 } |
| 119 | 107 |
| 120 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState*
scriptState) | 108 void PageRuntimeAgent::willReleaseScriptContext(LocalFrame* frame, ScriptState*
scriptState) |
| 121 { | 109 { |
| 122 reportExecutionContextDestroyed(scriptState); | 110 reportExecutionContextDestroyed(scriptState); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 154 |
| 167 void PageRuntimeAgent::reportExecutionContext(ScriptState* scriptState, bool isP
ageContext, const String& origin, const String& frameId) | 155 void PageRuntimeAgent::reportExecutionContext(ScriptState* scriptState, bool isP
ageContext, const String& origin, const String& frameId) |
| 168 { | 156 { |
| 169 DOMWrapperWorld& world = scriptState->world(); | 157 DOMWrapperWorld& world = scriptState->world(); |
| 170 String humanReadableName = world.isIsolatedWorld() ? world.isolatedWorldHuma
nReadableName() : ""; | 158 String humanReadableName = world.isIsolatedWorld() ? world.isolatedWorldHuma
nReadableName() : ""; |
| 171 String type = isPageContext ? "" : "Extension"; | 159 String type = isPageContext ? "" : "Extension"; |
| 172 InspectorRuntimeAgent::reportExecutionContextCreated(scriptState, type, orig
in, humanReadableName, frameId); | 160 InspectorRuntimeAgent::reportExecutionContextCreated(scriptState, type, orig
in, humanReadableName, frameId); |
| 173 } | 161 } |
| 174 | 162 |
| 175 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |