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..6716a6b6cca1fc5c8ac47b7b2cbe73c911a1e636 |
| --- /dev/null |
| +++ b/tools/dom/src/chrome/app.runtime.dart |
| @@ -0,0 +1,258 @@ |
| +// Copyright (c) 2013, 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. |
|
vsm
2013/01/23 20:44:50
If this is already deprecated in JS, why generate
sashab
2013/01/23 22:24:53
Will discuss this with benwells.
|
| +class Intent extends ChromeObject { |
| + /* |
| + * Public (Dart) constructor |
| + */ |
| + Intent({String action, String type, var data}) { |
|
Emily Fortuna
2013/01/23 19:28:04
90% sure this constructor can be simplified to:
I
sashab
2013/01/23 22:24:53
I thought so too :'( I've e-mailed misc@dartlang,
|
| + this.action = action; |
| + this.type = type; |
| + this.data = data; |
| + } |
| + |
| + /* |
| + * Private (JS) constructor |
| + */ |
| + Intent._proxy(_jsObject) |
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + |
| + // The WebIntent being invoked. |
| + String get action => |
|
Emily Fortuna
2013/01/23 19:28:04
when you have a getter with the => syntax, (and it
sashab
2013/01/23 22:24:53
Will do this. Is the grouping OK? Ie should it be
|
| + getMember('String', 'action'); |
| + |
| + void set action(String action) => |
| + setMember('action', action); |
| + |
| + // The MIME type of the data. |
| + String get type => |
| + getMember('String', 'type'); |
| + |
| + void set type(String type) => |
| + setMember('type', type); |
| + |
| + // Data associated with the intent. |
| + // TODO(sashab): What is the best way to serialize/return generic JS objects? |
| + Object get data => |
| + getMember('Object', 'data'); |
| + |
| + void set data(Object data) => |
| + setMember('data', data); |
| + |
| + /* |
| + * TODO(sashab): What is a NullCallback() type? |
| + * Add postResult and postFailure once understanding what this type is, and |
| + * once there is a way to pass functions back from JS. |
| + */ |
| +} |
| + |
| +class LaunchItem extends ChromeObject { |
| + /* |
| + * Public constructor |
| + */ |
| + LaunchItem({FileEntry entry, String type}) { |
| + this.entry = entry; |
| + this.type = type; |
| + } |
| + |
| + /* |
| + * Private constructor |
| + */ |
| + LaunchItem._proxy(_jsObject) |
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + |
| + // FileEntry for the file. |
| + FileEntry get entry => |
| + getMember('FileEntry', 'entry'); |
| + |
| + void set entry(FileEntry entry) => |
| + setMember('entry', entry); |
| + |
| + // The MIME type of the file. |
| + String get type => |
| + getMember('String', 'type'); |
| + |
| + void set type(String type) => |
| + setMember('type', type); |
| +} |
| + |
| +// Optional data for the launch. |
| +class LaunchData extends ChromeObject { |
| + /* |
| + * Public constructor |
| + */ |
| + LaunchData({Intent intent, String id, List<LaunchItem> items}) { |
| + this.intent = intent; |
| + this.id = id; |
| + this.items = items; |
| + } |
| + |
| + /* |
| + * Private constructor |
| + */ |
| + LaunchData._proxy(_jsObject) |
|
Emily Fortuna
2013/01/23 19:28:04
same with this -- dart common style has all of thi
sashab
2013/01/23 22:24:53
Done.
|
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + Intent get intent => |
| + new Intent._proxy(getMember('', 'intent')); |
| + |
| + void set intent(Intent intent) => |
| + setMember('intent', intent); |
| + |
| + // The id of the file handler that the app is being invoked with. |
| + String get id => |
| + getMember('String', 'id'); |
| + |
| + void set id(String id) => |
| + setMember('id', id); |
| + |
| + List<LaunchItem> get items() { |
| + List<LaunchItem> items_final = new List<LaunchItem>(); |
| + for (var o in getMember('List', 'items')) { |
| + items_final.add(new LaunchItem._proxy(o)); |
| + } |
| + return items_final; |
| + } |
| + |
| + void set items(List<LaunchItem> items) => |
| + setMember('items', items); |
| +} |
| + |
| +class IntentResponse extends ChromeObject { |
| + /* |
| + * Public constructor |
| + */ |
| + IntentResponse({int intentId, bool success, Object data}) { |
| + this.intentId = intentId; |
| + this.success = success; |
| + this.data = data; |
| + } |
| + |
| + /* |
| + * Private constructor |
| + */ |
| + IntentResponse._proxy(_jsObject) |
| + : super._proxy(_jsObject); |
| + |
| + /* |
| + * Public accessors |
| + */ |
| + |
| + // Identifies the intent. |
| + int get intentId => |
| + getMember('int', 'intentId'); |
| + |
| + void set intentId(int intentId) => |
| + setMember('intentId', intentId); |
| + |
| + // Was this intent successful? (i.e., postSuccess vs postFailure). |
| + bool get success => |
| + getMember('bool', 'success'); |
| + |
| + void set success(bool success) => |
| + setMember('success', success); |
| + |
| + // Data associated with the intent response. |
| + // TODO(sashab): What's the best way to serialize/return generic JS objects? |
| + Object get data => |
| + getMember('Object', 'data'); |
| + |
| + void set data(Object data) => |
| + setMember('data', 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); |
|
Emily Fortuna
2013/01/23 19:28:04
if you must separate a => function onto two lines,
sashab
2013/01/23 22:24:53
Done.
|
| + 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)); |
|
Emily Fortuna
2013/01/23 19:28:04
80 char or less, please. :-)
here and below
sashab
2013/01/23 22:24:53
Will I have to enforce this in the generated code?
|
| + } |
| + |
| + /* |
| + * Constructor |
| + */ |
| + $API_ChromeAppRuntime(this._jsObject) { |
| + onRestarted = new $Event_ChromeAppRuntimeOnRestarted(JS('Object', '#.onRestarted', this._jsObject)); |
| + onLaunched = new $Event_ChromeAppRuntimeOnLaunched(JS('Object', '#.onLaunched', this._jsObject)); |
| + } |
| +} |
| + |