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

Side by Side Diff: pkg/browser/lib/dart.js

Issue 11774006: A pub package to host dart.js (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix test suite to use new path Created 7 years, 11 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 | « no previous file | pkg/browser/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Bootstrap support for Dart scripts on the page as this script. 5 // Bootstrap support for Dart scripts on the page as this script.
6 if (navigator.webkitStartDart) { 6 if (navigator.webkitStartDart) {
7 if (!navigator.webkitStartDart()) { 7 if (!navigator.webkitStartDart()) {
8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html'; 8 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html';
9 } 9 }
10 } else { 10 } else {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 for (var i = 0; i < length; i++) { 154 for (var i = 0; i < length; i++) {
155 result[i] = deserializeHelper(values[i]); 155 result[i] = deserializeHelper(values[i]);
156 } 156 }
157 return result; 157 return result;
158 } 158 }
159 159
160 window.registerPort = function(name, port) { 160 window.registerPort = function(name, port) {
161 var stringified = JSON.stringify(serialize(port)); 161 var stringified = JSON.stringify(serialize(port));
162 var attrName = 'dart-port:' + name; 162 var attrName = 'dart-port:' + name;
163 document.documentElement.setAttribute(attrName, stringified); 163 document.documentElement.setAttribute(attrName, stringified);
164 // TODO(vsm): Phase out usage of localStorage and delete the
165 // below. We're leaving it in temporarily for backwards
166 // compatibility.
167 try {
168 window.localStorage[attrName] = stringified;
169 } catch (e) {
170 // Swallow errors (e.g., Chrome apps disallow this access).
171 }
172 }; 164 };
173 165
174 window.lookupPort = function(name) { 166 window.lookupPort = function(name) {
175 var attrName = 'dart-port:' + name; 167 var attrName = 'dart-port:' + name;
176 var stringified = document.documentElement.getAttribute(attrName); 168 var stringified = document.documentElement.getAttribute(attrName);
177 // TODO(vsm): Phase out usage of localStorage. We're leaving it in
178 // temporarily for backwards compatibility.
179 if (!stringified) {
180 stringified = window.localStorage[attrName];
181 }
182 return deserialize(JSON.parse(stringified)); 169 return deserialize(JSON.parse(stringified));
183 }; 170 };
184 171
185 ReceivePortSync.id = 0; 172 ReceivePortSync.id = 0;
186 ReceivePortSync.map = {}; 173 ReceivePortSync.map = {};
187 174
188 ReceivePortSync.dispatchCall = function(id, message) { 175 ReceivePortSync.dispatchCall = function(id, message) {
189 // TODO(vsm): Handle and propagate exceptions. 176 // TODO(vsm): Handle and propagate exceptions.
190 var deserialized = deserialize(message); 177 var deserialized = deserialize(message);
191 var result = ReceivePortSync.map[id].callback(deserialized); 178 var result = ReceivePortSync.map[id].callback(deserialized);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 var result = null; 240 var result = null;
254 var listener = function (e) { 241 var listener = function (e) {
255 result = JSON.parse(getPortSyncEventData(e)); 242 result = JSON.parse(getPortSyncEventData(e));
256 }; 243 };
257 window.addEventListener(source, listener, false); 244 window.addEventListener(source, listener, false);
258 dispatchEvent(target, [source, serialized]); 245 dispatchEvent(target, [source, serialized]);
259 window.removeEventListener(source, listener, false); 246 window.removeEventListener(source, listener, false);
260 return deserialize(result); 247 return deserialize(result);
261 } 248 }
262 })(); 249 })();
OLDNEW
« no previous file with comments | « no previous file | pkg/browser/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698