OLD | NEW |
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return false; | 179 return false; |
180 return true; | 180 return true; |
181 } | 181 } |
182 | 182 |
183 bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Local<v8:
:Array> array, v8::Local<v8::String> property, const String16& groupName, bool f
orceValueType, bool generatePreview) const | 183 bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Local<v8:
:Array> array, v8::Local<v8::String> property, const String16& groupName, bool f
orceValueType, bool generatePreview) const |
184 { | 184 { |
185 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapPropertyInArray"); | 185 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapPropertyInArray"); |
186 function.appendArgument(array); | 186 function.appendArgument(array); |
187 function.appendArgument(property); | 187 function.appendArgument(property); |
188 function.appendArgument(groupName); | 188 function.appendArgument(groupName); |
189 function.appendArgument(canAccessInspectedWindow()); | |
190 function.appendArgument(forceValueType); | 189 function.appendArgument(forceValueType); |
191 function.appendArgument(generatePreview); | 190 function.appendArgument(generatePreview); |
192 bool hadException = false; | 191 bool hadException = false; |
193 function.call(hadException); | 192 function.call(hadException); |
194 return !hasInternalError(errorString, hadException); | 193 return !hasInternalError(errorString, hadException); |
195 } | 194 } |
196 | 195 |
197 bool InjectedScript::wrapObjectsInArray(ErrorString* errorString, v8::Local<v8::
Array> array, const String16& groupName, bool forceValueType, bool generatePrevi
ew) const | 196 bool InjectedScript::wrapObjectsInArray(ErrorString* errorString, v8::Local<v8::
Array> array, const String16& groupName, bool forceValueType, bool generatePrevi
ew) const |
198 { | 197 { |
199 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapObjectsInArray"); | 198 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapObjectsInArray"); |
200 function.appendArgument(array); | 199 function.appendArgument(array); |
201 function.appendArgument(groupName); | 200 function.appendArgument(groupName); |
202 function.appendArgument(canAccessInspectedWindow()); | |
203 function.appendArgument(forceValueType); | 201 function.appendArgument(forceValueType); |
204 function.appendArgument(generatePreview); | 202 function.appendArgument(generatePreview); |
205 bool hadException = false; | 203 bool hadException = false; |
206 function.call(hadException); | 204 function.call(hadException); |
207 return !hasInternalError(errorString, hadException); | 205 return !hasInternalError(errorString, hadException); |
208 } | 206 } |
209 | 207 |
210 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* errorString, v8
::Local<v8::Value> value, const String16& groupName, bool forceValueType, bool g
eneratePreview) const | 208 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* errorString, v8
::Local<v8::Value> value, const String16& groupName, bool forceValueType, bool g
eneratePreview) const |
211 { | 209 { |
212 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapObject"); | 210 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapObject"); |
213 function.appendArgument(value); | 211 function.appendArgument(value); |
214 function.appendArgument(groupName); | 212 function.appendArgument(groupName); |
215 function.appendArgument(canAccessInspectedWindow()); | |
216 function.appendArgument(forceValueType); | 213 function.appendArgument(forceValueType); |
217 function.appendArgument(generatePreview); | 214 function.appendArgument(generatePreview); |
218 bool hadException = false; | 215 bool hadException = false; |
219 v8::Local<v8::Value> r = function.call(hadException); | 216 v8::Local<v8::Value> r = function.call(hadException); |
220 if (hasInternalError(errorString, hadException || r.IsEmpty())) | 217 if (hasInternalError(errorString, hadException || r.IsEmpty())) |
221 return v8::MaybeLocal<v8::Value>(); | 218 return v8::MaybeLocal<v8::Value>(); |
222 return r; | 219 return r; |
223 } | 220 } |
224 | 221 |
225 std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::L
ocal<v8::Value> table, v8::Local<v8::Value> columns) const | 222 std::unique_ptr<protocol::Runtime::RemoteObject> InjectedScript::wrapTable(v8::L
ocal<v8::Value> table, v8::Local<v8::Value> columns) const |
226 { | 223 { |
227 v8::HandleScope handles(m_context->isolate()); | 224 v8::HandleScope handles(m_context->isolate()); |
228 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapTable"); | 225 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "wrapTable"); |
229 function.appendArgument(canAccessInspectedWindow()); | |
230 function.appendArgument(table); | 226 function.appendArgument(table); |
231 if (columns.IsEmpty()) | 227 if (columns.IsEmpty()) |
232 function.appendArgument(false); | 228 function.appendArgument(false); |
233 else | 229 else |
234 function.appendArgument(columns); | 230 function.appendArgument(columns); |
235 bool hadException = false; | 231 bool hadException = false; |
236 v8::Local<v8::Value> r = function.call(hadException); | 232 v8::Local<v8::Value> r = function.call(hadException); |
237 if (hadException) | 233 if (hadException) |
238 return nullptr; | 234 return nullptr; |
239 protocol::ErrorSupport errors; | 235 protocol::ErrorSupport errors; |
(...skipping 23 matching lines...) Expand all Loading... |
263 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) | 259 void InjectedScript::setCustomObjectFormatterEnabled(bool enabled) |
264 { | 260 { |
265 v8::HandleScope handles(m_context->isolate()); | 261 v8::HandleScope handles(m_context->isolate()); |
266 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "setCustomObjectFormatterEnabled"); | 262 V8FunctionCall function(m_context->debugger(), m_context->context(), v8Value
(), "setCustomObjectFormatterEnabled"); |
267 function.appendArgument(enabled); | 263 function.appendArgument(enabled); |
268 bool hadException = false; | 264 bool hadException = false; |
269 function.call(hadException); | 265 function.call(hadException); |
270 DCHECK(!hadException); | 266 DCHECK(!hadException); |
271 } | 267 } |
272 | 268 |
273 bool InjectedScript::canAccessInspectedWindow() const | |
274 { | |
275 v8::Local<v8::Context> callingContext = m_context->isolate()->GetCallingCont
ext(); | |
276 if (callingContext.IsEmpty()) | |
277 return true; | |
278 return m_context->debugger()->client()->callingContextCanAccessContext(calli
ngContext, m_context->context()); | |
279 } | |
280 | |
281 v8::Local<v8::Value> InjectedScript::v8Value() const | 269 v8::Local<v8::Value> InjectedScript::v8Value() const |
282 { | 270 { |
283 return m_value.Get(m_context->isolate()); | 271 return m_value.Get(m_context->isolate()); |
284 } | 272 } |
285 | 273 |
286 v8::Local<v8::Value> InjectedScript::lastEvaluationResult() const | 274 v8::Local<v8::Value> InjectedScript::lastEvaluationResult() const |
287 { | 275 { |
288 if (m_lastEvaluationResult.IsEmpty()) | 276 if (m_lastEvaluationResult.IsEmpty()) |
289 return v8::Undefined(m_context->isolate()); | 277 return v8::Undefined(m_context->isolate()); |
290 return m_lastEvaluationResult.Get(m_context->isolate()); | 278 return m_lastEvaluationResult.Get(m_context->isolate()); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) | 494 void InjectedScript::CallFrameScope::findInjectedScript(V8InspectorSessionImpl*
session) |
507 { | 495 { |
508 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err
orString, m_remoteCallFrameId); | 496 std::unique_ptr<RemoteCallFrameId> remoteId = RemoteCallFrameId::parse(m_err
orString, m_remoteCallFrameId); |
509 if (!remoteId) | 497 if (!remoteId) |
510 return; | 498 return; |
511 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); | 499 m_frameOrdinal = static_cast<size_t>(remoteId->frameOrdinal()); |
512 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); | 500 m_injectedScript = session->findInjectedScript(m_errorString, remoteId.get()
); |
513 } | 501 } |
514 | 502 |
515 } // namespace blink | 503 } // namespace blink |
OLD | NEW |