OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 /** | 7 /** |
8 * A utility for retrieving data from a URL. | 8 * A utility for retrieving data from a URL. |
9 * | 9 * |
10 * HttpRequest can be used to obtain data from http, ftp, and file | 10 * HttpRequest can be used to obtain data from http, ftp, and file |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 return completer.future; | 123 return completer.future; |
124 } | 124 } |
125 | 125 |
126 /** | 126 /** |
127 * Checks to see if the Progress event is supported on the current platform. | 127 * Checks to see if the Progress event is supported on the current platform. |
128 */ | 128 */ |
129 static bool get supportsProgressEvent { | 129 static bool get supportsProgressEvent { |
130 $if DART2JS | 130 $if DART2JS |
131 var xhr = new HttpRequest(); | 131 var xhr = new HttpRequest(); |
132 return JS('bool', '"onprogress" in #', xhr); | 132 return JS('bool', '("onprogress" in #)', xhr); |
133 $else | 133 $else |
134 return true; | 134 return true; |
135 $endif | 135 $endif |
| 136 } |
| 137 |
| 138 /** |
| 139 * Checks to see if the current platform supports making cross origin |
| 140 * requests. |
| 141 * |
| 142 * Note that even if cross origin requests are supported, they still may fail |
| 143 * if the destination server does not support CORS requests. |
| 144 */ |
| 145 static bool get supportsCrossOrigin { |
| 146 $if DART2JS |
| 147 var xhr = new HttpRequest(); |
| 148 return JS('bool', '("withCredentials" in #)', xhr); |
| 149 $else |
| 150 return true; |
| 151 $endif |
136 } | 152 } |
137 | 153 |
138 /** | 154 /** |
139 * Checks to see if the LoadEnd event is supported on the current platform. | 155 * Checks to see if the LoadEnd event is supported on the current platform. |
140 */ | 156 */ |
141 static bool get supportsLoadEndEvent { | 157 static bool get supportsLoadEndEvent { |
142 $if DART2JS | 158 $if DART2JS |
143 var xhr = new HttpRequest(); | 159 var xhr = new HttpRequest(); |
144 return JS('bool', '"onloadend" in #', xhr); | 160 return JS('bool', '("onloadend" in #)', xhr); |
145 $else | 161 $else |
146 return true; | 162 return true; |
147 $endif | 163 $endif |
148 } | 164 } |
149 | 165 |
150 $!MEMBERS | 166 $!MEMBERS |
151 } | 167 } |
OLD | NEW |