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

Unified Diff: pkg/intl/lib/src/http_request_data_reader.dart

Issue 10959002: Read locales over http in the browser (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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: pkg/intl/lib/src/http_request_data_reader.dart
===================================================================
--- pkg/intl/lib/src/http_request_data_reader.dart (revision 0)
+++ pkg/intl/lib/src/http_request_data_reader.dart (revision 0)
@@ -0,0 +1,29 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/**
+ * This contains a reader that accesses data using the HttpRequest
+ * facility, and thus works only in the web browser.
+ */
+
+#library('http_request_data_reader');
+
+#import('dart:html');
+#import('intl_helpers.dart');
+
+class HTTPRequestDataReader implements LocaleDataReader {
+
+ /** The base url from which we read the data. */
+ String url;
+ HTTPRequestDataReader(this.url);
+
+ Future read(String locale) {
+ var completer = new Completer();
+ var source = '$url$locale.json';
+ var request = new HttpRequest.get(
+ source,
+ (request) => completer.complete(request.responseText));
+ return completer.future;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698