Chromium Code Reviews| 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 // TODO(sashab): Change all chrome-API object types to be JS-bound, so that the | |
| 6 // proxy types are not needed. Instead, creation of an object also creates its | |
| 7 // JS counterpart, and all objects are proxies from the start. | |
| 8 part of chrome; | |
| 9 | |
| 10 // chrome.app | |
| 11 class $API_ChromeApp { | |
| 12 /* | |
| 13 * JS Variable | |
| 14 */ | |
| 15 Object _jsObject; | |
| 16 | |
| 17 /* | |
| 18 * Members | |
| 19 */ | |
| 20 $API_ChromeAppWindow window; | |
| 21 $API_ChromeAppRuntime runtime; | |
| 22 | |
| 23 /* | |
| 24 * Constructor | |
| 25 */ | |
| 26 $API_ChromeApp(this._jsObject) { | |
| 27 var window_object = JS('', '#.window', this._jsObject); | |
| 28 if (window_object == null) | |
| 29 throw new UnsupportedError('Not supported by current browser.'); | |
| 30 window = new $API_ChromeAppWindow(window_object); | |
| 31 | |
| 32 var runtime_object = JS('', '#.runtime', this._jsObject); | |
| 33 if (runtime_object == null) | |
| 34 throw new UnsupportedError('Not supported by current browser.'); | |
| 35 runtime = new $API_ChromeAppRuntime(runtime_object); | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 // chrome | |
| 40 class $API_Chrome { | |
| 41 /* | |
| 42 * JS Variable | |
| 43 */ | |
| 44 Object _jsObject; | |
| 45 | |
| 46 /* | |
| 47 * Members | |
| 48 */ | |
| 49 $API_ChromeApp app; | |
| 50 | |
| 51 /* | |
| 52 * Constructor | |
| 53 */ | |
| 54 $API_Chrome() { | |
| 55 this._jsObject = JS("Object", "chrome"); | |
| 56 if (this._jsObject == null) | |
| 57 throw new UnsupportedError('Not supported by current browser.'); | |
| 58 | |
| 59 var app_object = JS('', '#.app', this._jsObject); | |
| 60 if (app_object == null) | |
| 61 throw new UnsupportedError('Not supported by current browser.'); | |
| 62 app = new $API_ChromeApp(app_object); | |
| 63 } | |
| 64 } | |
| 65 | |
| 66 // The final chrome object | |
| 67 final $API_Chrome chrome = new $API_Chrome(); | |
|
blois
2013/01/23 02:06:12
I think the preference is that the members of chro
sashab
2013/01/23 04:45:34
The reason I didn't want to do this is because the
| |
| OLD | NEW |