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

Unified Diff: tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate

Issue 23640003: Adding support for cross-origin requests on IE9. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « tests/html/xhr_cross_origin_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
index 4a6a45e7a355224ef2cea973f7c6158de45dd945..aa47fc8ec4f0666b3a4be5ae36e38a0f7ee89447 100644
--- a/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
+++ b/tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate
@@ -221,5 +221,44 @@ $else
$endif
}
+ /**
+ * Makes a cross-origin request to the specified URL.
+ *
+ * This API provides a subset of [request] which works on IE9. If IE9
+ * cross-origin support is not required then [request] should be used instead.
+ */
+ @Experimental()
+ static Future<String> requestCrossOrigin(String url,
+ {String method, String sendData}) {
+ if (supportsCrossOrigin) {
+ return request(url, method: method, sendData: sendData).then((xhr) {
+ return xhr.responseText;
+ });
+ }
+$if DART2JS
+ var completer = new Completer<String>();
+ if (method == null) {
+ method = 'GET';
+ }
+ var xhr = JS('var', 'new XDomainRequest()');
+ JS('', '#.open(#, #)', xhr, method, url);
+ JS('', '#.onload = #', xhr, convertDartClosureToJS((e) {
+ var response = JS('String', '#.responseText', xhr);
+ completer.complete(response);
+ }, 1));
+ JS('', '#.onerror = #', xhr, convertDartClosureToJS((e) {
+ completer.completeError(e);
+ }, 1));
+
+ if (sendData != null) {
+ JS('', '#.send(#)', xhr, sendData);
+ } else {
+ JS('', '#.send()', xhr);
+ }
+
+ return completer.future;
+$endif
+ }
+
$!MEMBERS
}
« no previous file with comments | « tests/html/xhr_cross_origin_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698