Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tools/dom/src/chrome/app_runtime.dart

Issue 12209045: Initial commit of generated dart:chrome app_window and app_runtime (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added chromegenerator.py, which (if run from its local directory), generates app_window and app_run… Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // from app_runtime.idl 5 // Generated from namespace: app.runtime
6
6 part of chrome; 7 part of chrome;
7 8
8 /** 9 /**
9 * Types 10 * Types
10 */ 11 */
11 12
12 /// A WebIntents intent object. Deprecated.
13 class Intent extends ChromeObject { 13 class Intent extends ChromeObject {
14 /* 14 /*
15 * Public (Dart) constructor 15 * Private 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 */ 16 */
26 Intent._proxy(_jsObject) : super._proxy(_jsObject); 17 Intent._proxy(_jsObject) : super._proxy(_jsObject);
27 18
28 /* 19 /*
29 * Public accessors 20 * Public accessors
30 */ 21 */
31 22
32 /// The WebIntent being invoked. 23 /// The WebIntent being invoked.
33 String get action => JS('String', '#.action', this._jsObject); 24 String get action => JS('String', '#.action', this._jsObject);
34 25
35 void set action(String action) { 26 void set action(String action) {
36 JS('void', '#.action = #', this._jsObject, action); 27 JS('void', '#.action = #', this._jsObject, action);
37 } 28 }
38 29
39 /// The MIME type of the data. 30 /// The MIME type of the data.
40 String get type => JS('String', '#.type', this._jsObject); 31 String get type => JS('String', '#.type', this._jsObject);
41 32
42 void set type(String type) { 33 void set type(String type) {
43 JS('void', '#.type = #', this._jsObject, type); 34 JS('void', '#.type = #', this._jsObject, type);
44 } 35 }
45 36
46 /// Data associated with the intent. 37 /// 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); 38 Object get data => JS('Object', '#.data', this._jsObject);
49 39
50 void set data(Object data) { 40 void set data(Object data) {
51 JS('void', '#.data = #', this._jsObject, convertArgument(data)); 41 JS('void', '#.data = #', this._jsObject, convertArgument(data));
52 } 42 }
53 43
54 /* 44 /*
55 * TODO(sashab): What is a NullCallback() type? 45 * Methods
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 */ 46 */
47 /// Callback to be compatible with WebIntents.
48 void postResult() => JS('void', '#.postResult()', this._jsObject);
49 /// Callback to be compatible with WebIntents.
50 void postFailure() => JS('void', '#.postFailure()', this._jsObject);
59 } 51 }
60 52
61 class LaunchItem extends ChromeObject { 53 class LaunchItem extends ChromeObject {
62 /* 54 /*
63 * Public constructor 55 * Public constructor
64 */ 56 */
65 LaunchItem({FileEntry entry, String type}) { 57 LaunchItem({FileEntry entry, String type}) {
66 this.entry = entry; 58 if (?entry)
67 this.type = type; 59 this.entry = entry;
60 if (?type)
61 this.type = type;
68 } 62 }
69 63
70 /* 64 /*
71 * Private constructor 65 * Private constructor
72 */ 66 */
73 LaunchItem._proxy(_jsObject) : super._proxy(_jsObject); 67 LaunchItem._proxy(_jsObject) : super._proxy(_jsObject);
74 68
75 /* 69 /*
76 * Public accessors 70 * Public accessors
77 */ 71 */
78 72
79 /// FileEntry for the file. 73 /// FileEntry for the file.
80 FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject); 74 FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject);
81 75
82 void set entry(FileEntry entry) { 76 void set entry(FileEntry entry) {
83 JS('void', '#.entry = #', this._jsObject, entry); 77 JS('void', '#.entry = #', this._jsObject, convertArgument(entry));
84 } 78 }
85 79
86 /// The MIME type of the file. 80 /// The MIME type of the file.
87 String get type => JS('String', '#.type', this._jsObject); 81 String get type => JS('String', '#.type', this._jsObject);
88 82
89 void set type(String type) { 83 void set type(String type) {
90 JS('void', '#.type = #', this._jsObject, type); 84 JS('void', '#.type = #', this._jsObject, type);
91 } 85 }
92 } 86 }
93 87
94 /// Optional data for the launch.
95 class LaunchData extends ChromeObject { 88 class LaunchData extends ChromeObject {
96 /* 89 /*
97 * Public constructor 90 * Public constructor
98 */ 91 */
99 LaunchData({Intent intent, String id, List<LaunchItem> items}) { 92 LaunchData({Intent intent, String id, List<LaunchItem> items}) {
100 this.intent = intent; 93 if (?intent)
101 this.id = id; 94 this.intent = intent;
102 this.items = items; 95 if (?id)
96 this.id = id;
97 if (?items)
98 this.items = items;
103 } 99 }
104 100
105 /* 101 /*
106 * Private constructor 102 * Private constructor
107 */ 103 */
108 LaunchData._proxy(_jsObject) : super._proxy(_jsObject); 104 LaunchData._proxy(_jsObject) : super._proxy(_jsObject);
109 105
110 /* 106 /*
111 * Public accessors 107 * Public accessors
112 */ 108 */
109
113 Intent get intent => new Intent._proxy(JS('', '#.intent', this._jsObject)); 110 Intent get intent => new Intent._proxy(JS('', '#.intent', this._jsObject));
114 111
115 void set intent(Intent intent) { 112 void set intent(Intent intent) {
116 JS('void', '#.intent = #', this._jsObject, convertArgument(intent)); 113 JS('void', '#.intent = #', this._jsObject, convertArgument(intent));
117 } 114 }
118 115
119 /// The id of the file handler that the app is being invoked with. 116 /// The id of the file handler that the app is being invoked with.
120 String get id => JS('String', '#.id', this._jsObject); 117 String get id => JS('String', '#.id', this._jsObject);
121 118
122 void set id(String id) { 119 void set id(String id) {
123 JS('void', '#.id = #', this._jsObject, id); 120 JS('void', '#.id = #', this._jsObject, id);
124 } 121 }
125 122
126 List<LaunchItem> get items() { 123 List<LaunchItem> get items {
127 List<LaunchItem> items_final = new List<LaunchItem>(); 124 List<LaunchItem> __proxy_items = new List<LaunchItem>();
128 for (var o in JS('List', '#.items', this._jsObject)) { 125 for (var o in JS('List', '#.items', this._jsObject)) {
129 items_final.add(new LaunchItem._proxy(o)); 126 __proxy_items.add(new LaunchItem._proxy(o));
130 } 127 }
131 return items_final; 128 return __proxy_items;
132 } 129 }
133 130
134 void set items(List<LaunchItem> items) { 131 void set items(List<LaunchItem> items) {
135 JS('void', '#.items = #', this._jsObject, convertArgument(items)); 132 JS('void', '#.items = #', this._jsObject, convertArgument(items));
136 } 133 }
137 } 134 }
138 135
139 class IntentResponse extends ChromeObject { 136 class IntentResponse extends ChromeObject {
140 /* 137 /*
141 * Public constructor 138 * Public constructor
142 */ 139 */
143 IntentResponse({int intentId, bool success, Object data}) { 140 IntentResponse({int intentId, bool success, Object data}) {
144 this.intentId = intentId; 141 if (?intentId)
145 this.success = success; 142 this.intentId = intentId;
146 this.data = data; 143 if (?success)
144 this.success = success;
145 if (?data)
146 this.data = data;
147 } 147 }
148 148
149 /* 149 /*
150 * Private constructor 150 * Private constructor
151 */ 151 */
152 IntentResponse._proxy(_jsObject) : super._proxy(_jsObject); 152 IntentResponse._proxy(_jsObject) : super._proxy(_jsObject);
153 153
154 /* 154 /*
155 * Public accessors 155 * Public accessors
156 */ 156 */
157 157
158 /// Identifies the intent. 158 /// Identifies the intent.
159 int get intentId => JS('int', '#.intentId', this._jsObject); 159 int get intentId => JS('int', '#.intentId', this._jsObject);
160 160
161 void set intentId(int intentId) { 161 void set intentId(int intentId) {
162 JS('void', '#.intentId = #', this._jsObject, intentId); 162 JS('void', '#.intentId = #', this._jsObject, intentId);
163 } 163 }
164 164
165 /// Was this intent successful? (i.e., postSuccess vs postFailure). 165 /// Was this intent successful? (i.e., postSuccess vs postFailure).
166 bool get success => JS('bool', '#.success', this._jsObject); 166 bool get success => JS('bool', '#.success', this._jsObject);
167 167
168 void set success(bool success) { 168 void set success(bool success) {
169 JS('void', '#.success = #', this._jsObject, success); 169 JS('void', '#.success = #', this._jsObject, success);
170 } 170 }
171 171
172 /// Data associated with the intent response. 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); 173 Object get data => JS('Object', '#.data', this._jsObject);
175 174
176 void set data(Object data) { 175 void set data(Object data) {
177 JS('void', '#.data = #', this._jsObject, convertArgument(data)); 176 JS('void', '#.data = #', this._jsObject, convertArgument(data));
178 } 177 }
179 } 178 }
180 179
181 /** 180 /**
182 * Events 181 * Events
183 */ 182 */
184 183
184 /// Fired when an app is launched from the launcher or in response to a web
185 /// intent.
186 class Event_app_runtime_onLaunched extends Event {
187 void addListener(void callback(LaunchData launchData)) {
188 void __proxy_callback(launchData) {
189 if (?callback) {
190 callback(new LaunchData._proxy(launchData));
191 }
192 }
193 super.addListener(callback);
194 }
195
196 void removeListener(void callback(LaunchData launchData)) {
197 void __proxy_callback(launchData) {
198 if (?callback) {
199 callback(new LaunchData._proxy(launchData));
200 }
201 }
202 super.removeListener(callback);
203 }
204
205 bool hasListener(void callback(LaunchData launchData)) {
206 void __proxy_callback(launchData) {
207 if (?callback) {
208 callback(new LaunchData._proxy(launchData));
209 }
210 }
211 super.hasListener(callback);
212 }
213
214 Event_app_runtime_onLaunched(jsObject) : super._(jsObject, 1);
215 }
216
185 /// Fired at Chrome startup to apps that were running when Chrome last shut 217 /// Fired at Chrome startup to apps that were running when Chrome last shut
186 /// down. 218 /// down.
187 class Event_ChromeAppRuntimeOnRestarted extends Event { 219 class Event_app_runtime_onRestarted extends Event {
188 /* 220 void addListener(void callback()) => super.addListener(callback);
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 221
198 /* 222 void removeListener(void callback()) => super.removeListener(callback);
199 * Constructor
200 */
201 Event_ChromeAppRuntimeOnRestarted(jsObject) : super._(jsObject, 0);
202 }
203 223
204 /// Fired when an app is launched from the launcher or in response to a web 224 bool hasListener(void callback()) => super.hasListener(callback);
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 225
217 /* 226 Event_app_runtime_onRestarted(jsObject) : super._(jsObject, 0);
218 * Constructor
219 */
220 Event_ChromeAppRuntimeOnLaunched(jsObject) : super._(jsObject, 1);
221 } 227 }
222 228
223 /** 229 /**
224 * Functions 230 * Functions
225 */ 231 */
226 class API_ChromeAppRuntime { 232
233 class API_app_runtime {
227 /* 234 /*
228 * API connection 235 * API connection
229 */ 236 */
230 Object _jsObject; 237 Object _jsObject;
231 238
232 /* 239 /*
233 * Events 240 * Events
234 */ 241 */
235 Event_ChromeAppRuntimeOnRestarted onRestarted; 242 Event_app_runtime_onLaunched onLaunched;
236 Event_ChromeAppRuntimeOnLaunched onLaunched; 243 Event_app_runtime_onRestarted onRestarted;
237 244
238 /* 245 /*
239 * Functions 246 * Functions
240 */ 247 */
241 void postIntentResponse(IntentResponse intentResponse) =>
242 JS('void', '#.postIntentResponse(#)', this._jsObject,
243 convertArgument(intentResponse));
244 248
245 /* 249 /// postIntentResponse is an internal method to responds to an intent
246 * Constructor 250 /// previously sent to a packaged app. This is identified by intentId, and
247 */ 251 /// should only be invoked at most once per intentId.
248 API_ChromeAppRuntime(this._jsObject) { 252 void postIntentResponse(IntentResponse intentResponse) => JS('void', '#.postIn tentResponse(#)', this._jsObject, convertArgument(intentResponse));
249 onRestarted = new Event_ChromeAppRuntimeOnRestarted(JS('Object', 253
250 '#.onRestarted', 254 API_app_runtime(this._jsObject) {
251 this._jsObject)); 255 onLaunched = new Event_app_runtime_onLaunched(JS('', '#.onLaunched', this._j sObject));
252 onLaunched = new Event_ChromeAppRuntimeOnLaunched(JS('Object', 256 onRestarted = new Event_app_runtime_onRestarted(JS('', '#.onRestarted', this ._jsObject));
253 '#.onLaunched',
254 this._jsObject));
255 } 257 }
256 } 258 }
257
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698