Index: Source/core/inspector/InjectedScript.cpp |
diff --git a/Source/core/inspector/InjectedScript.cpp b/Source/core/inspector/InjectedScript.cpp |
index 363be6a0266303ebfc6ba7fd9c0a69bce6f46960..e11798ec5d1ad5fa18e9f58e9b1f6063f29f738f 100644 |
--- a/Source/core/inspector/InjectedScript.cpp |
+++ b/Source/core/inspector/InjectedScript.cpp |
@@ -42,6 +42,17 @@ |
#include "platform/JSONValues.h" |
#include "wtf/text/WTFString.h" |
+// Includes added for Dart |
+#include "bindings/core/dart/DartHandleProxy.h" |
+#include "bindings/core/dart/DartInjectedScript.h" |
+#include "bindings/core/dart/DartInjectedScriptManager.h" |
+#include "bindings/core/dart/DartPersistentValue.h" |
+#include "bindings/core/dart/DartScriptDebugServer.h" |
+#include "bindings/core/v8/V8RecursionScope.h" |
+ |
+#include <dart_api.h> |
+// End of includes added for Dart |
+ |
using blink::TypeBuilder::Array; |
using blink::TypeBuilder::Debugger::CallFrame; |
using blink::TypeBuilder::Debugger::CollectionEntry; |
@@ -375,6 +386,31 @@ PassRefPtr<Array<CallFrame> > InjectedScript::wrapCallFrames(const ScriptValue& |
PassRefPtr<TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapObject(const ScriptValue& value, const String& groupName, bool generatePreview) const |
{ |
ASSERT(!isEmpty()); |
+ |
+ { |
+ // Start of Dart specific code. |
+ // This code is required to make objects logged to the console show up with a Dart view. |
+ // This hack should go away once custom formatter code is available in Chrome 47. |
+ |
+ ScriptState* state = value.scriptState(); |
+ v8::Context::Scope v8Scope(state->context()); |
+ |
+ v8::Handle<v8::Value> v8Handle = value.v8Value(); |
+ if (v8Handle->IsObject()) { |
+ if (DartHandleProxy::isDartProxy(v8Handle, state->isolate())) { |
+ DartPersistentValue* dartPersistentValue = DartHandleProxy::readPointerFromProxy(v8Handle); |
+ // If the isolate is dead we fall back to the default JS view of the Dart object. |
+ if (dartPersistentValue->isIsolateAlive()) { |
+ DartScopes scopes(v8Handle.As<v8::Object>()); |
+ DartScriptState* scriptState = DartUtilities::currentDartScriptState(); |
+ DartInjectedScript* dartInjectedScript = DartScriptDebugServer::shared().injectedScriptManager()->injectedScriptFor(scriptState); |
+ return dartInjectedScript->wrapDartObject(dartPersistentValue->value(), groupName, generatePreview); |
+ } |
+ } |
+ } |
+ } |
+ // End of Dart specific code. |
+ |
ScriptFunctionCall wrapFunction(injectedScriptObject(), "wrapObject"); |
wrapFunction.appendArgument(value); |
wrapFunction.appendArgument(groupName); |