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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/WebCore/bindings/dart/DartController.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012, Google Inc. 1 // Copyright 2012, Google Inc.
2 // All rights reserved. 2 // 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 #include "config.h" 30 #include "config.h"
31 #include "DartNativeUtilities.h" 31 #include "DartNativeUtilities.h"
32 32
33 #include "DartController.h" 33 #include "DartController.h"
34 #include "DartDOMStringMap.h" 34 #include "DartDOMStringMap.h"
35 #include "DartDOMWindow.h" 35 #include "DartDOMWindow.h"
36 #include "DartDOMWrapper.h" 36 #include "DartDOMWrapper.h"
37 #include "DartDocument.h" 37 #include "DartDocument.h"
38 #include "DartUtilities.h" 38 #include "DartUtilities.h"
39 #include "Frame.h"
39 #include "RuntimeEnabledFeatures.h" 40 #include "RuntimeEnabledFeatures.h"
41 #include "V8Converter.h"
40 #include "npruntime_impl.h" 42 #include "npruntime_impl.h"
41 43
42 #include <bindings/npruntime.h> 44 #include <bindings/npruntime.h>
43 #include <dart_api.h> 45 #include <dart_api.h>
44 #include <wtf/HashMap.h> 46 #include <wtf/HashMap.h>
45 #include <wtf/OwnArrayPtr.h> 47 #include <wtf/OwnArrayPtr.h>
46 #include <wtf/StdLibExtras.h> 48 #include <wtf/StdLibExtras.h>
47 #include <wtf/text/CString.h> 49 #include <wtf/text/CString.h>
48 #include <wtf/text/StringHash.h> 50 #include <wtf/text/StringHash.h>
49 51
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 85
84 printf("[print]: %s\n", String(message).utf8().data()); 86 printf("[print]: %s\n", String(message).utf8().data());
85 return; 87 return;
86 } 88 }
87 89
88 fail: 90 fail:
89 Dart_ThrowException(exception); 91 Dart_ThrowException(exception);
90 ASSERT_NOT_REACHED(); 92 ASSERT_NOT_REACHED();
91 } 93 }
92 94
95 /**
96 * Gadget for testing.
97 *
98 * With DART_FORWARDING_PRINT environment variable set, it invokes dartPrint
99 * JavaScript function on global object to communicate to Dart test framework.
100 */
101 static void forwardingPrint(Dart_NativeArguments args)
102 {
103 v8::HandleScope v8Scope;
104 ScriptExecutionContext* scriptExecutionContext = DartUtilities::scriptExecut ionContext();
105 ASSERT(scriptExecutionContext);
106
107 DartController* dartController = DartController::retrieve(scriptExecutionCon text);
108 if (!dartController)
109 return;
110
111 v8::Handle<v8::Context> v8Context = dartController->frame()->script()->mainW orldContext();
112 v8::Context::Scope scope(v8Context);
113 v8::TryCatch tryCatch;
114
115 v8::Handle<v8::Value> function = v8Context->Global()->Get(v8::String::New("d artPrint"));
116 if (function.IsEmpty() || !function->IsFunction())
117 return;
118
119 v8::Handle<v8::Value> message = V8Converter::stringToV8(Dart_GetNativeArgume nt(args, 0));
120 function.As<v8::Function>()->Call(v8Context->Global(), 1, &message);
121 }
122
93 static void getNewIsolateId(Dart_NativeArguments args) 123 static void getNewIsolateId(Dart_NativeArguments args)
94 { 124 {
95 DartApiScope dartApiScope; 125 DartApiScope dartApiScope;
96 static int isolateId = 0; 126 static int isolateId = 0;
97 Dart_SetReturnValue(args, DartUtilities::intToDart(isolateId++)); 127 Dart_SetReturnValue(args, DartUtilities::intToDart(isolateId++));
98 } 128 }
99 129
100 static void shadowRootSupported(Dart_NativeArguments args) 130 static void shadowRootSupported(Dart_NativeArguments args)
101 { 131 {
102 // FIXME: get rid of document. 132 // FIXME: get rid of document.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 if (Dart_NativeFunction func = htmlSnapshotResolver(name, argumentCount)) 299 if (Dart_NativeFunction func = htmlSnapshotResolver(name, argumentCount))
270 return func; 300 return func;
271 if (Dart_NativeFunction func = DartDOMStringMap::resolver(name, argumentCoun t)) 301 if (Dart_NativeFunction func = DartDOMStringMap::resolver(name, argumentCoun t))
272 return func; 302 return func;
273 303
274 String str = DartUtilities::toString(name); 304 String str = DartUtilities::toString(name);
275 if (argumentCount == 0 && str == "Utils_window") 305 if (argumentCount == 0 && str == "Utils_window")
276 return topLevelWindow; 306 return topLevelWindow;
277 if (argumentCount == 1 && str == "Utils_print") 307 if (argumentCount == 1 && str == "Utils_print")
278 return print; 308 return print;
309 if (argumentCount == 1 && str == "Utils_forwardingPrint")
310 return forwardingPrint;
279 if (argumentCount == 1 && str == "Utils_spawnDomFunction") 311 if (argumentCount == 1 && str == "Utils_spawnDomFunction")
280 return spawnDomFunction; 312 return spawnDomFunction;
281 if (argumentCount == 0 && str == "Utils_getNewIsolateId") 313 if (argumentCount == 0 && str == "Utils_getNewIsolateId")
282 return getNewIsolateId; 314 return getNewIsolateId;
283 if (argumentCount == 1 && str == "Utils_shadowRootSupported") 315 if (argumentCount == 1 && str == "Utils_shadowRootSupported")
284 return shadowRootSupported; 316 return shadowRootSupported;
285 if (argumentCount == 1 && str == "NPObject_retrieve") 317 if (argumentCount == 1 && str == "NPObject_retrieve")
286 return npObjectRetrieve; 318 return npObjectRetrieve;
287 if (argumentCount == 2 && str == "NPObject_property") 319 if (argumentCount == 2 && str == "NPObject_property")
288 return npObjectProperty; 320 return npObjectProperty;
289 if (argumentCount == 3 && str == "NPObject_invoke") 321 if (argumentCount == 3 && str == "NPObject_invoke")
290 return npObjectInvoke; 322 return npObjectInvoke;
291 if (argumentCount == 1 && str == "DOMWindow_history_cross_frame_Getter") 323 if (argumentCount == 1 && str == "DOMWindow_history_cross_frame_Getter")
292 return DartDOMWindowInternal::historyCrossFrameGetter; 324 return DartDOMWindowInternal::historyCrossFrameGetter;
293 if (argumentCount == 1 && str == "DOMWindow_location_cross_frame_Getter") 325 if (argumentCount == 1 && str == "DOMWindow_location_cross_frame_Getter")
294 return DartDOMWindowInternal::locationCrossFrameGetter; 326 return DartDOMWindowInternal::locationCrossFrameGetter;
295 return 0; 327 return 0;
296 } 328 }
297 329
298 } 330 }
OLDNEW
« no previous file with comments | « Source/WebCore/bindings/dart/DartController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698