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

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

Issue 52023002: Use userAgent instead of webkitStartDart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // --------------------------------------------------------------------------- 5 // ---------------------------------------------------------------------------
6 // Support for JS interoperability 6 // Support for JS interoperability
7 // --------------------------------------------------------------------------- 7 // ---------------------------------------------------------------------------
8 function SendPortSync() { 8 function SendPortSync() {
9 } 9 }
10 10
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 }; 157 };
158 158
159 ReceivePortSync.prototype.toSendPort = function() { 159 ReceivePortSync.prototype.toSendPort = function() {
160 return new LocalSendPortSync(this); 160 return new LocalSendPortSync(this);
161 }; 161 };
162 162
163 ReceivePortSync.prototype.close = function() { 163 ReceivePortSync.prototype.close = function() {
164 delete ReceivePortSync.map[this.id]; 164 delete ReceivePortSync.map[this.id];
165 }; 165 };
166 166
167 if (navigator.webkitStartDart) { 167 if (navigator.userAgent.indexOf('(Dart)') !== -1) {
168 window.addEventListener('js-sync-message', function(event) { 168 window.addEventListener('js-sync-message', function(event) {
169 var data = JSON.parse(getPortSyncEventData(event)); 169 var data = JSON.parse(getPortSyncEventData(event));
170 var deserialized = deserialize(data.message); 170 var deserialized = deserialize(data.message);
171 var result = ReceivePortSync.map[data.id].callback(deserialized); 171 var result = ReceivePortSync.map[data.id].callback(deserialized);
172 // TODO(vsm): Handle and propagate exceptions. 172 // TODO(vsm): Handle and propagate exceptions.
173 dispatchEvent('js-result', serialize(result)); 173 dispatchEvent('js-result', serialize(result));
174 }, false); 174 }, false);
175 } 175 }
176 176
177 function LocalSendPortSync(receivePort) { 177 function LocalSendPortSync(receivePort) {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 port.receive(f); 528 port.receive(f);
529 window.registerPort(name, port.toSendPort()); 529 window.registerPort(name, port.toSendPort());
530 } 530 }
531 531
532 makeGlobalPort('dart-js-context', context); 532 makeGlobalPort('dart-js-context', context);
533 makeGlobalPort('dart-js-create', construct); 533 makeGlobalPort('dart-js-create', construct);
534 makeGlobalPort('dart-js-instanceof', proxyInstanceof); 534 makeGlobalPort('dart-js-instanceof', proxyInstanceof);
535 makeGlobalPort('dart-js-delete-property', proxyDeleteProperty); 535 makeGlobalPort('dart-js-delete-property', proxyDeleteProperty);
536 makeGlobalPort('dart-js-convert', proxyConvert); 536 makeGlobalPort('dart-js-convert', proxyConvert);
537 })(); 537 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698