| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Generated from namespace: alarms |
| 6 |
| 7 part of chrome; |
| 8 |
| 9 /** |
| 10 * Types |
| 11 */ |
| 12 |
| 13 class AlarmsAlarm extends ChromeObject { |
| 14 /* |
| 15 * Public constructor |
| 16 */ |
| 17 AlarmsAlarm({String name, double scheduledTime, double periodInMinutes}) { |
| 18 if (?name) |
| 19 this.name = name; |
| 20 if (?scheduledTime) |
| 21 this.scheduledTime = scheduledTime; |
| 22 if (?periodInMinutes) |
| 23 this.periodInMinutes = periodInMinutes; |
| 24 } |
| 25 |
| 26 /* |
| 27 * Private constructor |
| 28 */ |
| 29 AlarmsAlarm._proxy(_jsObject) : super._proxy(_jsObject); |
| 30 |
| 31 /* |
| 32 * Public accessors |
| 33 */ |
| 34 /// Name of this alarm. |
| 35 String get name => JS('String', '#.name', this._jsObject); |
| 36 |
| 37 void set name(String name) { |
| 38 JS('void', '#.name = #', this._jsObject, name); |
| 39 } |
| 40 |
| 41 /// Time at which this alarm was scheduled to fire, in milliseconds past the |
| 42 /// epoch (e.g. <code>Date.now() + n</code>). For performance reasons, the |
| 43 /// alarm may have been delayed an arbitrary amount beyond this. |
| 44 double get scheduledTime => JS('double', '#.scheduledTime', this._jsObject); |
| 45 |
| 46 void set scheduledTime(double scheduledTime) { |
| 47 JS('void', '#.scheduledTime = #', this._jsObject, scheduledTime); |
| 48 } |
| 49 |
| 50 /// If not null, the alarm is a repeating alarm and will fire again in |
| 51 /// <var>periodInMinutes</var> minutes. |
| 52 double get periodInMinutes => JS('double', '#.periodInMinutes', this._jsObject
); |
| 53 |
| 54 void set periodInMinutes(double periodInMinutes) { |
| 55 JS('void', '#.periodInMinutes = #', this._jsObject, periodInMinutes); |
| 56 } |
| 57 |
| 58 } |
| 59 |
| 60 class AlarmsAlarmCreateInfo extends ChromeObject { |
| 61 /* |
| 62 * Public constructor |
| 63 */ |
| 64 AlarmsAlarmCreateInfo({double when, double delayInMinutes, double periodInMinu
tes}) { |
| 65 if (?when) |
| 66 this.when = when; |
| 67 if (?delayInMinutes) |
| 68 this.delayInMinutes = delayInMinutes; |
| 69 if (?periodInMinutes) |
| 70 this.periodInMinutes = periodInMinutes; |
| 71 } |
| 72 |
| 73 /* |
| 74 * Private constructor |
| 75 */ |
| 76 AlarmsAlarmCreateInfo._proxy(_jsObject) : super._proxy(_jsObject); |
| 77 |
| 78 /* |
| 79 * Public accessors |
| 80 */ |
| 81 /// Time at which the alarm should fire, in milliseconds past the epoch (e.g. |
| 82 /// <code>Date.now() + n</code>). |
| 83 double get when => JS('double', '#.when', this._jsObject); |
| 84 |
| 85 void set when(double when) { |
| 86 JS('void', '#.when = #', this._jsObject, when); |
| 87 } |
| 88 |
| 89 /// Length of time in minutes after which the <code>onAlarm</code> event shoul
d |
| 90 /// fire.<br/><br/> <!-- TODO: need minimum=0 --> |
| 91 double get delayInMinutes => JS('double', '#.delayInMinutes', this._jsObject); |
| 92 |
| 93 void set delayInMinutes(double delayInMinutes) { |
| 94 JS('void', '#.delayInMinutes = #', this._jsObject, delayInMinutes); |
| 95 } |
| 96 |
| 97 /// If set, the onAlarm event should fire every <var>periodInMinutes</var> |
| 98 /// minutes after the initial event specified by <var>when</var> or |
| 99 /// <var>delayInMinutes</var>. If not set, the alarm will only fire |
| 100 /// once.<br/><br/> <!-- TODO: need minimum=0 --> |
| 101 double get periodInMinutes => JS('double', '#.periodInMinutes', this._jsObject
); |
| 102 |
| 103 void set periodInMinutes(double periodInMinutes) { |
| 104 JS('void', '#.periodInMinutes = #', this._jsObject, periodInMinutes); |
| 105 } |
| 106 |
| 107 } |
| 108 |
| 109 /** |
| 110 * Events |
| 111 */ |
| 112 |
| 113 /// Fired when an alarm has elapsed. Useful for event pages. |
| 114 class Event_alarms_onAlarm extends Event { |
| 115 void addListener(void callback(AlarmsAlarm alarm)) { |
| 116 void __proxy_callback(alarm) { |
| 117 if (?callback) { |
| 118 callback(new AlarmsAlarm._proxy(alarm)); |
| 119 } |
| 120 } |
| 121 super.addListener(callback); |
| 122 } |
| 123 |
| 124 void removeListener(void callback(AlarmsAlarm alarm)) { |
| 125 void __proxy_callback(alarm) { |
| 126 if (?callback) { |
| 127 callback(new AlarmsAlarm._proxy(alarm)); |
| 128 } |
| 129 } |
| 130 super.removeListener(callback); |
| 131 } |
| 132 |
| 133 bool hasListener(void callback(AlarmsAlarm alarm)) { |
| 134 void __proxy_callback(alarm) { |
| 135 if (?callback) { |
| 136 callback(new AlarmsAlarm._proxy(alarm)); |
| 137 } |
| 138 } |
| 139 super.hasListener(callback); |
| 140 } |
| 141 |
| 142 Event_alarms_onAlarm(jsObject) : super._(jsObject, 1); |
| 143 } |
| 144 |
| 145 /** |
| 146 * Functions |
| 147 */ |
| 148 |
| 149 class API_alarms { |
| 150 /* |
| 151 * API connection |
| 152 */ |
| 153 Object _jsObject; |
| 154 |
| 155 /* |
| 156 * Events |
| 157 */ |
| 158 Event_alarms_onAlarm onAlarm; |
| 159 |
| 160 /* |
| 161 * Functions |
| 162 */ |
| 163 /// Creates an alarm. Near the time(s) specified by <var>alarmInfo</var>, the |
| 164 /// <code>onAlarm</code> event is fired. If there is another alarm with the |
| 165 /// same name (or no name if none is specified), it will be cancelled and |
| 166 /// replaced by this alarm.<br/><br/> In order to reduce the load on the user'
s |
| 167 /// machine, Chrome limits alarms to at most once every 1 minute but may delay |
| 168 /// them an arbitrary amount more. That is, setting |
| 169 /// <code>$ref:[alarms.AlarmCreateInfo.delayInMinutes delayInMinutes]</code> o
r |
| 170 /// <code>$ref:[alarms.AlarmCreateInfo.periodInMinutes periodInMinutes]</code> |
| 171 /// to less than <code>1</code> will not be honored and will cause a warning. |
| 172 /// <code>$ref:[alarms.AlarmCreateInfo.when when]</code> can be set to less |
| 173 /// than 1 minute after "now" without warning but won't actually cause the |
| 174 /// alarm to fire for at least 1 minute.<br/><br/> To help you debug your app |
| 175 /// or extension, when you've loaded it unpacked, there's no limit to how ofte
n |
| 176 /// the alarm can fire. |
| 177 void create(AlarmsAlarmCreateInfo alarmInfo, [String name]) => JS('void', '#.c
reate(#, #)', this._jsObject, name, convertArgument(alarmInfo)); |
| 178 |
| 179 /// Retrieves details about the specified alarm. |
| 180 void get(void callback(AlarmsAlarm alarm), [String name]) { |
| 181 void __proxy_callback(alarm) { |
| 182 if (?callback) { |
| 183 callback(new AlarmsAlarm._proxy(alarm)); |
| 184 } |
| 185 } |
| 186 JS('void', '#.get(#, #)', this._jsObject, name, convertDartClosureToJS(__pro
xy_callback, 1)); |
| 187 } |
| 188 |
| 189 /// Gets an array of all the alarms. |
| 190 void getAll(void callback(List<AlarmsAlarm> alarms)) { |
| 191 void __proxy_callback(alarms) { |
| 192 if (?callback) { |
| 193 List<AlarmsAlarm> __proxy_alarms = new List<AlarmsAlarm>(); |
| 194 for (var o in alarms) { |
| 195 __proxy_alarms.add(new AlarmsAlarm._proxy(o)); |
| 196 } |
| 197 callback(__proxy_alarms); |
| 198 } |
| 199 } |
| 200 JS('void', '#.getAll(#)', this._jsObject, convertDartClosureToJS(__proxy_cal
lback, 1)); |
| 201 } |
| 202 |
| 203 /// Clears the alarm with the given name. |
| 204 void clear([String name]) => JS('void', '#.clear(#)', this._jsObject, name); |
| 205 |
| 206 /// Clears all alarms. |
| 207 void clearAll() => JS('void', '#.clearAll()', this._jsObject); |
| 208 |
| 209 API_alarms(this._jsObject) { |
| 210 onAlarm = new Event_alarms_onAlarm(JS('', '#.onAlarm', this._jsObject)); |
| 211 } |
| 212 } |
| OLD | NEW |