Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: Source/core/inspector/PageRuntimeAgent.cpp

Issue 1118963002: Revert of DevTools: remove dependency of most agents on InspectorPageAgent (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/PageRuntimeAgent.h ('k') | Source/web/WebDevToolsAgentImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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"
43 #include "core/inspector/InstrumentingAgents.h" 44 #include "core/inspector/InstrumentingAgents.h"
44 #include "core/page/Page.h" 45 #include "core/page/Page.h"
45 #include "platform/weborigin/SecurityOrigin.h" 46 #include "platform/weborigin/SecurityOrigin.h"
46 47
47 namespace blink { 48 namespace blink {
48 49
49 static int s_nextDebuggerId = 1; 50 static int s_nextDebuggerId = 1;
50 51
51 PageRuntimeAgent::PageRuntimeAgent(LocalFrame* inspectedFrame, InjectedScriptMan ager* injectedScriptManager, Client* client, ScriptDebugServer* scriptDebugServe r) 52 PageRuntimeAgent::PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, Client* client, ScriptDebugServer* scriptDebugServer, InspectorPageAgent* pageA gent)
52 : InspectorRuntimeAgent(injectedScriptManager, scriptDebugServer, client) 53 : InspectorRuntimeAgent(injectedScriptManager, scriptDebugServer, client)
53 , m_inspectedFrame(inspectedFrame) 54 , m_pageAgent(pageAgent)
54 , m_mainWorldContextCreated(false) 55 , m_mainWorldContextCreated(false)
55 , m_debuggerId(s_nextDebuggerId++) 56 , m_debuggerId(s_nextDebuggerId++)
56 { 57 {
57 } 58 }
58 59
59 PageRuntimeAgent::~PageRuntimeAgent() 60 PageRuntimeAgent::~PageRuntimeAgent()
60 { 61 {
61 #if !ENABLE(OILPAN) 62 #if !ENABLE(OILPAN)
62 m_instrumentingAgents->setPageRuntimeAgent(0); 63 m_instrumentingAgents->setPageRuntimeAgent(0);
63 #endif 64 #endif
64 } 65 }
65 66
66 DEFINE_TRACE(PageRuntimeAgent) 67 DEFINE_TRACE(PageRuntimeAgent)
67 { 68 {
68 visitor->trace(m_inspectedFrame); 69 visitor->trace(m_pageAgent);
69 InspectorRuntimeAgent::trace(visitor); 70 InspectorRuntimeAgent::trace(visitor);
70 } 71 }
71 72
72 void PageRuntimeAgent::init() 73 void PageRuntimeAgent::init()
73 { 74 {
74 m_instrumentingAgents->setPageRuntimeAgent(this); 75 m_instrumentingAgents->setPageRuntimeAgent(this);
75 } 76 }
76 77
77 void PageRuntimeAgent::enable(ErrorString* errorString) 78 void PageRuntimeAgent::enable(ErrorString* errorString)
78 { 79 {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (it == m_scriptStateToId.end()) 123 if (it == m_scriptStateToId.end())
123 return; 124 return;
124 int id = it->value; 125 int id = it->value;
125 m_scriptStateToId.remove(scriptState); 126 m_scriptStateToId.remove(scriptState);
126 frontend()->executionContextDestroyed(id); 127 frontend()->executionContextDestroyed(id);
127 } 128 }
128 129
129 InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId) 130 InjectedScript PageRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId)
130 { 131 {
131 if (!executionContextId) { 132 if (!executionContextId) {
132 ScriptState* scriptState = ScriptState::forMainWorld(m_inspectedFrame); 133 ScriptState* scriptState = ScriptState::forMainWorld(m_pageAgent->inspec tedFrame());
133 InjectedScript result = injectedScriptManager()->injectedScriptFor(scrip tState); 134 InjectedScript result = injectedScriptManager()->injectedScriptFor(scrip tState);
134 if (result.isEmpty()) 135 if (result.isEmpty())
135 *errorString = "Internal error: main world execution context not fou nd."; 136 *errorString = "Internal error: main world execution context not fou nd.";
136 return result; 137 return result;
137 } 138 }
138 InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId (*executionContextId); 139 InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId (*executionContextId);
139 if (injectedScript.isEmpty()) 140 if (injectedScript.isEmpty())
140 *errorString = "Execution context with given id not found."; 141 *errorString = "Execution context with given id not found.";
141 return injectedScript; 142 return injectedScript;
142 } 143 }
143 144
144 void PageRuntimeAgent::muteConsole() 145 void PageRuntimeAgent::muteConsole()
145 { 146 {
146 FrameConsole::mute(); 147 FrameConsole::mute();
147 } 148 }
148 149
149 void PageRuntimeAgent::unmuteConsole() 150 void PageRuntimeAgent::unmuteConsole()
150 { 151 {
151 FrameConsole::unmute(); 152 FrameConsole::unmute();
152 } 153 }
153 154
154 void PageRuntimeAgent::reportExecutionContextCreation() 155 void PageRuntimeAgent::reportExecutionContextCreation()
155 { 156 {
156 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts; 157 Vector<std::pair<ScriptState*, SecurityOrigin*> > isolatedContexts;
157 for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseN ext(m_inspectedFrame)) { 158 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre e().traverseNext(m_pageAgent->inspectedFrame())) {
158 if (!frame->isLocalFrame()) 159 if (!frame->isLocalFrame())
159 continue; 160 continue;
160 LocalFrame* localFrame = toLocalFrame(frame); 161 LocalFrame* localFrame = toLocalFrame(frame);
161 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript)) 162 if (!localFrame->script().canExecuteScripts(NotAboutToExecuteScript))
162 continue; 163 continue;
163 String frameId = InspectorIdentifiers<LocalFrame>::identifier(localFrame ); 164 String frameId = InspectorIdentifiers<LocalFrame>::identifier(localFrame );
164 165
165 // Ensure execution context is created. 166 // Ensure execution context is created.
166 // If initializeMainWorld returns true, then is registered by didCreateS criptContext 167 // If initializeMainWorld returns true, then is registered by didCreateS criptContext
167 if (!localFrame->script().initializeMainWorld()) 168 if (!localFrame->script().initializeMainWorld())
168 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId); 169 addExecutionContextToFrontend(ScriptState::forMainWorld(localFrame), true, "", frameId);
169 localFrame->script().collectIsolatedContexts(isolatedContexts); 170 localFrame->script().collectIsolatedContexts(isolatedContexts);
170 if (isolatedContexts.isEmpty()) 171 if (isolatedContexts.isEmpty())
171 continue; 172 continue;
172 for (const auto& pair : isolatedContexts) { 173 for (const auto& pair : isolatedContexts) {
173 String originString = pair.second ? pair.second->toRawString() : ""; 174 String originString = pair.second ? pair.second->toRawString() : "";
174 addExecutionContextToFrontend(pair.first, false, originString, frame Id); 175 addExecutionContextToFrontend(pair.first, false, originString, frame Id);
175 } 176 }
176 isolatedContexts.clear(); 177 isolatedContexts.clear();
177 } 178 }
178 } 179 }
179 180
180 } // namespace blink 181 } // namespace blink
181 182
OLDNEW
« no previous file with comments | « Source/core/inspector/PageRuntimeAgent.h ('k') | Source/web/WebDevToolsAgentImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698