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

Unified Diff: Source/WebCore/bindings/dart/DartNativeUtilities.cpp

Issue 12477005: Enable print forwarding. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/bindings/dart/DartNativeUtilities.cpp
diff --git a/Source/WebCore/bindings/dart/DartNativeUtilities.cpp b/Source/WebCore/bindings/dart/DartNativeUtilities.cpp
index a4b567fd0a2bf02dc6ba8ba94fc698a330cf12cb..06d046b5cb550c768f626e74448f6fda34b290bb 100644
--- a/Source/WebCore/bindings/dart/DartNativeUtilities.cpp
+++ b/Source/WebCore/bindings/dart/DartNativeUtilities.cpp
@@ -36,7 +36,9 @@
#include "DartDOMWrapper.h"
#include "DartDocument.h"
#include "DartUtilities.h"
+#include "Frame.h"
#include "RuntimeEnabledFeatures.h"
+#include "V8Converter.h"
#include "npruntime_impl.h"
#include <bindings/npruntime.h>
@@ -90,6 +92,28 @@ fail:
ASSERT_NOT_REACHED();
}
+static void forwardingPrint(Dart_NativeArguments args)
+{
+ v8::HandleScope v8Scope;
+ ScriptExecutionContext* scriptExecutionContext = DartUtilities::scriptExecutionContext();
+ ASSERT(scriptExecutionContext);
+
+ DartController* dartController = DartController::retrieve(scriptExecutionContext);
+ if (!dartController)
+ return;
+
+ v8::Handle<v8::Context> v8Context = dartController->frame()->script()->mainWorldContext();
+ v8::Context::Scope scope(v8Context);
+ v8::TryCatch tryCatch;
+
+ v8::Handle<v8::Value> function = v8Context->Global()->Get(v8::String::New("dartPrint"));
+ if (function.IsEmpty() || !function->IsFunction())
+ return;
+
+ v8::Handle<v8::Value> message = V8Converter::stringToV8(Dart_GetNativeArgument(args, 0));
+ function.As<v8::Function>()->Call(v8Context->Global(), 1, &message);
+}
+
static void getNewIsolateId(Dart_NativeArguments args)
{
DartApiScope dartApiScope;
@@ -276,6 +300,8 @@ Dart_NativeFunction domResolver(Dart_Handle name, int argumentCount)
return topLevelWindow;
if (argumentCount == 1 && str == "Utils_print")
return print;
+ if (argumentCount == 1 && str == "Utils_forwardingPrint")
+ return forwardingPrint;
if (argumentCount == 1 && str == "Utils_spawnDomFunction")
return spawnDomFunction;
if (argumentCount == 0 && str == "Utils_getNewIsolateId")

Powered by Google App Engine
This is Rietveld 408576698