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

Side by Side Diff: sdk/lib/chrome/dart2js/chrome_dart2js.dart

Issue 23654055: Move dart:chrome to dart:_chrome. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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
(Empty)
1 /// Native wrappers for the Chrome packaged app APIs.
2 ///
3 /// These functions allow direct access to the chrome.* APIs, allowing
4 /// Chrome packaged apps to be written using Dart.
5 ///
6 /// For more information on these APIs, see the
7 /// [chrome.* API documentation](http://developer.chrome.com/apps/api_index.html ).
8 library chrome;
9
10 import 'dart:_foreign_helper' show JS;
11 import 'dart:_js_helper';
12 import 'dart:html_common';
13 import 'dart:html';
14
15 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
16 // for details. All rights reserved. Use of this source code is governed by a
17 // BSD-style license that can be found in the LICENSE file.
18
19 // DO NOT EDIT
20 // Auto-generated dart:chrome library.
21
22
23 /* TODO(sashab): Add "show convertDartClosureToJS" once 'show' works. */
24
25
26 // Generated files below this line.
27 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
28 // for details. All rights reserved. Use of this source code is governed by a
29 // BSD-style license that can be found in the LICENSE file.
30
31 /**
32 * A set of utilities for use with the Chrome Extension APIs.
33 *
34 * Allows for easy access to required JS objects.
35 */
36
37 /**
38 * A dart object, that is convertible to JS. Used for creating objects in dart,
39 * then passing them to JS.
40 *
41 * Objects that are passable to JS need to implement this interface.
42 */
43 abstract class ChromeObject {
44 /*
45 * Default Constructor
46 *
47 * Called by child objects during their regular construction.
48 */
49 ChromeObject() : _jsObject = JS('var', '{}');
50
51 /*
52 * Internal proxy constructor
53 *
54 * Creates a new Dart object using this existing proxy.
55 */
56 ChromeObject._proxy(this._jsObject);
57
58 /*
59 * JS Object Representation
60 */
61 final Object _jsObject;
62 }
63
64 /**
65 * Useful functions for converting arguments.
66 */
67
68 /**
69 * Converts the given map-type argument to js-friendly format, recursively.
70 * Returns the new Map object.
71 */
72 Object _convertMapArgument(Map argument) {
73 Map m = new Map();
74 for (Object key in argument.keys)
75 m[key] = convertArgument(argument[key]);
76 return convertDartToNative_Dictionary(m);
77 }
78
79 /**
80 * Converts the given list-type argument to js-friendly format, recursively.
81 * Returns the new List object.
82 */
83 List _convertListArgument(List argument) {
84 List l = new List();
85 for (var i = 0; i < argument.length; i ++)
86 l.add(convertArgument(argument[i]));
87 return l;
88 }
89
90 /**
91 * Converts the given argument Object to js-friendly format, recursively.
92 *
93 * Flattens out all Chrome objects into their corresponding ._toMap()
94 * definitions, then converts them to JS objects.
95 *
96 * Returns the new argument.
97 *
98 * Cannot be used for functions.
99 */
100 Object convertArgument(var argument) {
101 if (argument == null)
102 return argument;
103
104 if (argument is num || argument is String || argument is bool)
105 return argument;
106
107 if (argument is ChromeObject)
108 return argument._jsObject;
109
110 if (argument is List)
111 return _convertListArgument(argument);
112
113 if (argument is Map)
114 return _convertMapArgument(argument);
115
116 if (argument is Function)
117 throw new Exception("Cannot serialize Function argument ${argument}.");
118
119 // TODO(sashab): Try and detect whether the argument is already serialized.
120 return argument;
121 }
122
123 /// Description of a declarative rule for handling events.
124 class Rule extends ChromeObject {
125 /*
126 * Public (Dart) constructor
127 */
128 Rule({String id, List conditions, List actions, int priority}) {
129 this.id = id;
130 this.conditions = conditions;
131 this.actions = actions;
132 this.priority = priority;
133 }
134
135 /*
136 * Private (JS) constructor
137 */
138 Rule._proxy(_jsObject) : super._proxy(_jsObject);
139
140 /*
141 * Public accessors
142 */
143 String get id => JS('String', '#.id', this._jsObject);
144
145 void set id(String id) {
146 JS('void', '#.id = #', this._jsObject, id);
147 }
148
149 // TODO(sashab): Wrap these generic Lists somehow.
150 List get conditions => JS('List', '#.conditions', this._jsObject);
151
152 void set conditions(List conditions) {
153 JS('void', '#.conditions = #', this._jsObject, convertArgument(conditions));
154 }
155
156 // TODO(sashab): Wrap these generic Lists somehow.
157 List get actions => JS('List', '#.actions', this._jsObject);
158
159 void set actions(List actions) {
160 JS('void', '#.actions = #', this._jsObject, convertArgument(actions));
161 }
162
163 int get priority => JS('int', '#.priority', this._jsObject);
164
165 void set priority(int priority) {
166 JS('void', '#.priority = #', this._jsObject, priority);
167 }
168
169 }
170
171 /**
172 * The Event class.
173 *
174 * Chrome Event classes extend this interface.
175 *
176 * e.g.
177 *
178 * // chrome.app.runtime.onLaunched
179 * class Event_ChromeAppRuntimeOnLaunched extends Event {
180 * // constructor, passing the arity of the callback
181 * Event_ChromeAppRuntimeOnLaunched(jsObject) :
182 * super._(jsObject, 1);
183 *
184 * // methods, strengthening the Function parameter specificity
185 * void addListener(void callback(LaunchData launchData))
186 * => super.addListener(callback);
187 * void removeListener(void callback(LaunchData launchData))
188 * => super.removeListener(callback);
189 * bool hasListener(void callback(LaunchData launchData))
190 * => super.hasListener(callback);
191 * }
192 *
193 */
194 class Event {
195 /*
196 * JS Object Representation
197 */
198 final Object _jsObject;
199
200 /*
201 * Number of arguments the callback takes.
202 */
203 final int _callbackArity;
204
205 /*
206 * Private constructor
207 */
208 Event._(this._jsObject, this._callbackArity);
209
210 /*
211 * Methods
212 */
213
214 /// Registers an event listener <em>callback</em> to an event.
215 void addListener(Function callback) =>
216 JS('void',
217 '#.addListener(#)',
218 this._jsObject,
219 convertDartClosureToJS(callback, this._callbackArity)
220 );
221
222 /// Deregisters an event listener <em>callback</em> from an event.
223 void removeListener(Function callback) =>
224 JS('void',
225 '#.removeListener(#)',
226 this._jsObject,
227 convertDartClosureToJS(callback, this._callbackArity)
228 );
229
230 /// Returns True if <em>callback</em> is registered to the event.
231 bool hasListener(Function callback) =>
232 JS('bool',
233 '#.hasListener(#)',
234 this._jsObject,
235 convertDartClosureToJS(callback, this._callbackArity)
236 );
237
238 /// Returns true if any event listeners are registered to the event.
239 bool hasListeners() =>
240 JS('bool',
241 '#.hasListeners()',
242 this._jsObject
243 );
244
245 /// Registers rules to handle events.
246 ///
247 /// [eventName] is the name of the event this function affects and [rules] are
248 /// the rules to be registered. These do not replace previously registered
249 /// rules. [callback] is called with registered rules.
250 ///
251 void addRules(String eventName, List<Rule> rules,
252 [void callback(List<Rule> rules)]) {
253 // proxy the callback
254 void __proxy_callback(List rules) {
255 if (callback != null) {
256 List<Rule> __proxy_rules = new List<Rule>();
257
258 for (Object o in rules)
259 __proxy_rules.add(new Rule._proxy(o));
260
261 callback(__proxy_rules);
262 }
263 }
264
265 JS('void',
266 '#.addRules(#, #, #)',
267 this._jsObject,
268 convertArgument(eventName),
269 convertArgument(rules),
270 convertDartClosureToJS(__proxy_callback, 1)
271 );
272 }
273
274 /// Returns currently registered rules.
275 ///
276 /// [eventName] is the name of the event this function affects and, if an arra y
277 /// is passed as [ruleIdentifiers], only rules with identifiers contained in
278 /// this array are returned. [callback] is called with registered rules.
279 ///
280 void getRules(String eventName, [List<String> ruleIdentifiers,
281 void callback(List<Rule> rules)]) {
282 // proxy the callback
283 void __proxy_callback(List rules) {
284 if (callback != null) {
285 List<Rule> __proxy_rules = new List<Rule>();
286
287 for (Object o in rules)
288 __proxy_rules.add(new Rule._proxy(o));
289
290 callback(__proxy_rules);
291 }
292 }
293
294 JS('void',
295 '#.getRules(#, #, #)',
296 this._jsObject,
297 convertArgument(eventName),
298 convertArgument(ruleIdentifiers),
299 convertDartClosureToJS(__proxy_callback, 1)
300 );
301 }
302
303 /// Unregisters currently registered rules.
304 ///
305 /// [eventName] is the name of the event this function affects and, if an arra y
306 /// is passed as [ruleIdentifiers], only rules with identifiers contained in
307 /// this array are unregistered. [callback] is called when the rules are
308 /// unregistered.
309 ///
310 void removeRules(String eventName, [List<String> ruleIdentifiers,
311 void callback()]) =>
312 JS('void',
313 '#.removeRules(#, #, #)',
314 this._jsObject,
315 convertArgument(eventName),
316 convertArgument(ruleIdentifiers),
317 convertDartClosureToJS(callback, 0)
318 );
319 }
320
321 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
322 // for details. All rights reserved. Use of this source code is governed by a
323 // BSD-style license that can be found in the LICENSE file.
324
325
326 // chrome.app
327 class API_ChromeApp {
328 /*
329 * JS Variable
330 */
331 final Object _jsObject;
332
333 /*
334 * Members
335 */
336 API_app_window window;
337 API_app_runtime runtime;
338
339 /*
340 * Constructor
341 */
342 API_ChromeApp(this._jsObject) {
343 var window_object = JS('', '#.window', this._jsObject);
344 if (window_object == null)
345 throw new UnsupportedError('Not supported by current browser.');
346 window = new API_app_window(window_object);
347
348 var runtime_object = JS('', '#.runtime', this._jsObject);
349 if (runtime_object == null)
350 throw new UnsupportedError('Not supported by current browser.');
351 runtime = new API_app_runtime(runtime_object);
352 }
353 }
354
355 // chrome
356 class API_Chrome {
357 /*
358 * JS Variable
359 */
360 Object _jsObject;
361
362 /*
363 * Members
364 */
365 API_ChromeApp app;
366 API_file_system fileSystem;
367
368 /*
369 * Constructor
370 */
371 API_Chrome() {
372 this._jsObject = JS("Object", "chrome");
373 if (this._jsObject == null)
374 throw new UnsupportedError('Not supported by current browser.');
375
376 var app_object = JS('', '#.app', this._jsObject);
377 if (app_object == null)
378 throw new UnsupportedError('Not supported by current browser.');
379 app = new API_ChromeApp(app_object);
380
381 var file_system_object = JS('', '#.fileSystem', this._jsObject);
382 if (file_system_object == null)
383 throw new UnsupportedError('Not supported by current browser.');
384 fileSystem = new API_file_system(file_system_object);
385 }
386 }
387
388 // The final chrome objects
389 final API_Chrome chrome = new API_Chrome();
390 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
391 // for details. All rights reserved. Use of this source code is governed by a
392 // BSD-style license that can be found in the LICENSE file.
393
394 // Generated from namespace: app.window
395
396
397 /**
398 * Types
399 */
400
401 class AppWindowBounds extends ChromeObject {
402 /*
403 * Public constructor
404 */
405 AppWindowBounds({int left, int top, int width, int height}) {
406 if (left != null)
407 this.left = left;
408 if (top != null)
409 this.top = top;
410 if (width != null)
411 this.width = width;
412 if (height != null)
413 this.height = height;
414 }
415
416 /*
417 * Private constructor
418 */
419 AppWindowBounds._proxy(_jsObject) : super._proxy(_jsObject);
420
421 /*
422 * Public accessors
423 */
424 int get left => JS('int', '#.left', this._jsObject);
425
426 void set left(int left) {
427 JS('void', '#.left = #', this._jsObject, left);
428 }
429
430 int get top => JS('int', '#.top', this._jsObject);
431
432 void set top(int top) {
433 JS('void', '#.top = #', this._jsObject, top);
434 }
435
436 int get width => JS('int', '#.width', this._jsObject);
437
438 void set width(int width) {
439 JS('void', '#.width = #', this._jsObject, width);
440 }
441
442 int get height => JS('int', '#.height', this._jsObject);
443
444 void set height(int height) {
445 JS('void', '#.height = #', this._jsObject, height);
446 }
447
448 }
449
450 class AppWindowCreateWindowOptions extends ChromeObject {
451 /*
452 * Public constructor
453 */
454 AppWindowCreateWindowOptions({String id, int defaultWidth, int defaultHeight, int defaultLeft, int defaultTop, int width, int height, int left, int top, int m inWidth, int minHeight, int maxWidth, int maxHeight, String type, String frame, AppWindowBounds bounds, bool transparentBackground, String state, bool hidden, b ool resizable, bool singleton}) {
455 if (id != null)
456 this.id = id;
457 if (defaultWidth != null)
458 this.defaultWidth = defaultWidth;
459 if (defaultHeight != null)
460 this.defaultHeight = defaultHeight;
461 if (defaultLeft != null)
462 this.defaultLeft = defaultLeft;
463 if (defaultTop != null)
464 this.defaultTop = defaultTop;
465 if (width != null)
466 this.width = width;
467 if (height != null)
468 this.height = height;
469 if (left != null)
470 this.left = left;
471 if (top != null)
472 this.top = top;
473 if (minWidth != null)
474 this.minWidth = minWidth;
475 if (minHeight != null)
476 this.minHeight = minHeight;
477 if (maxWidth != null)
478 this.maxWidth = maxWidth;
479 if (maxHeight != null)
480 this.maxHeight = maxHeight;
481 if (type != null)
482 this.type = type;
483 if (frame != null)
484 this.frame = frame;
485 if (bounds != null)
486 this.bounds = bounds;
487 if (transparentBackground != null)
488 this.transparentBackground = transparentBackground;
489 if (state != null)
490 this.state = state;
491 if (hidden != null)
492 this.hidden = hidden;
493 if (resizable != null)
494 this.resizable = resizable;
495 if (singleton != null)
496 this.singleton = singleton;
497 }
498
499 /*
500 * Private constructor
501 */
502 AppWindowCreateWindowOptions._proxy(_jsObject) : super._proxy(_jsObject);
503
504 /*
505 * Public accessors
506 */
507 /// Id to identify the window. This will be used to remember the size and
508 /// position of the window and restore that geometry when a window with the
509 /// same id is later opened.
510 String get id => JS('String', '#.id', this._jsObject);
511
512 void set id(String id) {
513 JS('void', '#.id = #', this._jsObject, id);
514 }
515
516 /// Default width of the window. (Deprecated; regular bounds act like this
517 /// now.)
518 int get defaultWidth => JS('int', '#.defaultWidth', this._jsObject);
519
520 void set defaultWidth(int defaultWidth) {
521 JS('void', '#.defaultWidth = #', this._jsObject, defaultWidth);
522 }
523
524 /// Default height of the window. (Deprecated; regular bounds act like this
525 /// now.)
526 int get defaultHeight => JS('int', '#.defaultHeight', this._jsObject);
527
528 void set defaultHeight(int defaultHeight) {
529 JS('void', '#.defaultHeight = #', this._jsObject, defaultHeight);
530 }
531
532 /// Default X coordinate of the window. (Deprecated; regular bounds act like
533 /// this now.)
534 int get defaultLeft => JS('int', '#.defaultLeft', this._jsObject);
535
536 void set defaultLeft(int defaultLeft) {
537 JS('void', '#.defaultLeft = #', this._jsObject, defaultLeft);
538 }
539
540 /// Default Y coordinate of the window. (Deprecated; regular bounds act like
541 /// this now.)
542 int get defaultTop => JS('int', '#.defaultTop', this._jsObject);
543
544 void set defaultTop(int defaultTop) {
545 JS('void', '#.defaultTop = #', this._jsObject, defaultTop);
546 }
547
548 /// Width of the window. (Deprecated; use 'bounds'.)
549 int get width => JS('int', '#.width', this._jsObject);
550
551 void set width(int width) {
552 JS('void', '#.width = #', this._jsObject, width);
553 }
554
555 /// Height of the window. (Deprecated; use 'bounds'.)
556 int get height => JS('int', '#.height', this._jsObject);
557
558 void set height(int height) {
559 JS('void', '#.height = #', this._jsObject, height);
560 }
561
562 /// X coordinate of the window. (Deprecated; use 'bounds'.)
563 int get left => JS('int', '#.left', this._jsObject);
564
565 void set left(int left) {
566 JS('void', '#.left = #', this._jsObject, left);
567 }
568
569 /// Y coordinate of the window. (Deprecated; use 'bounds'.)
570 int get top => JS('int', '#.top', this._jsObject);
571
572 void set top(int top) {
573 JS('void', '#.top = #', this._jsObject, top);
574 }
575
576 /// Minimum width for the lifetime of the window.
577 int get minWidth => JS('int', '#.minWidth', this._jsObject);
578
579 void set minWidth(int minWidth) {
580 JS('void', '#.minWidth = #', this._jsObject, minWidth);
581 }
582
583 /// Minimum height for the lifetime of the window.
584 int get minHeight => JS('int', '#.minHeight', this._jsObject);
585
586 void set minHeight(int minHeight) {
587 JS('void', '#.minHeight = #', this._jsObject, minHeight);
588 }
589
590 /// Maximum width for the lifetime of the window.
591 int get maxWidth => JS('int', '#.maxWidth', this._jsObject);
592
593 void set maxWidth(int maxWidth) {
594 JS('void', '#.maxWidth = #', this._jsObject, maxWidth);
595 }
596
597 /// Maximum height for the lifetime of the window.
598 int get maxHeight => JS('int', '#.maxHeight', this._jsObject);
599
600 void set maxHeight(int maxHeight) {
601 JS('void', '#.maxHeight = #', this._jsObject, maxHeight);
602 }
603
604 /// Type of window to create.
605 String get type => JS('String', '#.type', this._jsObject);
606
607 void set type(String type) {
608 JS('void', '#.type = #', this._jsObject, type);
609 }
610
611 /// Frame type: 'none' or 'chrome' (defaults to 'chrome').
612 String get frame => JS('String', '#.frame', this._jsObject);
613
614 void set frame(String frame) {
615 JS('void', '#.frame = #', this._jsObject, frame);
616 }
617
618 /// Size and position of the content in the window (excluding the titlebar). I f
619 /// an id is also specified and a window with a matching id has been shown
620 /// before, the remembered bounds of the window will be used instead.
621 AppWindowBounds get bounds => new AppWindowBounds._proxy(JS('', '#.bounds', th is._jsObject));
622
623 void set bounds(AppWindowBounds bounds) {
624 JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds));
625 }
626
627 /// Enable window background transparency. Only supported in ash. Requires
628 /// experimental API permission.
629 bool get transparentBackground => JS('bool', '#.transparentBackground', this._ jsObject);
630
631 void set transparentBackground(bool transparentBackground) {
632 JS('void', '#.transparentBackground = #', this._jsObject, transparentBackgro und);
633 }
634
635 /// The initial state of the window, allowing it to be created already
636 /// fullscreen, maximized, or minimized. Defaults to 'normal'.
637 String get state => JS('String', '#.state', this._jsObject);
638
639 void set state(String state) {
640 JS('void', '#.state = #', this._jsObject, state);
641 }
642
643 /// If true, the window will be created in a hidden state. Call show() on the
644 /// window to show it once it has been created. Defaults to false.
645 bool get hidden => JS('bool', '#.hidden', this._jsObject);
646
647 void set hidden(bool hidden) {
648 JS('void', '#.hidden = #', this._jsObject, hidden);
649 }
650
651 /// If true, the window will be resizable by the user. Defaults to true.
652 bool get resizable => JS('bool', '#.resizable', this._jsObject);
653
654 void set resizable(bool resizable) {
655 JS('void', '#.resizable = #', this._jsObject, resizable);
656 }
657
658 /// By default if you specify an id for the window, the window will only be
659 /// created if another window with the same id doesn't already exist. If a
660 /// window with the same id already exists that window is activated instead. I f
661 /// you do want to create multiple windows with the same id, you can set this
662 /// property to false.
663 bool get singleton => JS('bool', '#.singleton', this._jsObject);
664
665 void set singleton(bool singleton) {
666 JS('void', '#.singleton = #', this._jsObject, singleton);
667 }
668
669 }
670
671 class AppWindowAppWindow extends ChromeObject {
672 /*
673 * Private constructor
674 */
675 AppWindowAppWindow._proxy(_jsObject) : super._proxy(_jsObject);
676
677 /*
678 * Public accessors
679 */
680 /// The JavaScript 'window' object for the created child.
681 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
682 // for details. All rights reserved. Use of this source code is governed by a
683 // BSD-style license that can be found in the LICENSE file.
684
685 // TODO(sashab, sra): Detect whether this is the current window, or an
686 // external one, and return an appropriately-typed object
687 WindowBase get contentWindow =>
688 JS("Window", "#.contentWindow", this._jsObject);
689
690 /*
691 * Methods
692 */
693 /// Focus the window.
694 void focus() => JS('void', '#.focus()', this._jsObject);
695
696 /// Fullscreens the window.
697 void fullscreen() => JS('void', '#.fullscreen()', this._jsObject);
698
699 /// Is the window fullscreen?
700 bool isFullscreen() => JS('bool', '#.isFullscreen()', this._jsObject);
701
702 /// Minimize the window.
703 void minimize() => JS('void', '#.minimize()', this._jsObject);
704
705 /// Is the window minimized?
706 bool isMinimized() => JS('bool', '#.isMinimized()', this._jsObject);
707
708 /// Maximize the window.
709 void maximize() => JS('void', '#.maximize()', this._jsObject);
710
711 /// Is the window maximized?
712 bool isMaximized() => JS('bool', '#.isMaximized()', this._jsObject);
713
714 /// Restore the window, exiting a maximized, minimized, or fullscreen state.
715 void restore() => JS('void', '#.restore()', this._jsObject);
716
717 /// Move the window to the position (|left|, |top|).
718 void moveTo(int left, int top) => JS('void', '#.moveTo(#, #)', this._jsObject, left, top);
719
720 /// Resize the window to |width|x|height| pixels in size.
721 void resizeTo(int width, int height) => JS('void', '#.resizeTo(#, #)', this._j sObject, width, height);
722
723 /// Draw attention to the window.
724 void drawAttention() => JS('void', '#.drawAttention()', this._jsObject);
725
726 /// Clear attention to the window.
727 void clearAttention() => JS('void', '#.clearAttention()', this._jsObject);
728
729 /// Close the window.
730 void close() => JS('void', '#.close()', this._jsObject);
731
732 /// Show the window. Does nothing if the window is already visible.
733 void show() => JS('void', '#.show()', this._jsObject);
734
735 /// Hide the window. Does nothing if the window is already hidden.
736 void hide() => JS('void', '#.hide()', this._jsObject);
737
738 /// Get the window's bounds as a $ref:Bounds object.
739 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
740 // for details. All rights reserved. Use of this source code is governed by a
741 // BSD-style license that can be found in the LICENSE file.
742
743 // TODO(sashab, kalman): Fix IDL parser to read function return values
744 // correctly. Currently, it just reads void for all functions.
745 AppWindowBounds getBounds() =>
746 new AppWindowBounds._proxy(JS('void', '#.getBounds()', this._jsObject));
747
748 /// Set the window's bounds.
749 void setBounds(AppWindowBounds bounds) => JS('void', '#.setBounds(#)', this._j sObject, convertArgument(bounds));
750
751 /// Set the app icon for the window (experimental). Currently this is only
752 /// being implemented on Ash. TODO(stevenjb): Investigate implementing this on
753 /// Windows and OSX.
754 void setIcon(String icon_url) => JS('void', '#.setIcon(#)', this._jsObject, ic on_url);
755
756 }
757
758 /**
759 * Events
760 */
761
762 /// Fired when the window is resized.
763 class Event_app_window_onBoundsChanged extends Event {
764 void addListener(void callback()) => super.addListener(callback);
765
766 void removeListener(void callback()) => super.removeListener(callback);
767
768 bool hasListener(void callback()) => super.hasListener(callback);
769
770 Event_app_window_onBoundsChanged(jsObject) : super._(jsObject, 0);
771 }
772
773 /// Fired when the window is closed.
774 class Event_app_window_onClosed extends Event {
775 void addListener(void callback()) => super.addListener(callback);
776
777 void removeListener(void callback()) => super.removeListener(callback);
778
779 bool hasListener(void callback()) => super.hasListener(callback);
780
781 Event_app_window_onClosed(jsObject) : super._(jsObject, 0);
782 }
783
784 /// Fired when the window is fullscreened.
785 class Event_app_window_onFullscreened extends Event {
786 void addListener(void callback()) => super.addListener(callback);
787
788 void removeListener(void callback()) => super.removeListener(callback);
789
790 bool hasListener(void callback()) => super.hasListener(callback);
791
792 Event_app_window_onFullscreened(jsObject) : super._(jsObject, 0);
793 }
794
795 /// Fired when the window is maximized.
796 class Event_app_window_onMaximized extends Event {
797 void addListener(void callback()) => super.addListener(callback);
798
799 void removeListener(void callback()) => super.removeListener(callback);
800
801 bool hasListener(void callback()) => super.hasListener(callback);
802
803 Event_app_window_onMaximized(jsObject) : super._(jsObject, 0);
804 }
805
806 /// Fired when the window is minimized.
807 class Event_app_window_onMinimized extends Event {
808 void addListener(void callback()) => super.addListener(callback);
809
810 void removeListener(void callback()) => super.removeListener(callback);
811
812 bool hasListener(void callback()) => super.hasListener(callback);
813
814 Event_app_window_onMinimized(jsObject) : super._(jsObject, 0);
815 }
816
817 /// Fired when the window is restored from being minimized or maximized.
818 class Event_app_window_onRestored extends Event {
819 void addListener(void callback()) => super.addListener(callback);
820
821 void removeListener(void callback()) => super.removeListener(callback);
822
823 bool hasListener(void callback()) => super.hasListener(callback);
824
825 Event_app_window_onRestored(jsObject) : super._(jsObject, 0);
826 }
827
828 /**
829 * Functions
830 */
831
832 class API_app_window {
833 /*
834 * API connection
835 */
836 Object _jsObject;
837
838 /*
839 * Events
840 */
841 Event_app_window_onBoundsChanged onBoundsChanged;
842 Event_app_window_onClosed onClosed;
843 Event_app_window_onFullscreened onFullscreened;
844 Event_app_window_onMaximized onMaximized;
845 Event_app_window_onMinimized onMinimized;
846 Event_app_window_onRestored onRestored;
847
848 /*
849 * Functions
850 */
851 /// The size and position of a window can be specified in a number of differen t
852 /// ways. The most simple option is not specifying anything at all, in which
853 /// case a default size and platform dependent position will be used.<br/><br/ >
854 /// Another option is to use the bounds property, which will put the window at
855 /// the specified coordinates with the specified size. If the window has a
856 /// frame, it's total size will be the size given plus the size of the frame;
857 /// that is, the size in bounds is the content size, not the window
858 /// size.<br/><br/> To automatically remember the positions of windows you can
859 /// give them ids. If a window has an id, This id is used to remember the size
860 /// and position of the window whenever it is moved or resized. This size and
861 /// position is then used instead of the specified bounds on subsequent openin g
862 /// of a window with the same id. If you need to open a window with an id at a
863 /// location other than the remembered default, you can create it hidden, move
864 /// it to the desired location, then show it.
865 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
866 // for details. All rights reserved. Use of this source code is governed by a
867 // BSD-style license that can be found in the LICENSE file.
868
869 // TODO(sashab): This override is no longer needed once prefixes are removed.
870 void create(String url,
871 [AppWindowCreateWindowOptions options,
872 void callback(AppWindowAppWindow created_window)]) {
873 void __proxy_callback(created_window) {
874 if (callback != null)
875 callback(new AppWindowAppWindow._proxy(created_window));
876 }
877 JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options ),
878 convertDartClosureToJS(__proxy_callback, 1));
879 }
880
881 /// Returns an $ref:AppWindow object for the current script context (ie
882 /// JavaScript 'window' object). This can also be called on a handle to a
883 /// script context for another page, for example:
884 /// otherWindow.chrome.app.window.current().
885 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
886 // for details. All rights reserved. Use of this source code is governed by a
887 // BSD-style license that can be found in the LICENSE file.
888
889 // TODO(sashab, kalman): Fix IDL parser to read function return values
890 // correctly. Currently, it just reads void for all functions.
891 AppWindowAppWindow current() =>
892 new AppWindowAppWindow._proxy(JS('void', '#.current()', this._jsObject));
893
894 void initializeAppWindow(Object state) => JS('void', '#.initializeAppWindow(#) ', this._jsObject, convertArgument(state));
895
896 API_app_window(this._jsObject) {
897 onBoundsChanged = new Event_app_window_onBoundsChanged(JS('', '#.onBoundsCha nged', this._jsObject));
898 onClosed = new Event_app_window_onClosed(JS('', '#.onClosed', this._jsObject ));
899 onFullscreened = new Event_app_window_onFullscreened(JS('', '#.onFullscreene d', this._jsObject));
900 onMaximized = new Event_app_window_onMaximized(JS('', '#.onMaximized', this. _jsObject));
901 onMinimized = new Event_app_window_onMinimized(JS('', '#.onMinimized', this. _jsObject));
902 onRestored = new Event_app_window_onRestored(JS('', '#.onRestored', this._js Object));
903 }
904 }
905 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
906 // for details. All rights reserved. Use of this source code is governed by a
907 // BSD-style license that can be found in the LICENSE file.
908
909 // Generated from namespace: app.runtime
910
911
912 /**
913 * Types
914 */
915
916 class AppRuntimeLaunchItem extends ChromeObject {
917 /*
918 * Public constructor
919 */
920 AppRuntimeLaunchItem({FileEntry entry, String type}) {
921 if (entry != null)
922 this.entry = entry;
923 if (type != null)
924 this.type = type;
925 }
926
927 /*
928 * Private constructor
929 */
930 AppRuntimeLaunchItem._proxy(_jsObject) : super._proxy(_jsObject);
931
932 /*
933 * Public accessors
934 */
935 /// FileEntry for the file.
936 FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject);
937
938 void set entry(FileEntry entry) {
939 JS('void', '#.entry = #', this._jsObject, convertArgument(entry));
940 }
941
942 /// The MIME type of the file.
943 String get type => JS('String', '#.type', this._jsObject);
944
945 void set type(String type) {
946 JS('void', '#.type = #', this._jsObject, type);
947 }
948
949 }
950
951 class AppRuntimeLaunchData extends ChromeObject {
952 /*
953 * Public constructor
954 */
955 AppRuntimeLaunchData({String id, List<AppRuntimeLaunchItem> items}) {
956 if (id != null)
957 this.id = id;
958 if (items != null)
959 this.items = items;
960 }
961
962 /*
963 * Private constructor
964 */
965 AppRuntimeLaunchData._proxy(_jsObject) : super._proxy(_jsObject);
966
967 /*
968 * Public accessors
969 */
970 /// The id of the file handler that the app is being invoked with.
971 String get id => JS('String', '#.id', this._jsObject);
972
973 void set id(String id) {
974 JS('void', '#.id = #', this._jsObject, id);
975 }
976
977 List<AppRuntimeLaunchItem> get items {
978 List<AppRuntimeLaunchItem> __proxy_items = new List<AppRuntimeLaunchItem>();
979 int count = JS('int', '#.items.length', this._jsObject);
980 for (int i = 0; i < count; i++) {
981 var item = JS('', '#.items[#]', this._jsObject, i);
982 __proxy_items.add(new AppRuntimeLaunchItem._proxy(item));
983 }
984 return __proxy_items;
985 }
986
987 void set items(List<AppRuntimeLaunchItem> items) {
988 JS('void', '#.items = #', this._jsObject, convertArgument(items));
989 }
990
991 }
992
993 /**
994 * Events
995 */
996
997 /// Fired when an app is launched from the launcher.
998 class Event_app_runtime_onLaunched extends Event {
999 void addListener(void callback(AppRuntimeLaunchData launchData)) {
1000 void __proxy_callback(launchData) {
1001 if (callback != null) {
1002 callback(new AppRuntimeLaunchData._proxy(launchData));
1003 }
1004 }
1005 super.addListener(__proxy_callback);
1006 }
1007
1008 void removeListener(void callback(AppRuntimeLaunchData launchData)) {
1009 void __proxy_callback(launchData) {
1010 if (callback != null) {
1011 callback(new AppRuntimeLaunchData._proxy(launchData));
1012 }
1013 }
1014 super.removeListener(__proxy_callback);
1015 }
1016
1017 bool hasListener(void callback(AppRuntimeLaunchData launchData)) {
1018 void __proxy_callback(launchData) {
1019 if (callback != null) {
1020 callback(new AppRuntimeLaunchData._proxy(launchData));
1021 }
1022 }
1023 super.hasListener(__proxy_callback);
1024 }
1025
1026 Event_app_runtime_onLaunched(jsObject) : super._(jsObject, 1);
1027 }
1028
1029 /// Fired at Chrome startup to apps that were running when Chrome last shut
1030 /// down.
1031 class Event_app_runtime_onRestarted extends Event {
1032 void addListener(void callback()) => super.addListener(callback);
1033
1034 void removeListener(void callback()) => super.removeListener(callback);
1035
1036 bool hasListener(void callback()) => super.hasListener(callback);
1037
1038 Event_app_runtime_onRestarted(jsObject) : super._(jsObject, 0);
1039 }
1040
1041 /**
1042 * Functions
1043 */
1044
1045 class API_app_runtime {
1046 /*
1047 * API connection
1048 */
1049 Object _jsObject;
1050
1051 /*
1052 * Events
1053 */
1054 Event_app_runtime_onLaunched onLaunched;
1055 Event_app_runtime_onRestarted onRestarted;
1056 API_app_runtime(this._jsObject) {
1057 onLaunched = new Event_app_runtime_onLaunched(JS('', '#.onLaunched', this._j sObject));
1058 onRestarted = new Event_app_runtime_onRestarted(JS('', '#.onRestarted', this ._jsObject));
1059 }
1060 }
1061 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
1062 // for details. All rights reserved. Use of this source code is governed by a
1063 // BSD-style license that can be found in the LICENSE file.
1064
1065 // Generated from namespace: fileSystem
1066
1067
1068 /**
1069 * Types
1070 */
1071
1072 class FilesystemAcceptOption extends ChromeObject {
1073 /*
1074 * Public constructor
1075 */
1076 FilesystemAcceptOption({String description, List<String> mimeTypes, List<Strin g> extensions}) {
1077 if (description != null)
1078 this.description = description;
1079 if (mimeTypes != null)
1080 this.mimeTypes = mimeTypes;
1081 if (extensions != null)
1082 this.extensions = extensions;
1083 }
1084
1085 /*
1086 * Private constructor
1087 */
1088 FilesystemAcceptOption._proxy(_jsObject) : super._proxy(_jsObject);
1089
1090 /*
1091 * Public accessors
1092 */
1093 /// This is the optional text description for this option. If not present, a
1094 /// description will be automatically generated; typically containing an
1095 /// expanded list of valid extensions (e.g. "text/html" may expand to "*.html,
1096 /// *.htm").
1097 String get description => JS('String', '#.description', this._jsObject);
1098
1099 void set description(String description) {
1100 JS('void', '#.description = #', this._jsObject, description);
1101 }
1102
1103 /// Mime-types to accept, e.g. "image/jpeg" or "audio/*". One of mimeTypes or
1104 /// extensions must contain at least one valid element.
1105 List<String> get mimeTypes => JS('List<String>', '#.mimeTypes', this._jsObject );
1106
1107 void set mimeTypes(List<String> mimeTypes) {
1108 JS('void', '#.mimeTypes = #', this._jsObject, mimeTypes);
1109 }
1110
1111 /// Extensions to accept, e.g. "jpg", "gif", "crx".
1112 List<String> get extensions => JS('List<String>', '#.extensions', this._jsObje ct);
1113
1114 void set extensions(List<String> extensions) {
1115 JS('void', '#.extensions = #', this._jsObject, extensions);
1116 }
1117
1118 }
1119
1120 class FilesystemChooseEntryOptions extends ChromeObject {
1121 /*
1122 * Public constructor
1123 */
1124 FilesystemChooseEntryOptions({String type, String suggestedName, List<Filesyst emAcceptOption> accepts, bool acceptsAllTypes}) {
1125 if (type != null)
1126 this.type = type;
1127 if (suggestedName != null)
1128 this.suggestedName = suggestedName;
1129 if (accepts != null)
1130 this.accepts = accepts;
1131 if (acceptsAllTypes != null)
1132 this.acceptsAllTypes = acceptsAllTypes;
1133 }
1134
1135 /*
1136 * Private constructor
1137 */
1138 FilesystemChooseEntryOptions._proxy(_jsObject) : super._proxy(_jsObject);
1139
1140 /*
1141 * Public accessors
1142 */
1143 /// Type of the prompt to show. The default is 'openFile'.
1144 String get type => JS('String', '#.type', this._jsObject);
1145
1146 void set type(String type) {
1147 JS('void', '#.type = #', this._jsObject, type);
1148 }
1149
1150 /// The suggested file name that will be presented to the user as the default
1151 /// name to read or write. This is optional.
1152 String get suggestedName => JS('String', '#.suggestedName', this._jsObject);
1153
1154 void set suggestedName(String suggestedName) {
1155 JS('void', '#.suggestedName = #', this._jsObject, suggestedName);
1156 }
1157
1158 /// The optional list of accept options for this file opener. Each option will
1159 /// be presented as a unique group to the end-user.
1160 List<FilesystemAcceptOption> get accepts {
1161 List<FilesystemAcceptOption> __proxy_accepts = new List<FilesystemAcceptOpti on>();
1162 int count = JS('int', '#.accepts.length', this._jsObject);
1163 for (int i = 0; i < count; i++) {
1164 var item = JS('', '#.accepts[#]', this._jsObject, i);
1165 __proxy_accepts.add(new FilesystemAcceptOption._proxy(item));
1166 }
1167 return __proxy_accepts;
1168 }
1169
1170 void set accepts(List<FilesystemAcceptOption> accepts) {
1171 JS('void', '#.accepts = #', this._jsObject, convertArgument(accepts));
1172 }
1173
1174 /// Whether to accept all file types, in addition to the options specified in
1175 /// the accepts argument. The default is true. If the accepts field is unset o r
1176 /// contains no valid entries, this will always be reset to true.
1177 bool get acceptsAllTypes => JS('bool', '#.acceptsAllTypes', this._jsObject);
1178
1179 void set acceptsAllTypes(bool acceptsAllTypes) {
1180 JS('void', '#.acceptsAllTypes = #', this._jsObject, acceptsAllTypes);
1181 }
1182
1183 }
1184
1185 /**
1186 * Functions
1187 */
1188
1189 class API_file_system {
1190 /*
1191 * API connection
1192 */
1193 Object _jsObject;
1194
1195 /*
1196 * Functions
1197 */
1198 /// Get the display path of a FileEntry object. The display path is based on
1199 /// the full path of the file on the local file system, but may be made more
1200 /// readable for display purposes.
1201 void getDisplayPath(FileEntry fileEntry, void callback(String displayPath)) => JS('void', '#.getDisplayPath(#, #)', this._jsObject, convertArgument(fileEntry) , convertDartClosureToJS(callback, 1));
1202
1203 /// Get a writable FileEntry from another FileEntry. This call will fail if th e
1204 /// application does not have the 'write' permission under 'fileSystem'.
1205 void getWritableEntry(FileEntry fileEntry, void callback(FileEntry fileEntry)) {
1206 void __proxy_callback(fileEntry) {
1207 if (callback != null) {
1208 callback(fileEntry);
1209 }
1210 }
1211 JS('void', '#.getWritableEntry(#, #)', this._jsObject, convertArgument(fileE ntry), convertDartClosureToJS(__proxy_callback, 1));
1212 }
1213
1214 /// Gets whether this FileEntry is writable or not.
1215 void isWritableEntry(FileEntry fileEntry, void callback(bool isWritable)) => J S('void', '#.isWritableEntry(#, #)', this._jsObject, convertArgument(fileEntry), convertDartClosureToJS(callback, 1));
1216
1217 /// Ask the user to choose a file.
1218 void chooseEntry(void callback(FileEntry fileEntry), [FilesystemChooseEntryOpt ions options]) {
1219 void __proxy_callback(fileEntry) {
1220 if (callback != null) {
1221 callback(fileEntry);
1222 }
1223 }
1224 JS('void', '#.chooseEntry(#, #)', this._jsObject, convertArgument(options), convertDartClosureToJS(__proxy_callback, 1));
1225 }
1226
1227 /// Returns the file entry with the given id if it can be restored. This call
1228 /// will fail otherwise.
1229 void restoreEntry(String id, void callback(FileEntry fileEntry)) {
1230 void __proxy_callback(fileEntry) {
1231 if (callback != null) {
1232 callback(fileEntry);
1233 }
1234 }
1235 JS('void', '#.restoreEntry(#, #)', this._jsObject, id, convertDartClosureToJ S(__proxy_callback, 1));
1236 }
1237
1238 /// Returns whether a file entry for the given id can be restored, i.e. whethe r
1239 /// restoreEntry would succeed with this id now.
1240 void isRestorable(String id, void callback(bool isRestorable)) => JS('void', ' #.isRestorable(#, #)', this._jsObject, id, convertDartClosureToJS(callback, 1));
1241
1242 /// Returns an id that can be passed to restoreEntry to regain access to a
1243 /// given file entry. Only the 500 most recently used entries are retained,
1244 /// where calls to retainEntry and restoreEntry count as use. If the app has
1245 /// the 'retainEntries' permission under 'fileSystem', entries are retained
1246 /// indefinitely. Otherwise, entries are retained only while the app is runnin g
1247 /// and across restarts.
1248 String retainEntry(FileEntry fileEntry) => JS('String', '#.retainEntry(#)', th is._jsObject, convertArgument(fileEntry));
1249
1250 API_file_system(this._jsObject) {
1251 }
1252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698