| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 , m_native(injectedScriptNative) | 69 , m_native(injectedScriptNative) |
| 70 , m_contextId(contextId) | 70 , m_contextId(contextId) |
| 71 { | 71 { |
| 72 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); | 72 m_context.SetWeak(this, &weakCallback, v8::WeakCallbackType::kParameter); |
| 73 } | 73 } |
| 74 | 74 |
| 75 InjectedScript::~InjectedScript() | 75 InjectedScript::~InjectedScript() |
| 76 { | 76 { |
| 77 } | 77 } |
| 78 | 78 |
| 79 void InjectedScript::getCollectionEntries(ErrorString* errorString, const String
16& objectId, OwnPtr<Array<CollectionEntry>>* result) | |
| 80 { | |
| 81 v8::HandleScope handles(m_isolate); | |
| 82 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getCol
lectionEntries"); | |
| 83 function.appendArgument(objectId); | |
| 84 OwnPtr<protocol::Value> resultValue = makeCall(function); | |
| 85 protocol::ErrorSupport errors(errorString); | |
| 86 *result = Array<CollectionEntry>::parse(resultValue.get(), &errors); | |
| 87 } | |
| 88 | |
| 89 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) | 79 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) |
| 90 { | 80 { |
| 91 v8::HandleScope handles(m_isolate); | 81 v8::HandleScope handles(m_isolate); |
| 92 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getPro
perties"); | 82 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "getPro
perties"); |
| 93 function.appendArgument(objectId); | 83 function.appendArgument(objectId); |
| 94 function.appendArgument(ownProperties); | 84 function.appendArgument(ownProperties); |
| 95 function.appendArgument(accessorPropertiesOnly); | 85 function.appendArgument(accessorPropertiesOnly); |
| 96 function.appendArgument(generatePreview); | 86 function.appendArgument(generatePreview); |
| 97 | 87 |
| 98 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); | 88 OwnPtr<protocol::Value> result = makeCallWithExceptionDetails(function, exce
ptionDetails); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (!wrapValue(error, property, groupName, forceValueType, generatePreview).
ToLocal(&wrappedProperty)) | 149 if (!wrapValue(error, property, groupName, forceValueType, generatePreview).
ToLocal(&wrappedProperty)) |
| 160 return false; | 150 return false; |
| 161 v8::Maybe<bool> success = object->Set(context(), key, wrappedProperty); | 151 v8::Maybe<bool> success = object->Set(context(), key, wrappedProperty); |
| 162 if (success.IsNothing() || !success.FromJust()) { | 152 if (success.IsNothing() || !success.FromJust()) { |
| 163 *error = "Internal error."; | 153 *error = "Internal error."; |
| 164 return false; | 154 return false; |
| 165 } | 155 } |
| 166 return true; | 156 return true; |
| 167 } | 157 } |
| 168 | 158 |
| 159 bool InjectedScript::wrapPropertyInArray(ErrorString* errorString, v8::Local<v8:
:Array> array, v8::Local<v8::String> property, const String16& groupName, bool f
orceValueType, bool generatePreview) const |
| 160 { |
| 161 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapPr
opertyInArray"); |
| 162 function.appendArgument(array); |
| 163 function.appendArgument(property); |
| 164 function.appendArgument(groupName); |
| 165 function.appendArgument(canAccessInspectedWindow()); |
| 166 function.appendArgument(forceValueType); |
| 167 function.appendArgument(generatePreview); |
| 168 bool hadException = false; |
| 169 callFunctionWithEvalEnabled(function, hadException); |
| 170 if (hadException) |
| 171 *errorString = "Internal error."; |
| 172 return !hadException; |
| 173 } |
| 174 |
| 169 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Loca
l<v8::Value> value, const String16& groupName, bool forceValueType, bool generat
ePreview) const | 175 v8::MaybeLocal<v8::Value> InjectedScript::wrapValue(ErrorString* error, v8::Loca
l<v8::Value> value, const String16& groupName, bool forceValueType, bool generat
ePreview) const |
| 170 { | 176 { |
| 171 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb
ject"); | 177 V8FunctionCall function(m_manager->debugger(), context(), v8Value(), "wrapOb
ject"); |
| 172 function.appendArgument(value); | 178 function.appendArgument(value); |
| 173 function.appendArgument(groupName); | 179 function.appendArgument(groupName); |
| 174 function.appendArgument(canAccessInspectedWindow()); | 180 function.appendArgument(canAccessInspectedWindow()); |
| 175 function.appendArgument(forceValueType); | 181 function.appendArgument(forceValueType); |
| 176 function.appendArgument(generatePreview); | 182 function.appendArgument(generatePreview); |
| 177 bool hadException = false; | 183 bool hadException = false; |
| 178 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; | 184 v8::Local<v8::Value> r = callFunctionWithEvalEnabled(function, hadException)
; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 return; | 425 return; |
| 420 *result = remoteObject.release(); | 426 *result = remoteObject.release(); |
| 421 if (exceptionDetails) | 427 if (exceptionDetails) |
| 422 *exceptionDetails = createExceptionDetails(tryCatch.Message()); | 428 *exceptionDetails = createExceptionDetails(tryCatch.Message()); |
| 423 if (wasThrown) | 429 if (wasThrown) |
| 424 *wasThrown = true; | 430 *wasThrown = true; |
| 425 } | 431 } |
| 426 } | 432 } |
| 427 | 433 |
| 428 } // namespace blink | 434 } // namespace blink |
| OLD | NEW |