| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of chrome; | |
| 6 | |
| 7 // This is an example of exposing chrome APIs in Dart and will be replaced with | |
| 8 // the proper implementation in the future. | |
| 9 | |
| 10 class AppModule { | |
| 11 AppModule._(); | |
| 12 | |
| 13 WindowModule get window => new WindowModule._(); | |
| 14 } | |
| 15 | |
| 16 class WindowModule { | |
| 17 WindowModule._(); | |
| 18 | |
| 19 void create(String url) { | |
| 20 var chrome = JS('', 'chrome'); | |
| 21 | |
| 22 if (chrome == null) { | |
| 23 throw new UnsupportedError('Not supported by current browser'); | |
| 24 } | |
| 25 var app = JS('', '#.app', chrome); | |
| 26 if (app == null) { | |
| 27 throw new UnsupportedError('Not supported by current browser'); | |
| 28 } | |
| 29 var window = JS('', '#.window', app); | |
| 30 if (app == null) { | |
| 31 throw new UnsupportedError('Not supported by current browser'); | |
| 32 } | |
| 33 JS('void', '#.create(#)', window, url); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 final app = new AppModule._(); | |
| OLD | NEW |