| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013, 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 // from app_runtime.idl | |
| 6 part of chrome; | |
| 7 | |
| 8 /** | |
| 9 * Types | |
| 10 */ | |
| 11 | |
| 12 /// A WebIntents intent object. Deprecated. | |
| 13 class Intent extends ChromeObject { | |
| 14 /* | |
| 15 * Public (Dart) constructor | |
| 16 */ | |
| 17 Intent({String action, String type, var data}) { | |
| 18 this.action = action; | |
| 19 this.type = type; | |
| 20 this.data = data; | |
| 21 } | |
| 22 | |
| 23 /* | |
| 24 * Private (JS) constructor | |
| 25 */ | |
| 26 Intent._proxy(_jsObject) : super._proxy(_jsObject); | |
| 27 | |
| 28 /* | |
| 29 * Public accessors | |
| 30 */ | |
| 31 | |
| 32 /// The WebIntent being invoked. | |
| 33 String get action => JS('String', '#.action', this._jsObject); | |
| 34 | |
| 35 void set action(String action) { | |
| 36 JS('void', '#.action = #', this._jsObject, action); | |
| 37 } | |
| 38 | |
| 39 /// The MIME type of the data. | |
| 40 String get type => JS('String', '#.type', this._jsObject); | |
| 41 | |
| 42 void set type(String type) { | |
| 43 JS('void', '#.type = #', this._jsObject, type); | |
| 44 } | |
| 45 | |
| 46 /// Data associated with the intent. | |
| 47 // TODO(sashab): What is the best way to serialize/return generic JS objects? | |
| 48 Object get data => JS('Object', '#.data', this._jsObject); | |
| 49 | |
| 50 void set data(Object data) { | |
| 51 JS('void', '#.data = #', this._jsObject, convertArgument(data)); | |
| 52 } | |
| 53 | |
| 54 /* | |
| 55 * TODO(sashab): What is a NullCallback() type? | |
| 56 * Add postResult and postFailure once understanding what this type is, and | |
| 57 * once there is a way to pass functions back from JS. | |
| 58 */ | |
| 59 } | |
| 60 | |
| 61 class LaunchItem extends ChromeObject { | |
| 62 /* | |
| 63 * Public constructor | |
| 64 */ | |
| 65 LaunchItem({FileEntry entry, String type}) { | |
| 66 this.entry = entry; | |
| 67 this.type = type; | |
| 68 } | |
| 69 | |
| 70 /* | |
| 71 * Private constructor | |
| 72 */ | |
| 73 LaunchItem._proxy(_jsObject) : super._proxy(_jsObject); | |
| 74 | |
| 75 /* | |
| 76 * Public accessors | |
| 77 */ | |
| 78 | |
| 79 /// FileEntry for the file. | |
| 80 FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject); | |
| 81 | |
| 82 void set entry(FileEntry entry) { | |
| 83 JS('void', '#.entry = #', this._jsObject, entry); | |
| 84 } | |
| 85 | |
| 86 /// The MIME type of the file. | |
| 87 String get type => JS('String', '#.type', this._jsObject); | |
| 88 | |
| 89 void set type(String type) { | |
| 90 JS('void', '#.type = #', this._jsObject, type); | |
| 91 } | |
| 92 } | |
| 93 | |
| 94 /// Optional data for the launch. | |
| 95 class LaunchData extends ChromeObject { | |
| 96 /* | |
| 97 * Public constructor | |
| 98 */ | |
| 99 LaunchData({Intent intent, String id, List<LaunchItem> items}) { | |
| 100 this.intent = intent; | |
| 101 this.id = id; | |
| 102 this.items = items; | |
| 103 } | |
| 104 | |
| 105 /* | |
| 106 * Private constructor | |
| 107 */ | |
| 108 LaunchData._proxy(_jsObject) : super._proxy(_jsObject); | |
| 109 | |
| 110 /* | |
| 111 * Public accessors | |
| 112 */ | |
| 113 Intent get intent => new Intent._proxy(JS('', '#.intent', this._jsObject)); | |
| 114 | |
| 115 void set intent(Intent intent) { | |
| 116 JS('void', '#.intent = #', this._jsObject, convertArgument(intent)); | |
| 117 } | |
| 118 | |
| 119 /// The id of the file handler that the app is being invoked with. | |
| 120 String get id => JS('String', '#.id', this._jsObject); | |
| 121 | |
| 122 void set id(String id) { | |
| 123 JS('void', '#.id = #', this._jsObject, id); | |
| 124 } | |
| 125 | |
| 126 List<LaunchItem> get items() { | |
| 127 List<LaunchItem> items_final = new List<LaunchItem>(); | |
| 128 for (var o in JS('List', '#.items', this._jsObject)) { | |
| 129 items_final.add(new LaunchItem._proxy(o)); | |
| 130 } | |
| 131 return items_final; | |
| 132 } | |
| 133 | |
| 134 void set items(List<LaunchItem> items) { | |
| 135 JS('void', '#.items = #', this._jsObject, convertArgument(items)); | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 class IntentResponse extends ChromeObject { | |
| 140 /* | |
| 141 * Public constructor | |
| 142 */ | |
| 143 IntentResponse({int intentId, bool success, Object data}) { | |
| 144 this.intentId = intentId; | |
| 145 this.success = success; | |
| 146 this.data = data; | |
| 147 } | |
| 148 | |
| 149 /* | |
| 150 * Private constructor | |
| 151 */ | |
| 152 IntentResponse._proxy(_jsObject) : super._proxy(_jsObject); | |
| 153 | |
| 154 /* | |
| 155 * Public accessors | |
| 156 */ | |
| 157 | |
| 158 /// Identifies the intent. | |
| 159 int get intentId => JS('int', '#.intentId', this._jsObject); | |
| 160 | |
| 161 void set intentId(int intentId) { | |
| 162 JS('void', '#.intentId = #', this._jsObject, intentId); | |
| 163 } | |
| 164 | |
| 165 /// Was this intent successful? (i.e., postSuccess vs postFailure). | |
| 166 bool get success => JS('bool', '#.success', this._jsObject); | |
| 167 | |
| 168 void set success(bool success) { | |
| 169 JS('void', '#.success = #', this._jsObject, success); | |
| 170 } | |
| 171 | |
| 172 /// Data associated with the intent response. | |
| 173 // TODO(sashab): What's the best way to serialize/return generic JS objects? | |
| 174 Object get data => JS('Object', '#.data', this._jsObject); | |
| 175 | |
| 176 void set data(Object data) { | |
| 177 JS('void', '#.data = #', this._jsObject, convertArgument(data)); | |
| 178 } | |
| 179 } | |
| 180 | |
| 181 /** | |
| 182 * Events | |
| 183 */ | |
| 184 | |
| 185 /// Fired at Chrome startup to apps that were running when Chrome last shut | |
| 186 /// down. | |
| 187 class Event_ChromeAppRuntimeOnRestarted extends Event { | |
| 188 /* | |
| 189 * Override callback type definitions | |
| 190 */ | |
| 191 void addListener(void callback()) | |
| 192 => super.addListener(callback); | |
| 193 void removeListener(void callback()) | |
| 194 => super.removeListener(callback); | |
| 195 bool hasListener(void callback()) | |
| 196 => super.hasListener(callback); | |
| 197 | |
| 198 /* | |
| 199 * Constructor | |
| 200 */ | |
| 201 Event_ChromeAppRuntimeOnRestarted(jsObject) : super._(jsObject, 0); | |
| 202 } | |
| 203 | |
| 204 /// Fired when an app is launched from the launcher or in response to a web | |
| 205 /// intent. | |
| 206 class Event_ChromeAppRuntimeOnLaunched extends Event { | |
| 207 /* | |
| 208 * Override callback type definitions | |
| 209 */ | |
| 210 void addListener(void callback(LaunchData launchData)) | |
| 211 => super.addListener(callback); | |
| 212 void removeListener(void callback(LaunchData launchData)) | |
| 213 => super.removeListener(callback); | |
| 214 bool hasListener(void callback(LaunchData launchData)) | |
| 215 => super.hasListener(callback); | |
| 216 | |
| 217 /* | |
| 218 * Constructor | |
| 219 */ | |
| 220 Event_ChromeAppRuntimeOnLaunched(jsObject) : super._(jsObject, 1); | |
| 221 } | |
| 222 | |
| 223 /** | |
| 224 * Functions | |
| 225 */ | |
| 226 class API_ChromeAppRuntime { | |
| 227 /* | |
| 228 * API connection | |
| 229 */ | |
| 230 Object _jsObject; | |
| 231 | |
| 232 /* | |
| 233 * Events | |
| 234 */ | |
| 235 Event_ChromeAppRuntimeOnRestarted onRestarted; | |
| 236 Event_ChromeAppRuntimeOnLaunched onLaunched; | |
| 237 | |
| 238 /* | |
| 239 * Functions | |
| 240 */ | |
| 241 void postIntentResponse(IntentResponse intentResponse) => | |
| 242 JS('void', '#.postIntentResponse(#)', this._jsObject, | |
| 243 convertArgument(intentResponse)); | |
| 244 | |
| 245 /* | |
| 246 * Constructor | |
| 247 */ | |
| 248 API_ChromeAppRuntime(this._jsObject) { | |
| 249 onRestarted = new Event_ChromeAppRuntimeOnRestarted(JS('Object', | |
| 250 '#.onRestarted', | |
| 251 this._jsObject)); | |
| 252 onLaunched = new Event_ChromeAppRuntimeOnLaunched(JS('Object', | |
| 253 '#.onLaunched', | |
| 254 this._jsObject)); | |
| 255 } | |
| 256 } | |
| 257 | |
| OLD | NEW |