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