| OLD | NEW |
| 1 /// Native wrappers for the Chrome Packaged App APIs. | 1 /// Native wrappers for the Chrome Packaged App APIs. |
| 2 /// | 2 /// |
| 3 /// These functions allow direct access to the Packaged App APIs, allowing | 3 /// These functions allow direct access to the Packaged App APIs, allowing |
| 4 /// Chrome Packaged Apps to be written using Dart. | 4 /// Chrome Packaged Apps to be written using Dart. |
| 5 /// | 5 /// |
| 6 /// For more information on these APIs, see the | 6 /// For more information on these APIs, see the |
| 7 /// [Chrome APIs Documentation](http://developer.chrome.com/extensions/api_index
.html) | 7 /// [Chrome APIs Documentation](http://developer.chrome.com/extensions/api_index
.html) |
| 8 library chrome; | 8 library chrome; |
| 9 | 9 |
| 10 import 'dart:_foreign_helper' show JS; | 10 import 'dart:_foreign_helper' show JS; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 /// Registers rules to handle events. | 246 /// Registers rules to handle events. |
| 247 /// | 247 /// |
| 248 /// [eventName] is the name of the event this function affects and [rules] are | 248 /// [eventName] is the name of the event this function affects and [rules] are |
| 249 /// the rules to be registered. These do not replace previously registered | 249 /// the rules to be registered. These do not replace previously registered |
| 250 /// rules. [callback] is called with registered rules. | 250 /// rules. [callback] is called with registered rules. |
| 251 /// | 251 /// |
| 252 void addRules(String eventName, List<Rule> rules, | 252 void addRules(String eventName, List<Rule> rules, |
| 253 [void callback(List<Rule> rules)]) { | 253 [void callback(List<Rule> rules)]) { |
| 254 // proxy the callback | 254 // proxy the callback |
| 255 void __proxy_callback(List rules) { | 255 void __proxy_callback(List rules) { |
| 256 if (?callback) { | 256 if (callback != null) { |
| 257 List<Rule> __proxy_rules = new List<Rule>(); | 257 List<Rule> __proxy_rules = new List<Rule>(); |
| 258 | 258 |
| 259 for (Object o in rules) | 259 for (Object o in rules) |
| 260 __proxy_rules.add(new Rule._proxy(o)); | 260 __proxy_rules.add(new Rule._proxy(o)); |
| 261 | 261 |
| 262 callback(__proxy_rules); | 262 callback(__proxy_rules); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 | 265 |
| 266 JS('void', | 266 JS('void', |
| 267 '#.addRules(#, #, #)', | 267 '#.addRules(#, #, #)', |
| 268 this._jsObject, | 268 this._jsObject, |
| 269 convertArgument(eventName), | 269 convertArgument(eventName), |
| 270 convertArgument(rules), | 270 convertArgument(rules), |
| 271 convertDartClosureToJS(__proxy_callback, 1) | 271 convertDartClosureToJS(__proxy_callback, 1) |
| 272 ); | 272 ); |
| 273 } | 273 } |
| 274 | 274 |
| 275 /// Returns currently registered rules. | 275 /// Returns currently registered rules. |
| 276 /// | 276 /// |
| 277 /// [eventName] is the name of the event this function affects and, if an arra
y | 277 /// [eventName] is the name of the event this function affects and, if an arra
y |
| 278 /// is passed as [ruleIdentifiers], only rules with identifiers contained in | 278 /// is passed as [ruleIdentifiers], only rules with identifiers contained in |
| 279 /// this array are returned. [callback] is called with registered rules. | 279 /// this array are returned. [callback] is called with registered rules. |
| 280 /// | 280 /// |
| 281 void getRules(String eventName, [List<String> ruleIdentifiers, | 281 void getRules(String eventName, [List<String> ruleIdentifiers, |
| 282 void callback(List<Rule> rules)]) { | 282 void callback(List<Rule> rules)]) { |
| 283 // proxy the callback | 283 // proxy the callback |
| 284 void __proxy_callback(List rules) { | 284 void __proxy_callback(List rules) { |
| 285 if (?callback) { | 285 if (callback != null) { |
| 286 List<Rule> __proxy_rules = new List<Rule>(); | 286 List<Rule> __proxy_rules = new List<Rule>(); |
| 287 | 287 |
| 288 for (Object o in rules) | 288 for (Object o in rules) |
| 289 __proxy_rules.add(new Rule._proxy(o)); | 289 __proxy_rules.add(new Rule._proxy(o)); |
| 290 | 290 |
| 291 callback(__proxy_rules); | 291 callback(__proxy_rules); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 JS('void', | 295 JS('void', |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 391 |
| 392 /** | 392 /** |
| 393 * Types | 393 * Types |
| 394 */ | 394 */ |
| 395 | 395 |
| 396 class AppWindowCreateWindowOptions extends ChromeObject { | 396 class AppWindowCreateWindowOptions extends ChromeObject { |
| 397 /* | 397 /* |
| 398 * Public constructor | 398 * Public constructor |
| 399 */ | 399 */ |
| 400 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, bool hidden, bool singleton}
) { | 400 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, bool hidden, bool singleton}
) { |
| 401 if (?id) | 401 if (id != null) |
| 402 this.id = id; | 402 this.id = id; |
| 403 if (?defaultWidth) | 403 if (defaultWidth != null) |
| 404 this.defaultWidth = defaultWidth; | 404 this.defaultWidth = defaultWidth; |
| 405 if (?defaultHeight) | 405 if (defaultHeight != null) |
| 406 this.defaultHeight = defaultHeight; | 406 this.defaultHeight = defaultHeight; |
| 407 if (?defaultLeft) | 407 if (defaultLeft != null) |
| 408 this.defaultLeft = defaultLeft; | 408 this.defaultLeft = defaultLeft; |
| 409 if (?defaultTop) | 409 if (defaultTop != null) |
| 410 this.defaultTop = defaultTop; | 410 this.defaultTop = defaultTop; |
| 411 if (?width) | 411 if (width != null) |
| 412 this.width = width; | 412 this.width = width; |
| 413 if (?height) | 413 if (height != null) |
| 414 this.height = height; | 414 this.height = height; |
| 415 if (?left) | 415 if (left != null) |
| 416 this.left = left; | 416 this.left = left; |
| 417 if (?top) | 417 if (top != null) |
| 418 this.top = top; | 418 this.top = top; |
| 419 if (?minWidth) | 419 if (minWidth != null) |
| 420 this.minWidth = minWidth; | 420 this.minWidth = minWidth; |
| 421 if (?minHeight) | 421 if (minHeight != null) |
| 422 this.minHeight = minHeight; | 422 this.minHeight = minHeight; |
| 423 if (?maxWidth) | 423 if (maxWidth != null) |
| 424 this.maxWidth = maxWidth; | 424 this.maxWidth = maxWidth; |
| 425 if (?maxHeight) | 425 if (maxHeight != null) |
| 426 this.maxHeight = maxHeight; | 426 this.maxHeight = maxHeight; |
| 427 if (?type) | 427 if (type != null) |
| 428 this.type = type; | 428 this.type = type; |
| 429 if (?frame) | 429 if (frame != null) |
| 430 this.frame = frame; | 430 this.frame = frame; |
| 431 if (?bounds) | 431 if (bounds != null) |
| 432 this.bounds = bounds; | 432 this.bounds = bounds; |
| 433 if (?transparentBackground) | 433 if (transparentBackground != null) |
| 434 this.transparentBackground = transparentBackground; | 434 this.transparentBackground = transparentBackground; |
| 435 if (?hidden) | 435 if (hidden != null) |
| 436 this.hidden = hidden; | 436 this.hidden = hidden; |
| 437 if (?singleton) | 437 if (singleton != null) |
| 438 this.singleton = singleton; | 438 this.singleton = singleton; |
| 439 } | 439 } |
| 440 | 440 |
| 441 /* | 441 /* |
| 442 * Private constructor | 442 * Private constructor |
| 443 */ | 443 */ |
| 444 AppWindowCreateWindowOptions._proxy(_jsObject) : super._proxy(_jsObject); | 444 AppWindowCreateWindowOptions._proxy(_jsObject) : super._proxy(_jsObject); |
| 445 | 445 |
| 446 /* | 446 /* |
| 447 * Public accessors | 447 * Public accessors |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 JS('void', '#.singleton = #', this._jsObject, singleton); | 594 JS('void', '#.singleton = #', this._jsObject, singleton); |
| 595 } | 595 } |
| 596 | 596 |
| 597 } | 597 } |
| 598 | 598 |
| 599 class AppWindowBounds extends ChromeObject { | 599 class AppWindowBounds extends ChromeObject { |
| 600 /* | 600 /* |
| 601 * Public constructor | 601 * Public constructor |
| 602 */ | 602 */ |
| 603 AppWindowBounds({int left, int top, int width, int height}) { | 603 AppWindowBounds({int left, int top, int width, int height}) { |
| 604 if (?left) | 604 if (left != null) |
| 605 this.left = left; | 605 this.left = left; |
| 606 if (?top) | 606 if (top != null) |
| 607 this.top = top; | 607 this.top = top; |
| 608 if (?width) | 608 if (width != null) |
| 609 this.width = width; | 609 this.width = width; |
| 610 if (?height) | 610 if (height != null) |
| 611 this.height = height; | 611 this.height = height; |
| 612 } | 612 } |
| 613 | 613 |
| 614 /* | 614 /* |
| 615 * Private constructor | 615 * Private constructor |
| 616 */ | 616 */ |
| 617 AppWindowBounds._proxy(_jsObject) : super._proxy(_jsObject); | 617 AppWindowBounds._proxy(_jsObject) : super._proxy(_jsObject); |
| 618 | 618 |
| 619 /* | 619 /* |
| 620 * Public accessors | 620 * Public accessors |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 /// that takes effect. | 828 /// that takes effect. |
| 829 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 829 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 830 // for details. All rights reserved. Use of this source code is governed by a | 830 // for details. All rights reserved. Use of this source code is governed by a |
| 831 // BSD-style license that can be found in the LICENSE file. | 831 // BSD-style license that can be found in the LICENSE file. |
| 832 | 832 |
| 833 // TODO(sashab): This override is no longer needed once prefixes are removed. | 833 // TODO(sashab): This override is no longer needed once prefixes are removed. |
| 834 void create(String url, | 834 void create(String url, |
| 835 [AppWindowCreateWindowOptions options, | 835 [AppWindowCreateWindowOptions options, |
| 836 void callback(AppWindowAppWindow created_window)]) { | 836 void callback(AppWindowAppWindow created_window)]) { |
| 837 void __proxy_callback(created_window) { | 837 void __proxy_callback(created_window) { |
| 838 if (?callback) | 838 if (callback != null) |
| 839 callback(new AppWindowAppWindow._proxy(created_window)); | 839 callback(new AppWindowAppWindow._proxy(created_window)); |
| 840 } | 840 } |
| 841 JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options
), | 841 JS('void', '#.create(#, #, #)', this._jsObject, url, convertArgument(options
), |
| 842 convertDartClosureToJS(__proxy_callback, 1)); | 842 convertDartClosureToJS(__proxy_callback, 1)); |
| 843 } | 843 } |
| 844 | 844 |
| 845 /// Returns an $ref:AppWindow object for the current script context (ie | 845 /// Returns an $ref:AppWindow object for the current script context (ie |
| 846 /// JavaScript 'window' object). This can also be called on a handle to a | 846 /// JavaScript 'window' object). This can also be called on a handle to a |
| 847 /// script context for another page, for example: | 847 /// script context for another page, for example: |
| 848 /// otherWindow.chrome.app.window.current(). | 848 /// otherWindow.chrome.app.window.current(). |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 /// Callback to be compatible with WebIntents. | 916 /// Callback to be compatible with WebIntents. |
| 917 void postFailure() => JS('void', '#.postFailure()', this._jsObject); | 917 void postFailure() => JS('void', '#.postFailure()', this._jsObject); |
| 918 | 918 |
| 919 } | 919 } |
| 920 | 920 |
| 921 class AppRuntimeLaunchItem extends ChromeObject { | 921 class AppRuntimeLaunchItem extends ChromeObject { |
| 922 /* | 922 /* |
| 923 * Public constructor | 923 * Public constructor |
| 924 */ | 924 */ |
| 925 AppRuntimeLaunchItem({FileEntry entry, String type}) { | 925 AppRuntimeLaunchItem({FileEntry entry, String type}) { |
| 926 if (?entry) | 926 if (entry != null) |
| 927 this.entry = entry; | 927 this.entry = entry; |
| 928 if (?type) | 928 if (type != null) |
| 929 this.type = type; | 929 this.type = type; |
| 930 } | 930 } |
| 931 | 931 |
| 932 /* | 932 /* |
| 933 * Private constructor | 933 * Private constructor |
| 934 */ | 934 */ |
| 935 AppRuntimeLaunchItem._proxy(_jsObject) : super._proxy(_jsObject); | 935 AppRuntimeLaunchItem._proxy(_jsObject) : super._proxy(_jsObject); |
| 936 | 936 |
| 937 /* | 937 /* |
| 938 * Public accessors | 938 * Public accessors |
| (...skipping 12 matching lines...) Expand all Loading... |
| 951 JS('void', '#.type = #', this._jsObject, type); | 951 JS('void', '#.type = #', this._jsObject, type); |
| 952 } | 952 } |
| 953 | 953 |
| 954 } | 954 } |
| 955 | 955 |
| 956 class AppRuntimeLaunchData extends ChromeObject { | 956 class AppRuntimeLaunchData extends ChromeObject { |
| 957 /* | 957 /* |
| 958 * Public constructor | 958 * Public constructor |
| 959 */ | 959 */ |
| 960 AppRuntimeLaunchData({AppRuntimeIntent intent, String id, List<AppRuntimeLaunc
hItem> items}) { | 960 AppRuntimeLaunchData({AppRuntimeIntent intent, String id, List<AppRuntimeLaunc
hItem> items}) { |
| 961 if (?intent) | 961 if (intent != null) |
| 962 this.intent = intent; | 962 this.intent = intent; |
| 963 if (?id) | 963 if (id != null) |
| 964 this.id = id; | 964 this.id = id; |
| 965 if (?items) | 965 if (items != null) |
| 966 this.items = items; | 966 this.items = items; |
| 967 } | 967 } |
| 968 | 968 |
| 969 /* | 969 /* |
| 970 * Private constructor | 970 * Private constructor |
| 971 */ | 971 */ |
| 972 AppRuntimeLaunchData._proxy(_jsObject) : super._proxy(_jsObject); | 972 AppRuntimeLaunchData._proxy(_jsObject) : super._proxy(_jsObject); |
| 973 | 973 |
| 974 /* | 974 /* |
| 975 * Public accessors | 975 * Public accessors |
| (...skipping 23 matching lines...) Expand all Loading... |
| 999 JS('void', '#.items = #', this._jsObject, convertArgument(items)); | 999 JS('void', '#.items = #', this._jsObject, convertArgument(items)); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 class AppRuntimeIntentResponse extends ChromeObject { | 1004 class AppRuntimeIntentResponse extends ChromeObject { |
| 1005 /* | 1005 /* |
| 1006 * Public constructor | 1006 * Public constructor |
| 1007 */ | 1007 */ |
| 1008 AppRuntimeIntentResponse({int intentId, bool success, Object data}) { | 1008 AppRuntimeIntentResponse({int intentId, bool success, Object data}) { |
| 1009 if (?intentId) | 1009 if (intentId != null) |
| 1010 this.intentId = intentId; | 1010 this.intentId = intentId; |
| 1011 if (?success) | 1011 if (success != null) |
| 1012 this.success = success; | 1012 this.success = success; |
| 1013 if (?data) | 1013 if (data != null) |
| 1014 this.data = data; | 1014 this.data = data; |
| 1015 } | 1015 } |
| 1016 | 1016 |
| 1017 /* | 1017 /* |
| 1018 * Private constructor | 1018 * Private constructor |
| 1019 */ | 1019 */ |
| 1020 AppRuntimeIntentResponse._proxy(_jsObject) : super._proxy(_jsObject); | 1020 AppRuntimeIntentResponse._proxy(_jsObject) : super._proxy(_jsObject); |
| 1021 | 1021 |
| 1022 /* | 1022 /* |
| 1023 * Public accessors | 1023 * Public accessors |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1047 | 1047 |
| 1048 /** | 1048 /** |
| 1049 * Events | 1049 * Events |
| 1050 */ | 1050 */ |
| 1051 | 1051 |
| 1052 /// Fired when an app is launched from the launcher or in response to a web | 1052 /// Fired when an app is launched from the launcher or in response to a web |
| 1053 /// intent. | 1053 /// intent. |
| 1054 class Event_app_runtime_onLaunched extends Event { | 1054 class Event_app_runtime_onLaunched extends Event { |
| 1055 void addListener(void callback(AppRuntimeLaunchData launchData)) { | 1055 void addListener(void callback(AppRuntimeLaunchData launchData)) { |
| 1056 void __proxy_callback(launchData) { | 1056 void __proxy_callback(launchData) { |
| 1057 if (?callback) { | 1057 if (callback != null) { |
| 1058 callback(new AppRuntimeLaunchData._proxy(launchData)); | 1058 callback(new AppRuntimeLaunchData._proxy(launchData)); |
| 1059 } | 1059 } |
| 1060 } | 1060 } |
| 1061 super.addListener(callback); | 1061 super.addListener(callback); |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 void removeListener(void callback(AppRuntimeLaunchData launchData)) { | 1064 void removeListener(void callback(AppRuntimeLaunchData launchData)) { |
| 1065 void __proxy_callback(launchData) { | 1065 void __proxy_callback(launchData) { |
| 1066 if (?callback) { | 1066 if (callback != null) { |
| 1067 callback(new AppRuntimeLaunchData._proxy(launchData)); | 1067 callback(new AppRuntimeLaunchData._proxy(launchData)); |
| 1068 } | 1068 } |
| 1069 } | 1069 } |
| 1070 super.removeListener(callback); | 1070 super.removeListener(callback); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 bool hasListener(void callback(AppRuntimeLaunchData launchData)) { | 1073 bool hasListener(void callback(AppRuntimeLaunchData launchData)) { |
| 1074 void __proxy_callback(launchData) { | 1074 void __proxy_callback(launchData) { |
| 1075 if (?callback) { | 1075 if (callback != null) { |
| 1076 callback(new AppRuntimeLaunchData._proxy(launchData)); | 1076 callback(new AppRuntimeLaunchData._proxy(launchData)); |
| 1077 } | 1077 } |
| 1078 } | 1078 } |
| 1079 super.hasListener(callback); | 1079 super.hasListener(callback); |
| 1080 } | 1080 } |
| 1081 | 1081 |
| 1082 Event_app_runtime_onLaunched(jsObject) : super._(jsObject, 1); | 1082 Event_app_runtime_onLaunched(jsObject) : super._(jsObject, 1); |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 /// Fired at Chrome startup to apps that were running when Chrome last shut | 1085 /// Fired at Chrome startup to apps that were running when Chrome last shut |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1116 /// postIntentResponse is an internal method to responds to an intent | 1116 /// postIntentResponse is an internal method to responds to an intent |
| 1117 /// previously sent to a packaged app. This is identified by intentId, and | 1117 /// previously sent to a packaged app. This is identified by intentId, and |
| 1118 /// should only be invoked at most once per intentId. | 1118 /// should only be invoked at most once per intentId. |
| 1119 void postIntentResponse(AppRuntimeIntentResponse intentResponse) => JS('void',
'#.postIntentResponse(#)', this._jsObject, convertArgument(intentResponse)); | 1119 void postIntentResponse(AppRuntimeIntentResponse intentResponse) => JS('void',
'#.postIntentResponse(#)', this._jsObject, convertArgument(intentResponse)); |
| 1120 | 1120 |
| 1121 API_app_runtime(this._jsObject) { | 1121 API_app_runtime(this._jsObject) { |
| 1122 onLaunched = new Event_app_runtime_onLaunched(JS('', '#.onLaunched', this._j
sObject)); | 1122 onLaunched = new Event_app_runtime_onLaunched(JS('', '#.onLaunched', this._j
sObject)); |
| 1123 onRestarted = new Event_app_runtime_onRestarted(JS('', '#.onRestarted', this
._jsObject)); | 1123 onRestarted = new Event_app_runtime_onRestarted(JS('', '#.onRestarted', this
._jsObject)); |
| 1124 } | 1124 } |
| 1125 } | 1125 } |
| OLD | NEW |