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

Side by Side Diff: sdk/lib/chrome/dart2js/chrome_dart2js.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 library chrome; 1 library chrome;
2 2
3 import 'dart:_foreign_helper' show JS; 3 import 'dart:_foreign_helper' show JS;
4 import 'dart:_js_helper';
4 import 'dart:html_common'; 5 import 'dart:html_common';
5 import 'dart:html'; 6 import 'dart:html';
6 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 7 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
7 // for details. All rights reserved. Use of this source code is governed by a 8 // for details. All rights reserved. Use of this source code is governed by a
8 // BSD-style license that can be found in the LICENSE file. 9 // BSD-style license that can be found in the LICENSE file.
9 10
10 // DO NOT EDIT 11 // DO NOT EDIT
11 // Auto-generated dart:chrome library. 12 // Auto-generated dart:chrome library.
12 13
13 14
15 /* TODO(sashab): Add "show convertDartClosureToJS" once 'show' works. */
14 16
15 17
18 // Generated files below this line.
19
16 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 20 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
17 // for details. All rights reserved. Use of this source code is governed by a 21 // for details. All rights reserved. Use of this source code is governed by a
18 // BSD-style license that can be found in the LICENSE file. 22 // BSD-style license that can be found in the LICENSE file.
19 23
20 /** 24 /**
21 * A set of utilities for use with the Chrome Extension APIs. 25 * A set of utilities for use with the Chrome Extension APIs.
22 * 26 *
23 * Allows for easy access to required JS objects. 27 * Allows for easy access to required JS objects.
24 */ 28 */
25 29
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // chrome.app 319 // chrome.app
316 class API_ChromeApp { 320 class API_ChromeApp {
317 /* 321 /*
318 * JS Variable 322 * JS Variable
319 */ 323 */
320 Object _jsObject; 324 Object _jsObject;
321 325
322 /* 326 /*
323 * Members 327 * Members
324 */ 328 */
325 API_ChromeAppWindow window; 329 API_app_window window;
326 API_ChromeAppRuntime runtime; 330 API_app_runtime runtime;
327 331
328 /* 332 /*
329 * Constructor 333 * Constructor
330 */ 334 */
331 API_ChromeApp(this._jsObject) { 335 API_ChromeApp(this._jsObject) {
332 var window_object = JS('', '#.window', this._jsObject); 336 var window_object = JS('', '#.window', this._jsObject);
333 if (window_object == null) 337 if (window_object == null)
334 throw new UnsupportedError('Not supported by current browser.'); 338 throw new UnsupportedError('Not supported by current browser.');
335 window = new API_ChromeAppWindow(window_object); 339 window = new API_app_window(window_object);
336 340
337 var runtime_object = JS('', '#.runtime', this._jsObject); 341 var runtime_object = JS('', '#.runtime', this._jsObject);
338 if (runtime_object == null) 342 if (runtime_object == null)
339 throw new UnsupportedError('Not supported by current browser.'); 343 throw new UnsupportedError('Not supported by current browser.');
340 runtime = new API_ChromeAppRuntime(runtime_object); 344 runtime = new API_app_runtime(runtime_object);
341 } 345 }
342 } 346 }
343 347
344 // chrome 348 // chrome
345 class API_Chrome { 349 class API_Chrome {
346 /* 350 /*
347 * JS Variable 351 * JS Variable
348 */ 352 */
349 Object _jsObject; 353 Object _jsObject;
350 354
(...skipping 16 matching lines...) Expand all
367 app = new API_ChromeApp(app_object); 371 app = new API_ChromeApp(app_object);
368 } 372 }
369 } 373 }
370 374
371 // The final chrome objects 375 // The final chrome objects
372 final API_Chrome chrome = new API_Chrome(); 376 final API_Chrome chrome = new API_Chrome();
373 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 377 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
374 // for details. All rights reserved. Use of this source code is governed by a 378 // for details. All rights reserved. Use of this source code is governed by a
375 // BSD-style license that can be found in the LICENSE file. 379 // BSD-style license that can be found in the LICENSE file.
376 380
377 // from app_runtime.idl 381 // Generated from namespace: app.runtime
382
378 383
379 /** 384 /**
380 * Types 385 * Types
381 */ 386 */
382 387
383 /// A WebIntents intent object. Deprecated.
384 class Intent extends ChromeObject { 388 class Intent extends ChromeObject {
385 /* 389 /*
386 * Public (Dart) constructor 390 * Private constructor
387 */
388 Intent({String action, String type, var data}) {
389 this.action = action;
390 this.type = type;
391 this.data = data;
392 }
393
394 /*
395 * Private (JS) constructor
396 */ 391 */
397 Intent._proxy(_jsObject) : super._proxy(_jsObject); 392 Intent._proxy(_jsObject) : super._proxy(_jsObject);
398 393
399 /* 394 /*
400 * Public accessors 395 * Public accessors
401 */ 396 */
402 397
403 /// The WebIntent being invoked. 398 /// The WebIntent being invoked.
404 String get action => JS('String', '#.action', this._jsObject); 399 String get action => JS('String', '#.action', this._jsObject);
405 400
406 void set action(String action) { 401 void set action(String action) {
407 JS('void', '#.action = #', this._jsObject, action); 402 JS('void', '#.action = #', this._jsObject, action);
408 } 403 }
409 404
410 /// The MIME type of the data. 405 /// The MIME type of the data.
411 String get type => JS('String', '#.type', this._jsObject); 406 String get type => JS('String', '#.type', this._jsObject);
412 407
413 void set type(String type) { 408 void set type(String type) {
414 JS('void', '#.type = #', this._jsObject, type); 409 JS('void', '#.type = #', this._jsObject, type);
415 } 410 }
416 411
417 /// Data associated with the intent. 412 /// Data associated with the intent.
418 // TODO(sashab): What is the best way to serialize/return generic JS objects?
419 Object get data => JS('Object', '#.data', this._jsObject); 413 Object get data => JS('Object', '#.data', this._jsObject);
420 414
421 void set data(Object data) { 415 void set data(Object data) {
422 JS('void', '#.data = #', this._jsObject, convertArgument(data)); 416 JS('void', '#.data = #', this._jsObject, convertArgument(data));
423 } 417 }
424 418
425 /* 419 /*
426 * TODO(sashab): What is a NullCallback() type? 420 * Methods
427 * Add postResult and postFailure once understanding what this type is, and
428 * once there is a way to pass functions back from JS.
429 */ 421 */
422 /// Callback to be compatible with WebIntents.
423 void postResult() => JS('void', '#.postResult()', this._jsObject);
424 /// Callback to be compatible with WebIntents.
425 void postFailure() => JS('void', '#.postFailure()', this._jsObject);
430 } 426 }
431 427
432 class LaunchItem extends ChromeObject { 428 class LaunchItem extends ChromeObject {
433 /* 429 /*
434 * Public constructor 430 * Public constructor
435 */ 431 */
436 LaunchItem({FileEntry entry, String type}) { 432 LaunchItem({FileEntry entry, String type}) {
437 this.entry = entry; 433 if (?entry)
438 this.type = type; 434 this.entry = entry;
435 if (?type)
436 this.type = type;
439 } 437 }
440 438
441 /* 439 /*
442 * Private constructor 440 * Private constructor
443 */ 441 */
444 LaunchItem._proxy(_jsObject) : super._proxy(_jsObject); 442 LaunchItem._proxy(_jsObject) : super._proxy(_jsObject);
445 443
446 /* 444 /*
447 * Public accessors 445 * Public accessors
448 */ 446 */
449 447
450 /// FileEntry for the file. 448 /// FileEntry for the file.
451 FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject); 449 FileEntry get entry => JS('FileEntry', '#.entry', this._jsObject);
452 450
453 void set entry(FileEntry entry) { 451 void set entry(FileEntry entry) {
454 JS('void', '#.entry = #', this._jsObject, entry); 452 JS('void', '#.entry = #', this._jsObject, convertArgument(entry));
455 } 453 }
456 454
457 /// The MIME type of the file. 455 /// The MIME type of the file.
458 String get type => JS('String', '#.type', this._jsObject); 456 String get type => JS('String', '#.type', this._jsObject);
459 457
460 void set type(String type) { 458 void set type(String type) {
461 JS('void', '#.type = #', this._jsObject, type); 459 JS('void', '#.type = #', this._jsObject, type);
462 } 460 }
463 } 461 }
464 462
465 /// Optional data for the launch.
466 class LaunchData extends ChromeObject { 463 class LaunchData extends ChromeObject {
467 /* 464 /*
468 * Public constructor 465 * Public constructor
469 */ 466 */
470 LaunchData({Intent intent, String id, List<LaunchItem> items}) { 467 LaunchData({Intent intent, String id, List<LaunchItem> items}) {
471 this.intent = intent; 468 if (?intent)
472 this.id = id; 469 this.intent = intent;
473 this.items = items; 470 if (?id)
471 this.id = id;
472 if (?items)
473 this.items = items;
474 } 474 }
475 475
476 /* 476 /*
477 * Private constructor 477 * Private constructor
478 */ 478 */
479 LaunchData._proxy(_jsObject) : super._proxy(_jsObject); 479 LaunchData._proxy(_jsObject) : super._proxy(_jsObject);
480 480
481 /* 481 /*
482 * Public accessors 482 * Public accessors
483 */ 483 */
484
484 Intent get intent => new Intent._proxy(JS('', '#.intent', this._jsObject)); 485 Intent get intent => new Intent._proxy(JS('', '#.intent', this._jsObject));
485 486
486 void set intent(Intent intent) { 487 void set intent(Intent intent) {
487 JS('void', '#.intent = #', this._jsObject, convertArgument(intent)); 488 JS('void', '#.intent = #', this._jsObject, convertArgument(intent));
488 } 489 }
489 490
490 /// The id of the file handler that the app is being invoked with. 491 /// The id of the file handler that the app is being invoked with.
491 String get id => JS('String', '#.id', this._jsObject); 492 String get id => JS('String', '#.id', this._jsObject);
492 493
493 void set id(String id) { 494 void set id(String id) {
494 JS('void', '#.id = #', this._jsObject, id); 495 JS('void', '#.id = #', this._jsObject, id);
495 } 496 }
496 497
497 List<LaunchItem> get items() { 498 List<LaunchItem> get items {
498 List<LaunchItem> items_final = new List<LaunchItem>(); 499 List<LaunchItem> __proxy_items = new List<LaunchItem>();
499 for (var o in JS('List', '#.items', this._jsObject)) { 500 for (var o in JS('List', '#.items', this._jsObject)) {
500 items_final.add(new LaunchItem._proxy(o)); 501 __proxy_items.add(new LaunchItem._proxy(o));
501 } 502 }
502 return items_final; 503 return __proxy_items;
503 } 504 }
504 505
505 void set items(List<LaunchItem> items) { 506 void set items(List<LaunchItem> items) {
506 JS('void', '#.items = #', this._jsObject, convertArgument(items)); 507 JS('void', '#.items = #', this._jsObject, convertArgument(items));
507 } 508 }
508 } 509 }
509 510
510 class IntentResponse extends ChromeObject { 511 class IntentResponse extends ChromeObject {
511 /* 512 /*
512 * Public constructor 513 * Public constructor
513 */ 514 */
514 IntentResponse({int intentId, bool success, Object data}) { 515 IntentResponse({int intentId, bool success, Object data}) {
515 this.intentId = intentId; 516 if (?intentId)
516 this.success = success; 517 this.intentId = intentId;
517 this.data = data; 518 if (?success)
519 this.success = success;
520 if (?data)
521 this.data = data;
518 } 522 }
519 523
520 /* 524 /*
521 * Private constructor 525 * Private constructor
522 */ 526 */
523 IntentResponse._proxy(_jsObject) : super._proxy(_jsObject); 527 IntentResponse._proxy(_jsObject) : super._proxy(_jsObject);
524 528
525 /* 529 /*
526 * Public accessors 530 * Public accessors
527 */ 531 */
528 532
529 /// Identifies the intent. 533 /// Identifies the intent.
530 int get intentId => JS('int', '#.intentId', this._jsObject); 534 int get intentId => JS('int', '#.intentId', this._jsObject);
531 535
532 void set intentId(int intentId) { 536 void set intentId(int intentId) {
533 JS('void', '#.intentId = #', this._jsObject, intentId); 537 JS('void', '#.intentId = #', this._jsObject, intentId);
534 } 538 }
535 539
536 /// Was this intent successful? (i.e., postSuccess vs postFailure). 540 /// Was this intent successful? (i.e., postSuccess vs postFailure).
537 bool get success => JS('bool', '#.success', this._jsObject); 541 bool get success => JS('bool', '#.success', this._jsObject);
538 542
539 void set success(bool success) { 543 void set success(bool success) {
540 JS('void', '#.success = #', this._jsObject, success); 544 JS('void', '#.success = #', this._jsObject, success);
541 } 545 }
542 546
543 /// Data associated with the intent response. 547 /// Data associated with the intent response.
544 // TODO(sashab): What's the best way to serialize/return generic JS objects?
545 Object get data => JS('Object', '#.data', this._jsObject); 548 Object get data => JS('Object', '#.data', this._jsObject);
546 549
547 void set data(Object data) { 550 void set data(Object data) {
548 JS('void', '#.data = #', this._jsObject, convertArgument(data)); 551 JS('void', '#.data = #', this._jsObject, convertArgument(data));
549 } 552 }
550 } 553 }
551 554
552 /** 555 /**
553 * Events 556 * Events
554 */ 557 */
555 558
559 /// Fired when an app is launched from the launcher or in response to a web
560 /// intent.
561 class Event_app_runtime_onLaunched extends Event {
562 void addListener(void callback(LaunchData launchData)) {
563 void __proxy_callback(launchData) {
564 if (?callback) {
565 callback(new LaunchData._proxy(launchData));
566 }
567 }
568 super.addListener(callback);
569 }
570
571 void removeListener(void callback(LaunchData launchData)) {
572 void __proxy_callback(launchData) {
573 if (?callback) {
574 callback(new LaunchData._proxy(launchData));
575 }
576 }
577 super.removeListener(callback);
578 }
579
580 bool hasListener(void callback(LaunchData launchData)) {
581 void __proxy_callback(launchData) {
582 if (?callback) {
583 callback(new LaunchData._proxy(launchData));
584 }
585 }
586 super.hasListener(callback);
587 }
588
589 Event_app_runtime_onLaunched(jsObject) : super._(jsObject, 1);
590 }
591
556 /// Fired at Chrome startup to apps that were running when Chrome last shut 592 /// Fired at Chrome startup to apps that were running when Chrome last shut
557 /// down. 593 /// down.
558 class Event_ChromeAppRuntimeOnRestarted extends Event { 594 class Event_app_runtime_onRestarted extends Event {
559 /* 595 void addListener(void callback()) => super.addListener(callback);
560 * Override callback type definitions
561 */
562 void addListener(void callback())
563 => super.addListener(callback);
564 void removeListener(void callback())
565 => super.removeListener(callback);
566 bool hasListener(void callback())
567 => super.hasListener(callback);
568 596
569 /* 597 void removeListener(void callback()) => super.removeListener(callback);
570 * Constructor
571 */
572 Event_ChromeAppRuntimeOnRestarted(jsObject) : super._(jsObject, 0);
573 }
574 598
575 /// Fired when an app is launched from the launcher or in response to a web 599 bool hasListener(void callback()) => super.hasListener(callback);
576 /// intent.
577 class Event_ChromeAppRuntimeOnLaunched extends Event {
578 /*
579 * Override callback type definitions
580 */
581 void addListener(void callback(LaunchData launchData))
582 => super.addListener(callback);
583 void removeListener(void callback(LaunchData launchData))
584 => super.removeListener(callback);
585 bool hasListener(void callback(LaunchData launchData))
586 => super.hasListener(callback);
587 600
588 /* 601 Event_app_runtime_onRestarted(jsObject) : super._(jsObject, 0);
589 * Constructor
590 */
591 Event_ChromeAppRuntimeOnLaunched(jsObject) : super._(jsObject, 1);
592 } 602 }
593 603
594 /** 604 /**
595 * Functions 605 * Functions
596 */ 606 */
597 class API_ChromeAppRuntime { 607
608 class API_app_runtime {
598 /* 609 /*
599 * API connection 610 * API connection
600 */ 611 */
601 Object _jsObject; 612 Object _jsObject;
602 613
603 /* 614 /*
604 * Events 615 * Events
605 */ 616 */
606 Event_ChromeAppRuntimeOnRestarted onRestarted; 617 Event_app_runtime_onLaunched onLaunched;
607 Event_ChromeAppRuntimeOnLaunched onLaunched; 618 Event_app_runtime_onRestarted onRestarted;
608 619
609 /* 620 /*
610 * Functions 621 * Functions
611 */ 622 */
612 void postIntentResponse(IntentResponse intentResponse) =>
613 JS('void', '#.postIntentResponse(#)', this._jsObject,
614 convertArgument(intentResponse));
615 623
616 /* 624 /// postIntentResponse is an internal method to responds to an intent
617 * Constructor 625 /// previously sent to a packaged app. This is identified by intentId, and
618 */ 626 /// should only be invoked at most once per intentId.
619 API_ChromeAppRuntime(this._jsObject) { 627 void postIntentResponse(IntentResponse intentResponse) => JS('void', '#.postIn tentResponse(#)', this._jsObject, convertArgument(intentResponse));
620 onRestarted = new Event_ChromeAppRuntimeOnRestarted(JS('Object', 628
621 '#.onRestarted', 629 API_app_runtime(this._jsObject) {
622 this._jsObject)); 630 onLaunched = new Event_app_runtime_onLaunched(JS('', '#.onLaunched', this._j sObject));
623 onLaunched = new Event_ChromeAppRuntimeOnLaunched(JS('Object', 631 onRestarted = new Event_app_runtime_onRestarted(JS('', '#.onRestarted', this ._jsObject));
624 '#.onLaunched',
625 this._jsObject));
626 } 632 }
627 } 633 }// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
628
629 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
630 // for details. All rights reserved. Use of this source code is governed by a 634 // for details. All rights reserved. Use of this source code is governed by a
631 // BSD-style license that can be found in the LICENSE file. 635 // BSD-style license that can be found in the LICENSE file.
632 636
633 // from app.window.idl 637 // Generated from namespace: app.window
638
634 639
635 /** 640 /**
636 * Types 641 * Types
637 */ 642 */
643
644 class Bounds extends ChromeObject {
645 /*
646 * Public constructor
647 */
648 Bounds({int left, int top, int width, int height}) {
649 if (?left)
650 this.left = left;
651 if (?top)
652 this.top = top;
653 if (?width)
654 this.width = width;
655 if (?height)
656 this.height = height;
657 }
658
659 /*
660 * Private constructor
661 */
662 Bounds._proxy(_jsObject) : super._proxy(_jsObject);
663
664 /*
665 * Public accessors
666 */
667
668 int get left => JS('int', '#.left', this._jsObject);
669
670 void set left(int left) {
671 JS('void', '#.left = #', this._jsObject, left);
672 }
673
674 int get top => JS('int', '#.top', this._jsObject);
675
676 void set top(int top) {
677 JS('void', '#.top = #', this._jsObject, top);
678 }
679
680 int get width => JS('int', '#.width', this._jsObject);
681
682 void set width(int width) {
683 JS('void', '#.width = #', this._jsObject, width);
684 }
685
686 int get height => JS('int', '#.height', this._jsObject);
687
688 void set height(int height) {
689 JS('void', '#.height = #', this._jsObject, height);
690 }
691 }
692
638 class CreateWindowOptions extends ChromeObject { 693 class CreateWindowOptions extends ChromeObject {
639 /* 694 /*
640 * Public constructor 695 * Public constructor
641 */ 696 */
642 CreateWindowOptions({String id, int defaultWidth, int defaultHeight, 697 CreateWindowOptions({String id, int defaultWidth, int defaultHeight, int defau ltLeft, int defaultTop, int width, int height, int left, int top, int minWidth, int minHeight, int maxWidth, int maxHeight, String type, String frame, Bounds bo unds, bool transparentBackground, bool hidden, bool singleton}) {
643 int defaultLeft, int defaultTop, int width, int height, int left, int top, 698 if (?id)
644 int minWidth, int minHeight, int maxWidth, int maxHeight, String type, 699 this.id = id;
645 String frame, Bounds bounds, bool hidden}) { 700 if (?defaultWidth)
646 this.id = id; 701 this.defaultWidth = defaultWidth;
647 this.defaultWidth = defaultWidth; 702 if (?defaultHeight)
648 this.defaultHeight = defaultHeight; 703 this.defaultHeight = defaultHeight;
649 this.defaultLeft = defaultLeft; 704 if (?defaultLeft)
650 this.defaultTop = defaultTop; 705 this.defaultLeft = defaultLeft;
651 this.width = width; 706 if (?defaultTop)
652 this.height = height; 707 this.defaultTop = defaultTop;
653 this.left = left; 708 if (?width)
654 this.top = top; 709 this.width = width;
655 this.minWidth = minWidth; 710 if (?height)
656 this.minHeight = minHeight; 711 this.height = height;
657 this.maxWidth = maxWidth; 712 if (?left)
658 this.maxHeight = maxHeight; 713 this.left = left;
659 this.type = type; 714 if (?top)
660 this.frame = frame; 715 this.top = top;
661 this.bounds = bounds; 716 if (?minWidth)
662 this.hidden = hidden; 717 this.minWidth = minWidth;
718 if (?minHeight)
719 this.minHeight = minHeight;
720 if (?maxWidth)
721 this.maxWidth = maxWidth;
722 if (?maxHeight)
723 this.maxHeight = maxHeight;
724 if (?type)
725 this.type = type;
726 if (?frame)
727 this.frame = frame;
728 if (?bounds)
729 this.bounds = bounds;
730 if (?transparentBackground)
731 this.transparentBackground = transparentBackground;
732 if (?hidden)
733 this.hidden = hidden;
734 if (?singleton)
735 this.singleton = singleton;
663 } 736 }
664 737
665 /* 738 /*
666 * Private constructor 739 * Private constructor
667 */ 740 */
668 CreateWindowOptions._proxy(_jsObject) : super._proxy(_jsObject); 741 CreateWindowOptions._proxy(_jsObject) : super._proxy(_jsObject);
669 742
670 /* 743 /*
671 * Public accessors 744 * Public accessors
672 */ 745 */
673 /// Id to identify the window. This will be used to remember the size 746
674 /// and position of the window and restore that geometry when a window 747 /// Id to identify the window. This will be used to remember the size and
675 /// with the same id (and no explicit size or position) is later opened. 748 /// position of the window and restore that geometry when a window with the
749 /// same id (and no explicit size or position) is later opened.
676 String get id => JS('String', '#.id', this._jsObject); 750 String get id => JS('String', '#.id', this._jsObject);
677 751
678 void set id(String id) { 752 void set id(String id) {
679 JS('void', '#.id = #', this._jsObject, id); 753 JS('void', '#.id = #', this._jsObject, id);
680 } 754 }
681 755
682 /// Default width of the window. (Deprecated; regular bounds act like this 756 /// Default width of the window. (Deprecated; regular bounds act like this
683 /// now.) 757 /// now.)
684 int get defaultWidth => JS('int', '#.defaultWidth', this._jsObject); 758 int get defaultWidth => JS('int', '#.defaultWidth', this._jsObject);
685 759
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 JS('void', '#.left = #', this._jsObject, left); 806 JS('void', '#.left = #', this._jsObject, left);
733 } 807 }
734 808
735 /// Y coordinate of the window. (Deprecated; use 'bounds'.) 809 /// Y coordinate of the window. (Deprecated; use 'bounds'.)
736 int get top => JS('int', '#.top', this._jsObject); 810 int get top => JS('int', '#.top', this._jsObject);
737 811
738 void set top(int top) { 812 void set top(int top) {
739 JS('void', '#.top = #', this._jsObject, top); 813 JS('void', '#.top = #', this._jsObject, top);
740 } 814 }
741 815
742 /// Minimium width of the window. 816 /// Minimum width of the window.
743 int get minWidth => JS('int', '#.minWidth', this._jsObject); 817 int get minWidth => JS('int', '#.minWidth', this._jsObject);
744 818
745 void set minWidth(int minWidth) { 819 void set minWidth(int minWidth) {
746 JS('void', '#.minWidth = #', this._jsObject, minWidth); 820 JS('void', '#.minWidth = #', this._jsObject, minWidth);
747 } 821 }
748 822
749 /// Minimum height of the window. 823 /// Minimum height of the window.
750 int get minHeight => JS('int', '#.minHeight', this._jsObject); 824 int get minHeight => JS('int', '#.minHeight', this._jsObject);
751 825
752 void set minHeight(int minHeight) { 826 void set minHeight(int minHeight) {
753 JS('void', '#.minHeight = #', this._jsObject, minHeight); 827 JS('void', '#.minHeight = #', this._jsObject, minHeight);
754 } 828 }
755 829
756 /// Maximum width of the window. 830 /// Maximum width of the window.
757 int get maxWidth => JS('int', '#.maxWidth', this._jsObject); 831 int get maxWidth => JS('int', '#.maxWidth', this._jsObject);
758 832
759 void set maxWidth(int maxWidth) { 833 void set maxWidth(int maxWidth) {
760 JS('void', '#.maxWidth = #', this._jsObject, maxWidth); 834 JS('void', '#.maxWidth = #', this._jsObject, maxWidth);
761 } 835 }
762 836
763 /// Maximum height of the window. 837 /// Maximum height of the window.
764 int get maxHeight => JS('int', '#.maxHeight', this._jsObject); 838 int get maxHeight => JS('int', '#.maxHeight', this._jsObject);
765 839
766 void set maxHeight(int maxHeight) { 840 void set maxHeight(int maxHeight) {
767 JS('void', '#.maxHeight = #', this._jsObject, maxHeight); 841 JS('void', '#.maxHeight = #', this._jsObject, maxHeight);
768 } 842 }
769 843
770 /// Window type: 'shell' (the default) is the only currently supported value. 844 /// Window type: 'shell' - the default window type 'panel' - a panel, manage d
845 /// by the OS (Currently experimental, Ash only)
771 String get type => JS('String', '#.type', this._jsObject); 846 String get type => JS('String', '#.type', this._jsObject);
772 847
773 void set type(String type) { 848 void set type(String type) {
774 JS('void', '#.type = #', this._jsObject, type); 849 JS('void', '#.type = #', this._jsObject, type);
775 } 850 }
776 851
777 /// Frame type: 'none' or 'chrome' (defaults to 'chrome'). 852 /// Frame type: 'none' or 'chrome' (defaults to 'chrome').
778 String get frame => JS('String', '#.frame', this._jsObject); 853 String get frame => JS('String', '#.frame', this._jsObject);
779 854
780 void set frame(String frame) { 855 void set frame(String frame) {
781 JS('void', '#.frame = #', this._jsObject, frame); 856 JS('void', '#.frame = #', this._jsObject, frame);
782 } 857 }
783 858
784 /// Size of the content in the window (excluding the titlebar). If specified 859 /// Size of the content in the window (excluding the titlebar). If specified i n
785 /// in addition to any of the left/top/width/height parameters, this field 860 /// addition to any of the left/top/width/height parameters, this field takes
786 /// takes precedence. If a frameBounds is specified, the frameBounds take 861 /// precedence. If a frameBounds is specified, the frameBounds take precedence .
787 /// precedence. 862 Bounds get bounds => new Bounds._proxy(JS('', '#.bounds', this._jsObject));
788 Bounds get bounds =>
789 new Bounds._proxy(JS('Bounds', '#.bounds', this._jsObject));
790 863
791 void set bounds(Bounds bounds) { 864 void set bounds(Bounds bounds) {
792 JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds)); 865 JS('void', '#.bounds = #', this._jsObject, convertArgument(bounds));
793 } 866 }
794 867
795 /// If true, the window will be created in a hidden state. Call show() on 868 /// Enable window background transparency. Only supported in ash. Requires
796 /// the window to show it once it has been created. Defaults to false. 869 /// experimental API permission.
870 bool get transparentBackground => JS('bool', '#.transparentBackground', this._ jsObject);
871
872 void set transparentBackground(bool transparentBackground) {
873 JS('void', '#.transparentBackground = #', this._jsObject, transparentBackgro und);
874 }
875
876 /// If true, the window will be created in a hidden state. Call show() on the
877 /// window to show it once it has been created. Defaults to false.
797 bool get hidden => JS('bool', '#.hidden', this._jsObject); 878 bool get hidden => JS('bool', '#.hidden', this._jsObject);
798 879
799 void set hidden(bool hidden) { 880 void set hidden(bool hidden) {
800 JS('void', '#.hidden = #', this._jsObject, hidden); 881 JS('void', '#.hidden = #', this._jsObject, hidden);
801 } 882 }
802 } 883
803 884 /// By default if you specify an id for the window, the window will only be
804 class Bounds extends ChromeObject { 885 /// created if another window with the same id doesn't already exist. If a
805 /* 886 /// window with the same id already exists that window is activated instead. I f
806 * Public constructor 887 /// you do want to create multiple windows with the same id, you can set this
807 */ 888 /// property to false.
808 Bounds({int left, int top, int width, int height}) { 889 bool get singleton => JS('bool', '#.singleton', this._jsObject);
809 this.left = left; 890
810 this.top = top; 891 void set singleton(bool singleton) {
811 this.width = width; 892 JS('void', '#.singleton = #', this._jsObject, singleton);
812 this.height = height; 893 }
813 } 894 }
814 895
896 class AppWindow extends ChromeObject {
815 /* 897 /*
816 * Private constructor 898 * Private constructor
817 */ 899 */
818 Bounds._proxy(_jsObject) : super._proxy(_jsObject); 900 AppWindow._proxy(_jsObject) : super._proxy(_jsObject);
819 901
820 /* 902 /*
821 * Public accessors 903 * Public accessors
822 */ 904 */
823 int get left => JS('int', '#.left', this._jsObject); 905
824
825 void set left(int left) {
826 JS('void', '#.left = #', this._jsObject, left);
827 }
828
829 int get top => JS('int', '#.top', this._jsObject);
830
831 void set top(int top) {
832 JS('void', '#.top = #', this._jsObject, top);
833 }
834
835 int get width => JS('int', '#.width', this._jsObject);
836
837 void set width(int width) {
838 JS('void', '#.width = #', this._jsObject, width);
839 }
840
841 int get height => JS('int', '#.height', this._jsObject);
842
843 void set height(int height) {
844 JS('void', '#.height = #', this._jsObject, height);
845 }
846 }
847
848 class AppWindow extends ChromeObject {
849 /*
850 * Public constructor
851 * TODO(sashab): Does it make sense to be able to create a new AppWindow this
852 * way?
853 */
854 //AppWindow();
855
856 /*
857 * Private constructor
858 */
859 AppWindow._proxy(jsObject) : super._proxy(jsObject);
860
861 /*
862 * Public accessors
863 */
864 /// The JavaScript 'window' object for the created child. 906 /// The JavaScript 'window' object for the created child.
865 // TODO(sashab, sra): Detect whether this is the current window, or an 907 // TODO(sashab, sra): Detect whether this is the current window, or an
866 // external one, and return an appropriately-typed object 908 // external one, and return an appropriately-typed object
867 WindowBase get contentWindow => 909 WindowBase get contentWindow =>
868 JS("Window", "#.contentWindow", this._jsObject); 910 JS("Window", "#.contentWindow", this._jsObject);
869 911
870 /* 912 /*
871 * Functions 913 * Methods
872 */ 914 */
873
874 /// Focus the window. 915 /// Focus the window.
875 void focus() => JS("void", "#.focus()", this._jsObject); 916 void focus() => JS('void', '#.focus()', this._jsObject);
876
877 /// Minimize the window. 917 /// Minimize the window.
878 void minimize() => JS("void", "#.minimize()", this._jsObject); 918 void minimize() => JS('void', '#.minimize()', this._jsObject);
879
880 /// Is the window minimized? 919 /// Is the window minimized?
881 bool isMinimized() => JS("bool", "#.isMinimized()", this._jsObject); 920 void isMinimized() => JS('void', '#.isMinimized()', this._jsObject);
882
883 /// Maximize the window. 921 /// Maximize the window.
884 void maximize() => JS("void", "#.maximize()", this._jsObject); 922 void maximize() => JS('void', '#.maximize()', this._jsObject);
885
886 /// Is the window maximized? 923 /// Is the window maximized?
887 bool isMaximized() => JS("bool", "c#.isMaximized()", this._jsObject); 924 void isMaximized() => JS('void', '#.isMaximized()', this._jsObject);
888
889 /// Restore the window. 925 /// Restore the window.
890 void restore() => JS("void", "#.restore()", this._jsObject); 926 void restore() => JS('void', '#.restore()', this._jsObject);
891
892 /// Move the window to the position (|left|, |top|). 927 /// Move the window to the position (|left|, |top|).
893 void moveTo(int left, int top) => 928 void moveTo(int left, int top) => JS('void', '#.moveTo(#, #)', this._jsObject, left, top);
894 JS("void", "#.moveTo(#, #)", this._jsObject, left, top);
895
896 /// Resize the window to |width|x|height| pixels in size. 929 /// Resize the window to |width|x|height| pixels in size.
897 void resizeTo(int width, int height) => 930 void resizeTo(int width, int height) => JS('void', '#.resizeTo(#, #)', this._j sObject, width, height);
898 JS("void", "#.resizeTo(#, #)", this._jsObject, width, height);
899
900 /// Draw attention to the window. 931 /// Draw attention to the window.
901 void drawAttention() => JS("void", "#.drawAttention()", this._jsObject); 932 void drawAttention() => JS('void', '#.drawAttention()', this._jsObject);
902
903 /// Clear attention to the window. 933 /// Clear attention to the window.
904 void clearAttention() => JS("void", "#.clearAttention()", this._jsObject); 934 void clearAttention() => JS('void', '#.clearAttention()', this._jsObject);
905
906 /// Close the window. 935 /// Close the window.
907 void close() => JS("void", "#.close()", this._jsObject); 936 void close() => JS('void', '#.close()', this._jsObject);
908
909 /// Show the window. Does nothing if the window is already visible. 937 /// Show the window. Does nothing if the window is already visible.
910 void show() => JS("void", "#.show()", this._jsObject); 938 void show() => JS('void', '#.show()', this._jsObject);
911
912 /// Hide the window. Does nothing if the window is already hidden. 939 /// Hide the window. Does nothing if the window is already hidden.
913 void hide() => JS("void", "#.hide()", this._jsObject); 940 void hide() => JS('void', '#.hide()', this._jsObject);
914 941 /// Get the window's bounds as a $ref:Bounds object.
942 void getBounds() => JS('void', '#.getBounds()', this._jsObject);
915 /// Set the window's bounds. 943 /// Set the window's bounds.
916 void setBounds(Bounds bounds) => 944 void setBounds(Bounds bounds) => JS('void', '#.setBounds(#)', this._jsObject, convertArgument(bounds));
917 JS("void", "#.setBounds(#)", this._jsObject, convertArgument(bounds)); 945 /// Set the app icon for the window (experimental). Currently this is only
918 946 /// being implemented on Ash. TODO(stevenjb): Investigate implementing this on
947 /// Windows and OSX.
948 void setIcon(String icon_url) => JS('void', '#.setIcon(#)', this._jsObject, ic on_url);
949 }
950
951 /**
952 * Events
953 */
954
955 /// Fired when the window is resized.
956 class Event_app_window_onBoundsChanged extends Event {
957 void addListener(void callback()) => super.addListener(callback);
958
959 void removeListener(void callback()) => super.removeListener(callback);
960
961 bool hasListener(void callback()) => super.hasListener(callback);
962
963 Event_app_window_onBoundsChanged(jsObject) : super._(jsObject, 0);
964 }
965
966 /// Fired when the window is closed.
967 class Event_app_window_onClosed extends Event {
968 void addListener(void callback()) => super.addListener(callback);
969
970 void removeListener(void callback()) => super.removeListener(callback);
971
972 bool hasListener(void callback()) => super.hasListener(callback);
973
974 Event_app_window_onClosed(jsObject) : super._(jsObject, 0);
975 }
976
977 /// Fired when the window is maximized.
978 class Event_app_window_onMaximized extends Event {
979 void addListener(void callback()) => super.addListener(callback);
980
981 void removeListener(void callback()) => super.removeListener(callback);
982
983 bool hasListener(void callback()) => super.hasListener(callback);
984
985 Event_app_window_onMaximized(jsObject) : super._(jsObject, 0);
986 }
987
988 /// Fired when the window is minimized.
989 class Event_app_window_onMinimized extends Event {
990 void addListener(void callback()) => super.addListener(callback);
991
992 void removeListener(void callback()) => super.removeListener(callback);
993
994 bool hasListener(void callback()) => super.hasListener(callback);
995
996 Event_app_window_onMinimized(jsObject) : super._(jsObject, 0);
997 }
998
999 /// Fired when the window is restored from being minimized or maximized.
1000 class Event_app_window_onRestored extends Event {
1001 void addListener(void callback()) => super.addListener(callback);
1002
1003 void removeListener(void callback()) => super.removeListener(callback);
1004
1005 bool hasListener(void callback()) => super.hasListener(callback);
1006
1007 Event_app_window_onRestored(jsObject) : super._(jsObject, 0);
919 } 1008 }
920 1009
921 /** 1010 /**
922 * Functions 1011 * Functions
923 */ 1012 */
924 class API_ChromeAppWindow { 1013
925 /** 1014 class API_app_window {
926 * JS object 1015 /*
1016 * API connection
927 */ 1017 */
928 Object _jsObject; 1018 Object _jsObject;
929 1019
930 /** 1020 /*
931 * Constructor 1021 * Events
932 */ 1022 */
933 API_ChromeAppWindow(this._jsObject); 1023 Event_app_window_onBoundsChanged onBoundsChanged;
934 1024 Event_app_window_onClosed onClosed;
935 /** 1025 Event_app_window_onMaximized onMaximized;
1026 Event_app_window_onMinimized onMinimized;
1027 Event_app_window_onRestored onRestored;
1028
1029 /*
936 * Functions 1030 * Functions
937 */ 1031 */
938 1032
939 /// Returns an <a href="#type-AppWindow">AppWindow</a> object for the 1033 /// The size and position of a window can be specified in a number of differen t
940 /// current script context (ie JavaScript 'window' object). This can also be 1034 /// ways. The most simple option is not specifying anything at all, in which
941 /// called on a handle to a script context for another page, for example: 1035 /// case a default size and platform dependent position will be used.<br/><br/ >
1036 /// Another option is to use the top/left and width/height properties, which
1037 /// will always put the window at the specified coordinates with the specified
1038 /// size.<br/><br/> Yet another option is to give the window a (unique) id.
1039 /// This id is then used to remember the size and position of the window
1040 /// whenever it is moved or resized. This size and position is then used
1041 /// instead of the specified bounds on subsequent opening of a window with the
1042 /// same id. If you need to open a window with an id at a location other than
1043 /// the remembered default, you can create it hidden, move it to the desired
1044 /// location, then show it.<br/><br/> You can also combine these various
1045 /// options, explicitly specifying for example the size while having the
1046 /// position be remembered or other combinations like that. Size and position
1047 /// are dealt with seperately, but individual coordinates are not. So if you
1048 /// specify a top (or left) coordinate, you should also specify a left (or top )
1049 /// coordinate, and similar for size.<br/><br/> If you specify both a regular
1050 /// and a default value for the same option the regular value is the only one
1051 /// that takes effect.
1052 void create(String url, [CreateWindowOptions options, void callback(AppWindow created_window)]) {
1053 void __proxy_callback(created_window) {
1054 if (?callback) {
1055 callback(new AppWindow._proxy(created_window));
1056 }
1057 }
1058 JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options ), convertDartClosureToJS(__proxy_callback, 1));
1059 }
1060
1061 /// Returns an $ref:AppWindow object for the current script context (ie
1062 /// JavaScript 'window' object). This can also be called on a handle to a
1063 /// script context for another page, for example:
942 /// otherWindow.chrome.app.window.current(). 1064 /// otherWindow.chrome.app.window.current().
943 AppWindow current() => 1065 void current() => JS('void', '#.current()', this._jsObject);
944 new AppWindow._proxy(JS("Object", "#.current()", this._jsObject)); 1066
945 1067 void initializeAppWindow(Object state) => JS('void', '#.initializeAppWindow(#) ', this._jsObject, convertArgument(state));
946 /// The size and position of a window can be specified in a number of 1068
947 /// different ways. The most simple option is not specifying anything at 1069 API_app_window(this._jsObject) {
948 /// all, in which case a default size and platform dependent position will 1070 onBoundsChanged = new Event_app_window_onBoundsChanged(JS('', '#.onBoundsCha nged', this._jsObject));
949 /// be used. 1071 onClosed = new Event_app_window_onClosed(JS('', '#.onClosed', this._jsObject ));
950 /// 1072 onMaximized = new Event_app_window_onMaximized(JS('', '#.onMaximized', this. _jsObject));
951 /// Another option is to use the top/left and width/height properties, 1073 onMinimized = new Event_app_window_onMinimized(JS('', '#.onMinimized', this. _jsObject));
952 /// which will always put the window at the specified coordinates with the 1074 onRestored = new Event_app_window_onRestored(JS('', '#.onRestored', this._js Object));
953 /// specified size.
954 ///
955 /// Yet another option is to give the window a (unique) id. This id is then
956 /// used to remember the size and position of the window whenever it is
957 /// moved or resized. This size and position is then used instead of the
958 /// specified bounds on subsequent opening of a window with the same id. If
959 /// you need to open a window with an id at a location other than the
960 /// remembered default, you can create it hidden, move it to the desired
961 /// location, then show it.
962 ///
963 /// You can also combine these various options, explicitly specifying for
964 /// example the size while having the position be remembered or other
965 /// combinations like that. Size and position are dealt with seperately,
966 /// but individual coordinates are not. So if you specify a top (or left)
967 /// coordinate, you should also specify a left (or top) coordinate, and
968 /// similar for size.
969 ///
970 /// If you specify both a regular and a default value for the same option
971 /// the regular value is the only one that takes effect.
972 void create(String url, [CreateWindowOptions options,
973 void callback(AppWindow created_window)]) {
974 void __proxy_callback(Object created_window) {
975 if (?callback)
976 callback(new AppWindow._proxy(created_window));
977 }
978
979 JS("void", "#.create(#, #, #)",
980 this._jsObject,
981 url,
982 convertArgument(options),
983 convertDartClosureToJS(__proxy_callback, 1)
984 );
985 } 1075 }
986 } 1076 }
OLDNEW
« no previous file with comments | « no previous file | tools/dom/scripts/chromegenerator.py » ('j') | tools/dom/scripts/chromegenerator.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698