Chromium Code Reviews| Index: tools/dom/src/chrome/app.runtime.dart |
| diff --git a/tools/dom/src/chrome/app.runtime.dart b/tools/dom/src/chrome/app.runtime.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d71265be952c12256ddf5e945d01091454c03f43 |
| --- /dev/null |
| +++ b/tools/dom/src/chrome/app.runtime.dart |
| @@ -0,0 +1,425 @@ |
| +// 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. |
| + |
| +// from app_runtime.idl |
| +part of chrome; |
| + |
| +/** |
| + * Types |
| + */ |
| + |
| +// A WebIntents intent object. Deprecated. |
| +class Intent extends ChromeObject { |
| + // The WebIntent being invoked. |
| + String _action; |
| + |
| + // The MIME type of the data. |
| + String _type; |
| + |
| + // Data associated with the intent. |
| + var _data; |
| + |
| + // Callback to be compatible with WebIntents. |
| + Function _postResult; |
| + |
| + // Callback to be compatible with WebIntents. |
| + Function _postFailure; |
| + |
| + /* |
| + * Public (Dart) constructor |
| + */ |
| + Intent({ |
| + String action, |
|
blois
2013/01/23 02:06:12
Normally these are all collapsed onto the same lin
sashab
2013/01/23 04:45:34
Done.
|
| + String type, |
| + var data, |
| + Function postResult, |
| + Function postFailure |
|
blois
2013/01/23 02:06:12
Can this be further typed? As in what are the para
sashab
2013/01/23 04:45:34
This is actually a mistake; see the TODO below:
|
| + }) : |
| + _action = action, |
| + _type = type, |
| + _data = data, |
| + _postResult = postResult, |
| + _postFailure = postFailure |
| + ; |
| + |
| + /* |
| + * Private (JS) constructor |
| + */ |
| + Intent._proxy(_jsObject) |
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Serialisation method |
| + */ |
| + Map _toMap() { |
| + Map m = {}; |
| + if (action != null) m['action'] = action; |
| + if (type != null) m['type'] = type; |
| + if (data != null) m['data'] = data; |
| + if (postResult != null) m['postResult'] = postResult; |
| + if (postFailure != null) m['postFailure'] = postFailure; |
| + return m; |
| + } |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + String get action { |
|
blois
2013/01/23 02:06:12
Couldn't you just have it always have the JS proxy
sashab
2013/01/23 04:45:34
Done.
|
| + if (!this._hasProxy()) |
| + return this._action; |
| + return JS('String', '#.action', this._jsObject); |
| + } |
| + |
| + void set action(String action) { |
| + if (!this._hasProxy()) |
| + this._action = action; |
| + else |
| + JS('void', '#.action = #', this._jsObject, convertArgument(action)); |
| + } |
| + |
| + String get type { |
| + if (!this._hasProxy()) |
| + return this._type; |
| + return JS('String', '#.action', this._jsObject); |
| + } |
| + |
| + void set type(String type) { |
| + if (!this._hasProxy()) |
| + this._type = type; |
| + else |
| + JS('void', '#.type = #', this._jsObject, convertArgument(type)); |
| + } |
| + |
| + /* TODO(sashab): What's the best way to return generic JS objects? */ |
| + Object get data { |
| + if (!this._hasProxy()) |
| + return this._data; |
| + return convertNativeToDart_SerializedScriptValue(JS('Object', '#.data', this._jsObject)); |
| + } |
| + |
| + /* TODO(sashab): What's the best way to serialize generic JS objects? */ |
| + void set data(var data) { |
| + if (!this._hasProxy()) |
| + this._data = data; |
| + else |
| + JS('void', '#.data = #', this._jsObject, convertArgument(data)); |
| + } |
| + |
| + /* |
| + * TODO(sashab): What is a NullCallback() type? |
| + * Add postResult and postFailure once understanding what this type is, and |
| + * how to pass functions back from JS. |
| + */ |
| +} |
| + |
| +class LaunchItem extends ChromeObject { |
| + // FileEntry for the file. |
| + FileEntry _entry; |
| + |
| + // The MIME type of the file. |
| + String _type; |
| + |
| + /* |
| + * Public constructor |
| + */ |
| + LaunchItem({ |
| + FileEntry entry, |
| + String type |
| + }) : |
| + _entry = entry, |
| + _type = type |
| + ; |
| + |
| + /* |
| + * Private constructor |
| + */ |
| + LaunchItem._proxy(_jsObject) |
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Serialisation method |
| + */ |
| + Map _toMap() { |
| + Map m = {}; |
| + if (entry != null) m['entry'] = entry; |
| + if (type != null) m['type'] = type; |
| + return m; |
| + } |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + FileEntry get entry { |
| + if (!this._hasProxy()) |
| + return this._entry; |
| + return JS('FileEntry', '#.entry', this._jsObject); |
| + } |
| + |
| + /* TODO(sashab): Find a way to serialize a html.FileEntry? */ |
| + void set entry(FileEntry entry) { |
| + if (!this._hasProxy()) |
| + this._entry = entry; |
| + else |
| + JS('void', '#.entry = #', this._jsObject, convertArgument(entry)); |
| + } |
| + |
| + String get type { |
| + if (!this._hasProxy()) |
| + return this._type; |
| + return JS('String', '#.type', this._jsObject); |
| + } |
| + |
| + void set type(String type) { |
| + if (!this._hasProxy()) |
| + this._type = type; |
| + else |
| + JS('void', '#.type = #', this._jsObject, convertArgument(type)); |
| + } |
| + |
| + |
| +} |
| + |
| +// Optional data for the launch. |
| +class LaunchData extends ChromeObject { |
| + Intent _intent; |
| + |
| + // The id of the file handler that the app is being invoked with. |
| + String _id; |
| + |
| + List<LaunchItem> _items; |
| + |
| + /* |
| + * Public constructor |
| + */ |
| + LaunchData({ |
| + Intent intent, |
| + String id, |
| + List<LaunchItem> items |
| + }) : |
| + _intent = intent, |
| + _id = id, |
| + _items = items |
| + ; |
| + |
| + /* |
| + * Private constructor |
| + */ |
| + LaunchData._proxy(_jsObject) |
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Serialisation method |
| + */ |
| + Map _toMap() { |
| + Map m = {}; |
| + if (intent != null) m['intent'] = intent; |
| + if (id != null) m['id'] = id; |
| + if (items != null) m['items'] = items; |
| + return m; |
| + } |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + Intent get intent { |
| + if (!this._hasProxy()) |
| + return this._intent; |
| + return new Intent._proxy(JS('Object', '#.intent', this._jsObject)); |
| + } |
| + |
| + void set intent(Intent intent) { |
| + if (!this._hasProxy()) |
| + this._intent = intent; |
| + else |
| + JS('void', '#.intent = #', this._jsObject, convertArgument(intent)); |
| + } |
| + |
| + String get id { |
| + if (!this._hasProxy()) |
| + return this._id; |
| + return JS('String', '#.id', this._jsObject); |
| + } |
| + |
| + void set id(String id) { |
| + if (!this._hasProxy()) |
| + this._id = id; |
| + else |
| + JS('void', '#.id = #', this._jsObject, convertArgument(id)); |
| + } |
| + |
| + /* TODO(sashab): Wrap lists of custom types when returning. */ |
| + List<LaunchItem> get items { |
| + if (!this._hasProxy()) |
| + return this._items; |
| + return JS('List', '#.items', this._jsObject); |
| + } |
| + |
| + void set items(List<LaunchItem> items) { |
| + if (!this._hasProxy()) |
| + this._items = items; |
| + else |
| + JS('void', '#.items = #', this._jsObject, convertArgument(items)); |
| + } |
| +} |
| + |
| +class IntentResponse extends ChromeObject { |
| + // Identifies the intent. |
| + int _intentId; |
| + |
| + // Was this intent successful? (i.e., postSuccess vs postFailure). |
| + bool _success; |
| + |
| + // Data associated with the intent response. |
| + Object _data; |
| + |
| + /* |
| + * Public constructor |
| + */ |
| + IntentResponse({ |
| + int intentId, |
| + bool success, |
| + Object data |
| + }) : |
| + _intentId = intentId, |
| + _success = success, |
| + _data = data |
| + ; |
| + |
| + /* |
| + * Private constructor |
| + */ |
| + IntentResponse._proxy(JSObject _jsObject) |
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Serialisation method |
| + */ |
| + Map _toMap() { |
| + Map m = {}; |
| + if (intentId != null) m['intentId'] = intentId; |
| + if (success != null) m['success'] = success; |
| + if (data != null) m['data'] = data; |
| + return m; |
| + } |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + int get intentId { |
| + if (!this._hasProxy()) |
| + return this._intentId; |
| + return JS('int', '#.intentId', this._jsObject); |
| + } |
| + |
| + void set intentId(int intentId) { |
| + if (!this._hasProxy()) |
| + this._intentId = intentId; |
| + else |
| + JS('void', '#.intentId = #', this._jsObject, convertArgument(intentId)); |
| + } |
| + |
| + bool get success { |
| + if (!this._hasProxy()) |
| + return this._success; |
| + return JS('bool', '#.success', this._jsObject); |
| + } |
| + |
| + void set success(bool success) { |
| + if (!this._hasProxy()) |
| + this._success = success; |
| + else |
| + JS('void', '#.success = #', this._jsObject, convertArgument(success)); |
| + } |
| + |
| + /* TODO(sashab): What's the best way to return generic JS objects? */ |
| + Object get data { |
| + if (!this._hasProxy()) |
| + return this._data; |
| + return convertNativeToDart_SerializedScriptValue(JS('Object', '#.data', this._jsObject)); |
| + } |
| + |
| + /* TODO(sashab): What's the best way to serialize generic JS objects? */ |
| + void set data(var data) { |
| + if (!this._hasProxy()) |
| + this._data = data; |
| + else |
| + JS('void', '#.data = #', this._jsObject, convertArgument(data)); |
| + } |
| +} |
| + |
| +/** |
| + * Events |
| + */ |
| + |
| +// Fired at Chrome startup to apps that were running when Chrome last shut |
| +// down. |
| +class $Event_ChromeAppRuntimeOnRestarted extends $Event { |
| + /* |
| + * Override callback type definitions |
| + */ |
| + void addListener(void callback()) |
| + => super.addListener(callback); |
| + void removeListener(void callback()) |
| + => super.removeListener(callback); |
| + bool hasListener(void callback()) |
| + => super.hasListener(callback); |
| + |
| + /* |
| + * Constructor |
| + */ |
| + $Event_ChromeAppRuntimeOnRestarted(jsObject) : |
| + super._(jsObject, 0); |
| +} |
| + |
| +// Fired when an app is launched from the launcher or in response to a web |
| +// intent. |
| +class $Event_ChromeAppRuntimeOnLaunched extends $Event { |
| + /* |
| + * Override callback type definitions |
| + */ |
| + void addListener(void callback(LaunchData launchData)) |
| + => super.addListener(callback); |
| + void removeListener(void callback(LaunchData launchData)) |
| + => super.removeListener(callback); |
| + bool hasListener(void callback(LaunchData launchData)) |
| + => super.hasListener(callback); |
| + |
| + /* |
| + * Constructor |
| + */ |
| + $Event_ChromeAppRuntimeOnLaunched(jsObject) : |
| + super._(jsObject, 1); |
| +} |
| + |
| +/** |
| + * Functions |
| + */ |
| +class $API_ChromeAppRuntime { |
| + /* |
| + * API connection |
| + */ |
| + Object _jsObject; |
| + |
| + /* |
| + * Events |
| + */ |
| + $Event_ChromeAppRuntimeOnRestarted onRestarted; |
| + $Event_ChromeAppRuntimeOnLaunched onLaunched; |
| + |
| + /* |
| + * Functions |
| + */ |
| + void postIntentResponse(IntentResponse intentResponse) { |
| + JS('void', '#.postIntentResponse(#)', this._jsObject, convertArgument(intentResponse)); |
| + } |
| + |
| + /* |
| + * Constructor |
| + */ |
| + $API_ChromeAppRuntime(this._jsObject) { |
| + onRestarted = new $Event_ChromeAppRuntimeOnRestarted(JS('Object', '#.onRestarted', this._jsObject)); |
| + onLaunched = new $Event_ChromeAppRuntimeOnLaunched(JS('Object', '#.onLaunched', this._jsObject)); |
| + } |
| +} |
| + |