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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/InjectedScript.cpp

Issue 1769273004: Remove V8RecrusionScope, cleanup call sites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 18 matching lines...) Expand all
29 */ 29 */
30 30
31 #include "platform/v8_inspector/InjectedScript.h" 31 #include "platform/v8_inspector/InjectedScript.h"
32 32
33 #include "platform/inspector_protocol/Parser.h" 33 #include "platform/inspector_protocol/Parser.h"
34 #include "platform/inspector_protocol/String16.h" 34 #include "platform/inspector_protocol/String16.h"
35 #include "platform/inspector_protocol/Values.h" 35 #include "platform/inspector_protocol/Values.h"
36 #include "platform/v8_inspector/InjectedScriptHost.h" 36 #include "platform/v8_inspector/InjectedScriptHost.h"
37 #include "platform/v8_inspector/InjectedScriptManager.h" 37 #include "platform/v8_inspector/InjectedScriptManager.h"
38 #include "platform/v8_inspector/RemoteObjectId.h" 38 #include "platform/v8_inspector/RemoteObjectId.h"
39 #include "platform/v8_inspector/V8DebuggerImpl.h"
39 #include "platform/v8_inspector/V8FunctionCall.h" 40 #include "platform/v8_inspector/V8FunctionCall.h"
40 #include "platform/v8_inspector/V8StringUtil.h" 41 #include "platform/v8_inspector/V8StringUtil.h"
41 #include "platform/v8_inspector/public/V8Debugger.h" 42 #include "platform/v8_inspector/public/V8Debugger.h"
42 #include "platform/v8_inspector/public/V8DebuggerClient.h" 43 #include "platform/v8_inspector/public/V8DebuggerClient.h"
43 #include "platform/v8_inspector/public/V8ToProtocolValue.h" 44 #include "platform/v8_inspector/public/V8ToProtocolValue.h"
44 45
45 using blink::protocol::Array; 46 using blink::protocol::Array;
46 using blink::protocol::Debugger::CallFrame; 47 using blink::protocol::Debugger::CallFrame;
47 using blink::protocol::Debugger::CollectionEntry; 48 using blink::protocol::Debugger::CollectionEntry;
48 using blink::protocol::Debugger::FunctionDetails; 49 using blink::protocol::Debugger::FunctionDetails;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (originScriptId) 109 if (originScriptId)
109 exceptionDetails->setScriptId(String16::number(originScriptId)); 110 exceptionDetails->setScriptId(String16::number(originScriptId));
110 return exceptionDetails.release(); 111 return exceptionDetails.release();
111 } 112 }
112 113
113 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data) 114 static void weakCallback(const v8::WeakCallbackInfo<InjectedScript>& data)
114 { 115 {
115 data.GetParameter()->dispose(); 116 data.GetParameter()->dispose();
116 } 117 }
117 118
118 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con text> context, v8::Local<v8::Object> object, V8DebuggerClient* client, PassOwnPt r<InjectedScriptNative> injectedScriptNative, int contextId) 119 InjectedScript::InjectedScript(InjectedScriptManager* manager, v8::Local<v8::Con text> context, v8::Local<v8::Object> object, PassOwnPtr<InjectedScriptNative> in jectedScriptNative, int contextId)
119 : m_manager(manager) 120 : m_manager(manager)
120 , m_isolate(context->GetIsolate()) 121 , m_isolate(context->GetIsolate())
121 , m_context(m_isolate, context) 122 , m_context(m_isolate, context)
122 , m_value(m_isolate, object) 123 , m_value(m_isolate, object)
123 , m_client(client)
124 , m_native(injectedScriptNative) 124 , m_native(injectedScriptNative)
125 , m_contextId(contextId) 125 , m_contextId(contextId)
126 { 126 {
127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); 127 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter);
128 } 128 }
129 129
130 InjectedScript::~InjectedScript() 130 InjectedScript::~InjectedScript()
131 { 131 {
132 } 132 }
133 133
134 void InjectedScript::evaluate(ErrorString* errorString, const String16& expressi on, const String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bo ol>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails) 134 void InjectedScript::evaluate(ErrorString* errorString, const String16& expressi on, const String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe<bo ol>* wasThrown, Maybe<protocol::Runtime::ExceptionDetails>* exceptionDetails)
135 { 135 {
136 v8::HandleScope handles(m_isolate); 136 v8::HandleScope handles(m_isolate);
137 V8FunctionCall function(m_client, context(), v8Value(), "evaluate"); 137 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evalua te");
138 function.appendArgument(expression); 138 function.appendArgument(expression);
139 function.appendArgument(objectGroup); 139 function.appendArgument(objectGroup);
140 function.appendArgument(includeCommandLineAPI); 140 function.appendArgument(includeCommandLineAPI);
141 function.appendArgument(returnByValue); 141 function.appendArgument(returnByValue);
142 function.appendArgument(generatePreview); 142 function.appendArgument(generatePreview);
143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); 143 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails);
144 } 144 }
145 145
146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String16& ob jectId, const String16& expression, const String16& arguments, bool returnByValu e, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe< bool>* wasThrown) 146 void InjectedScript::callFunctionOn(ErrorString* errorString, const String16& ob jectId, const String16& expression, const String16& arguments, bool returnByValu e, bool generatePreview, OwnPtr<protocol::Runtime::RemoteObject>* result, Maybe< bool>* wasThrown)
147 { 147 {
148 v8::HandleScope handles(m_isolate); 148 v8::HandleScope handles(m_isolate);
149 V8FunctionCall function(m_client, context(), v8Value(), "callFunctionOn"); 149 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "callFu nctionOn");
150 function.appendArgument(objectId); 150 function.appendArgument(objectId);
151 function.appendArgument(expression); 151 function.appendArgument(expression);
152 function.appendArgument(arguments); 152 function.appendArgument(arguments);
153 function.appendArgument(returnByValue); 153 function.appendArgument(returnByValue);
154 function.appendArgument(generatePreview); 154 function.appendArgument(generatePreview);
155 *result = makeEvalCall(errorString, function, wasThrown); 155 *result = makeEvalCall(errorString, function, wasThrown);
156 } 156 }
157 157
158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: :Object> callFrames, const String16& callFrameId, const String16& expression, co nst String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<pro tocol::Runtime::ExceptionDetails>* exceptionDetails) 158 void InjectedScript::evaluateOnCallFrame(ErrorString* errorString, v8::Local<v8: :Object> callFrames, const String16& callFrameId, const String16& expression, co nst String16& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, OwnPtr<RemoteObject>* result, Maybe<bool>* wasThrown, Maybe<pro tocol::Runtime::ExceptionDetails>* exceptionDetails)
159 { 159 {
160 v8::HandleScope handles(m_isolate); 160 v8::HandleScope handles(m_isolate);
161 V8FunctionCall function(m_client, context(), v8Value(), "evaluateOnCallFrame "); 161 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "evalua teOnCallFrame");
162 function.appendArgument(callFrames); 162 function.appendArgument(callFrames);
163 function.appendArgument(callFrameId); 163 function.appendArgument(callFrameId);
164 function.appendArgument(expression); 164 function.appendArgument(expression);
165 function.appendArgument(objectGroup); 165 function.appendArgument(objectGroup);
166 function.appendArgument(includeCommandLineAPI); 166 function.appendArgument(includeCommandLineAPI);
167 function.appendArgument(returnByValue); 167 function.appendArgument(returnByValue);
168 function.appendArgument(generatePreview); 168 function.appendArgument(generatePreview);
169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails); 169 *result = makeEvalCall(errorString, function, wasThrown, exceptionDetails);
170 } 170 }
171 171
172 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16 & functionId, OwnPtr<FunctionDetails>* result) 172 void InjectedScript::getFunctionDetails(ErrorString* errorString, const String16 & functionId, OwnPtr<FunctionDetails>* result)
173 { 173 {
174 v8::HandleScope handles(m_isolate); 174 v8::HandleScope handles(m_isolate);
175 V8FunctionCall function(m_client, context(), v8Value(), "getFunctionDetails" ); 175 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getFun ctionDetails");
176 function.appendArgument(functionId); 176 function.appendArgument(functionId);
177 OwnPtr<protocol::Value> resultValue = makeCall(function); 177 OwnPtr<protocol::Value> resultValue = makeCall(function);
178 protocol::ErrorSupport errors(errorString); 178 protocol::ErrorSupport errors(errorString);
179 *result = FunctionDetails::parse(resultValue.get(), &errors); 179 *result = FunctionDetails::parse(resultValue.get(), &errors);
180 } 180 }
181 181
182 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String 16& objectId, OwnPtr<Array<CollectionEntry>>* result) 182 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String 16& objectId, OwnPtr<Array<CollectionEntry>>* result)
183 { 183 {
184 v8::HandleScope handles(m_isolate); 184 v8::HandleScope handles(m_isolate);
185 V8FunctionCall function(m_client, context(), v8Value(), "getCollectionEntrie s"); 185 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getCol lectionEntries");
186 function.appendArgument(objectId); 186 function.appendArgument(objectId);
187 OwnPtr<protocol::Value> resultValue = makeCall(function); 187 OwnPtr<protocol::Value> resultValue = makeCall(function);
188 protocol::ErrorSupport errors(errorString); 188 protocol::ErrorSupport errors(errorString);
189 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); 189 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors);
190 } 190 }
191 191
192 void InjectedScript::getProperties(ErrorString* errorString, const String16& obj ectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, Ow nPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionD etails>* exceptionDetails) 192 void InjectedScript::getProperties(ErrorString* errorString, const String16& obj ectId, bool ownProperties, bool accessorPropertiesOnly, bool generatePreview, Ow nPtr<Array<PropertyDescriptor>>* properties, Maybe<protocol::Runtime::ExceptionD etails>* exceptionDetails)
193 { 193 {
194 v8::HandleScope handles(m_isolate); 194 v8::HandleScope handles(m_isolate);
195 V8FunctionCall function(m_client, context(), v8Value(), "getProperties"); 195 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getPro perties");
196 function.appendArgument(objectId); 196 function.appendArgument(objectId);
197 function.appendArgument(ownProperties); 197 function.appendArgument(ownProperties);
198 function.appendArgument(accessorPropertiesOnly); 198 function.appendArgument(accessorPropertiesOnly);
199 function.appendArgument(generatePreview); 199 function.appendArgument(generatePreview);
200 200
201 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); 201 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails);
202 if (exceptionDetails->isJust()) { 202 if (exceptionDetails->isJust()) {
203 // FIXME: make properties optional 203 // FIXME: make properties optional
204 *properties = Array<PropertyDescriptor>::create(); 204 *properties = Array<PropertyDescriptor>::create();
205 return; 205 return;
206 } 206 }
207 protocol::ErrorSupport errors(errorString); 207 protocol::ErrorSupport errors(errorString);
208 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors); 208 *properties = Array<PropertyDescriptor>::parse(result.get(), &errors);
209 } 209 }
210 210
211 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto col::Runtime::ExceptionDetails>* exceptionDetails) 211 void InjectedScript::getInternalProperties(ErrorString* errorString, const Strin g16& objectId, Maybe<Array<InternalPropertyDescriptor>>* properties, Maybe<proto col::Runtime::ExceptionDetails>* exceptionDetails)
212 { 212 {
213 v8::HandleScope handles(m_isolate); 213 v8::HandleScope handles(m_isolate);
214 V8FunctionCall function(m_client, context(), v8Value(), "getInternalProperti es"); 214 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getInt ernalProperties");
215 function.appendArgument(objectId); 215 function.appendArgument(objectId);
216 216
217 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails); 217 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce ptionDetails);
218 if (exceptionDetails->isJust()) 218 if (exceptionDetails->isJust())
219 return; 219 return;
220 protocol::ErrorSupport errors(errorString); 220 protocol::ErrorSupport errors(errorString);
221 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors); 221 OwnPtr<Array<InternalPropertyDescriptor>> array = Array<InternalPropertyDesc riptor>::parse(result.get(), &errors);
222 if (!errors.hasErrors() && array->length() > 0) 222 if (!errors.hasErrors() && array->length() > 0)
223 *properties = array.release(); 223 *properties = array.release();
224 } 224 }
(...skipping 10 matching lines...) Expand all
235 if (!object->getNumber("id", &boundId)) 235 if (!object->getNumber("id", &boundId))
236 return; 236 return;
237 m_native->unbind(boundId); 237 m_native->unbind(boundId);
238 } 238 }
239 239
240 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI) 240 v8::MaybeLocal<v8::Value> InjectedScript::runCompiledScript(v8::Local<v8::Script > script, bool includeCommandLineAPI)
241 { 241 {
242 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate); 242 v8::Local<v8::Symbol> commandLineAPISymbolValue = V8Debugger::commandLineAPI Symbol(m_isolate);
243 v8::Local<v8::Object> global = context()->Global(); 243 v8::Local<v8::Object> global = context()->Global();
244 if (includeCommandLineAPI) { 244 if (includeCommandLineAPI) {
245 V8FunctionCall function(m_client, context(), v8Value(), "commandLineAPI" ); 245 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "co mmandLineAPI");
246 bool hadException = false; 246 bool hadException = false;
247 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ; 247 v8::Local<v8::Value> commandLineAPI = function.call(hadException, false) ;
248 if (!hadException) 248 if (!hadException)
249 global->Set(commandLineAPISymbolValue, commandLineAPI); 249 global->Set(commandLineAPISymbolValue, commandLineAPI);
250 } 250 }
251 251
252 v8::MaybeLocal<v8::Value> maybeValue = m_client->runCompiledScript(context() , script); 252 v8::MaybeLocal<v8::Value> maybeValue = m_manager->debugger()->runCompiledScr ipt(context(), script);
253 if (includeCommandLineAPI) 253 if (includeCommandLineAPI)
254 global->Delete(context(), commandLineAPISymbolValue); 254 global->Delete(context(), commandLineAPISymbolValue);
255 255
256 return maybeValue; 256 return maybeValue;
257 } 257 }
258 258
259 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames) 259 PassOwnPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(v8::Local<v8::Object > callFrames)
260 { 260 {
261 v8::HandleScope handles(m_isolate); 261 v8::HandleScope handles(m_isolate);
262 V8FunctionCall function(m_client, context(), v8Value(), "wrapCallFrames"); 262 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapCa llFrames");
263 function.appendArgument(callFrames); 263 function.appendArgument(callFrames);
264 bool hadException = false; 264 bool hadException = false;
265 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException); 265 v8::Local<v8::Value> callFramesValue = callFunctionWithEvalEnabled(function, hadException);
266 ASSERT(!hadException); 266 ASSERT(!hadException);
267 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ; 267 OwnPtr<protocol::Value> result = toProtocolValue(context(), callFramesValue) ;
268 protocol::ErrorSupport errors; 268 protocol::ErrorSupport errors;
269 if (result && result->type() == protocol::Value::TypeArray) 269 if (result && result->type() == protocol::Value::TypeArray)
270 return Array<CallFrame>::parse(result.get(), &errors); 270 return Array<CallFrame>::parse(result.get(), &errors);
271 return Array<CallFrame>::create(); 271 return Array<CallFrame>::create();
272 } 272 }
273 273
274 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String16& groupName, bool generatePreview) const 274 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapObject(v8::Local <v8::Value> value, const String16& groupName, bool generatePreview) const
275 { 275 {
276 v8::HandleScope handles(m_isolate); 276 v8::HandleScope handles(m_isolate);
277 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); 277 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb ject");
278 v8::Local<v8::Value> wrappedObject; 278 v8::Local<v8::Value> wrappedObject;
279 ErrorString errorString; 279 ErrorString errorString;
280 if (!wrapValue(&errorString, value, groupName, generatePreview).ToLocal(&wra ppedObject)) 280 if (!wrapValue(&errorString, value, groupName, generatePreview).ToLocal(&wra ppedObject))
281 return nullptr; 281 return nullptr;
282 protocol::ErrorSupport errors; 282 protocol::ErrorSupport errors;
283 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), wra ppedObject).get(), &errors); 283 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), wra ppedObject).get(), &errors);
284 } 284 }
285 285
286 bool InjectedScript::wrapObjectProperty(ErrorString* error, v8::Local<v8::Object > object, v8::Local<v8::Value> key, const String16& groupName, bool generatePrev iew) const 286 bool InjectedScript::wrapObjectProperty(ErrorString* error, v8::Local<v8::Object > object, v8::Local<v8::Value> key, const String16& groupName, bool generatePrev iew) const
287 { 287 {
288 v8::Local<v8::Value> property; 288 v8::Local<v8::Value> property;
289 if (!object->Get(context(), key).ToLocal(&property)) { 289 if (!object->Get(context(), key).ToLocal(&property)) {
290 *error = "Internal error."; 290 *error = "Internal error.";
291 return false; 291 return false;
292 } 292 }
293 v8::Local<v8::Value> wrappedProperty; 293 v8::Local<v8::Value> wrappedProperty;
294 if (!wrapValue(error, property, groupName, generatePreview).ToLocal(&wrapped Property)) 294 if (!wrapValue(error, property, groupName, generatePreview).ToLocal(&wrapped Property))
295 return false; 295 return false;
296 v8::Maybe<bool> success = object->Set(context(), key, wrappedProperty); 296 v8::Maybe<bool> success = object->Set(context(), key, wrappedProperty);
297 if (success.IsNothing() || !success.FromJust()) { 297 if (success.IsNothing() || !success.FromJust()) {
298 *error = "Internal error."; 298 *error = "Internal error.";
299 return false; 299 return false;
300 } 300 }
301 return true; 301 return true;
302 } 302 }
303 303
304 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Loca l<v8::Value> value, const String16& groupName, bool generatePreview) const 304 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Loca l<v8::Value> value, const String16& groupName, bool generatePreview) const
305 { 305 {
306 V8FunctionCall function(m_client, context(), v8Value(), "wrapObject"); 306 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb ject");
307 function.appendArgument(value); 307 function.appendArgument(value);
308 function.appendArgument(groupName); 308 function.appendArgument(groupName);
309 function.appendArgument(canAccessInspectedWindow()); 309 function.appendArgument(canAccessInspectedWindow());
310 function.appendArgument(generatePreview); 310 function.appendArgument(generatePreview);
311 bool hadException = false; 311 bool hadException = false;
312 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ; 312 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException) ;
313 if (hadException) { 313 if (hadException) {
314 *error = "Internal error."; 314 *error = "Internal error.";
315 return v8::MaybeLocal<v8::Value>(); 315 return v8::MaybeLocal<v8::Value>();
316 } 316 }
317 return r; 317 return r;
318 } 318 }
319 319
320 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const 320 PassOwnPtr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::Local< v8::Value> table, v8::Local<v8::Value> columns) const
321 { 321 {
322 v8::HandleScope handles(m_isolate); 322 v8::HandleScope handles(m_isolate);
323 V8FunctionCall function(m_client, context(), v8Value(), "wrapTable"); 323 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapTa ble");
324 function.appendArgument(canAccessInspectedWindow()); 324 function.appendArgument(canAccessInspectedWindow());
325 function.appendArgument(table); 325 function.appendArgument(table);
326 if (columns.IsEmpty()) 326 if (columns.IsEmpty())
327 function.appendArgument(false); 327 function.appendArgument(false);
328 else 328 else
329 function.appendArgument(columns); 329 function.appendArgument(columns);
330 bool hadException = false; 330 bool hadException = false;
331 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException ); 331 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException );
332 if (hadException) 332 if (hadException)
333 return nullptr; 333 return nullptr;
334 protocol::ErrorSupport errors; 334 protocol::ErrorSupport errors;
335 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors); 335 return protocol::Runtime::RemoteObject::parse(toProtocolValue(context(), r). get(), &errors);
336 } 336 }
337 337
338 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const 338 v8::Local<v8::Value> InjectedScript::findObject(const RemoteObjectId& objectId) const
339 { 339 {
340 return m_native->objectForId(objectId.id()); 340 return m_native->objectForId(objectId.id());
341 } 341 }
342 342
343 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const 343 String16 InjectedScript::objectGroupName(const RemoteObjectId& objectId) const
344 { 344 {
345 return m_native->groupName(objectId.id()); 345 return m_native->groupName(objectId.id());
346 } 346 }
347 347
348 void InjectedScript::releaseObjectGroup(const String16& objectGroup) 348 void InjectedScript::releaseObjectGroup(const String16& objectGroup)
349 { 349 {
350 v8::HandleScope handles(m_isolate); 350 v8::HandleScope handles(m_isolate);
351 m_native->releaseObjectGroup(objectGroup); 351 m_native->releaseObjectGroup(objectGroup);
352 if (objectGroup == "console") { 352 if (objectGroup == "console") {
353 V8FunctionCall function(m_client, context(), v8Value(), "clearLastEvalua tionResult"); 353 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "cl earLastEvaluationResult");
354 bool hadException = false; 354 bool hadException = false;
355 callFunctionWithEvalEnabled(function, hadException); 355 callFunctionWithEvalEnabled(function, hadException);
356 ASSERT(!hadException); 356 ASSERT(!hadException);
357 } 357 }
358 } 358 }
359 359
360 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) 360 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled)
361 { 361 {
362 v8::HandleScope handles(m_isolate); 362 v8::HandleScope handles(m_isolate);
363 V8FunctionCall function(m_client, context(), v8Value(), "setCustomObjectForm atterEnabled"); 363 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "setCus tomObjectFormatterEnabled");
364 function.appendArgument(enabled); 364 function.appendArgument(enabled);
365 makeCall(function); 365 makeCall(function);
366 } 366 }
367 367
368 bool InjectedScript::canAccessInspectedWindow() const 368 bool InjectedScript::canAccessInspectedWindow() const
369 { 369 {
370 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext(); 370 v8::Local<v8::Context> callingContext = m_isolate->GetCallingContext();
371 if (callingContext.IsEmpty()) 371 if (callingContext.IsEmpty())
372 return true; 372 return true;
373 return m_client->callingContextCanAccessContext(callingContext, context()); 373 return m_manager->debugger()->client()->callingContextCanAccessContext(calli ngContext, context());
374 } 374 }
375 375
376 v8::Local<v8::Context> InjectedScript::context() const 376 v8::Local<v8::Context> InjectedScript::context() const
377 { 377 {
378 return m_context.Get(m_isolate); 378 return m_context.Get(m_isolate);
379 } 379 }
380 380
381 v8::Local<v8::Value> InjectedScript::v8Value() const 381 v8::Local<v8::Value> InjectedScript::v8Value() const
382 { 382 {
383 return m_value.Get(m_isolate); 383 return m_value.Get(m_isolate);
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 *errorString = "Could not find object with given id"; 491 *errorString = "Could not find object with given id";
492 return v8::MaybeLocal<v8::Value>(); 492 return v8::MaybeLocal<v8::Value>();
493 } 493 }
494 return object; 494 return object;
495 } 495 }
496 if (callArgument->hasValue()) { 496 if (callArgument->hasValue()) {
497 String16 value = callArgument->getValue(nullptr)->toJSONString(); 497 String16 value = callArgument->getValue(nullptr)->toJSONString();
498 if (callArgument->getType(String16()) == "number") 498 if (callArgument->getType(String16()) == "number")
499 value = "Number(" + value + ")"; 499 value = "Number(" + value + ")";
500 v8::Local<v8::Value> object; 500 v8::Local<v8::Value> object;
501 if (!m_client->compileAndRunInternalScript(toV8String(m_isolate, value)) .ToLocal(&object)) { 501 if (!m_manager->debugger()->compileAndRunInternalScript(context(), toV8S tring(m_isolate, value)).ToLocal(&object)) {
502 *errorString = "Couldn't parse value object in call argument"; 502 *errorString = "Couldn't parse value object in call argument";
503 return v8::MaybeLocal<v8::Value>(); 503 return v8::MaybeLocal<v8::Value>();
504 } 504 }
505 return object; 505 return object;
506 } 506 }
507 return v8::Undefined(m_isolate); 507 return v8::Undefined(m_isolate);
508 } 508 }
509 509
510 } // namespace blink 510 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698