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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

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:
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 955ddaccc4ead6ad46edd0adf4b1e920251954f1..57de07dda4d4b693c005e59ce630453749a9c4a9 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -12919,6 +12919,43 @@ class HttpRequest extends EventTarget native "XMLHttpRequest" {
return JS('bool', '("overrideMimeType" in #)', xhr);
}
+ /**
+ * 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;
+ });
+ }
+ 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;
+ }
+
// To suppress missing implicit constructor warnings.
factory HttpRequest._() { throw new UnsupportedError("Not supported"); }
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698