Chromium Code Reviews| Index: tools/dom/src/chrome/chrome.dart |
| diff --git a/tools/dom/src/chrome/chrome.dart b/tools/dom/src/chrome/chrome.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e7f561aa8ceaa087825e4aad4898b576d9625c52 |
| --- /dev/null |
| +++ b/tools/dom/src/chrome/chrome.dart |
| @@ -0,0 +1,67 @@ |
| +// 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. |
| + |
| +// TODO(sashab): Change all chrome-API object types to be JS-bound, so that the |
| +// proxy types are not needed. Instead, creation of an object also creates its |
| +// JS counterpart, and all objects are proxies from the start. |
| +part of chrome; |
| + |
| +// chrome.app |
| +class $API_ChromeApp { |
| + /* |
| + * JS Variable |
| + */ |
| + Object _jsObject; |
| + |
| + /* |
| + * Members |
| + */ |
| + $API_ChromeAppWindow window; |
| + $API_ChromeAppRuntime runtime; |
| + |
| + /* |
| + * Constructor |
| + */ |
| + $API_ChromeApp(this._jsObject) { |
| + var window_object = JS('', '#.window', this._jsObject); |
| + if (window_object == null) |
| + throw new UnsupportedError('Not supported by current browser.'); |
| + window = new $API_ChromeAppWindow(window_object); |
| + |
| + var runtime_object = JS('', '#.runtime', this._jsObject); |
| + if (runtime_object == null) |
| + throw new UnsupportedError('Not supported by current browser.'); |
| + runtime = new $API_ChromeAppRuntime(runtime_object); |
| + } |
| +} |
| + |
| +// chrome |
| +class $API_Chrome { |
| + /* |
| + * JS Variable |
| + */ |
| + Object _jsObject; |
| + |
| + /* |
| + * Members |
| + */ |
| + $API_ChromeApp app; |
| + |
| + /* |
| + * Constructor |
| + */ |
| + $API_Chrome() { |
| + this._jsObject = JS("Object", "chrome"); |
| + if (this._jsObject == null) |
| + throw new UnsupportedError('Not supported by current browser.'); |
| + |
| + var app_object = JS('', '#.app', this._jsObject); |
| + if (app_object == null) |
| + throw new UnsupportedError('Not supported by current browser.'); |
| + app = new $API_ChromeApp(app_object); |
| + } |
| +} |
| + |
| +// The final chrome object |
| +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
|