| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * A set of utilities for use with the Chrome Extension APIs. | 6 * A set of utilities for use with the Chrome Extension APIs. |
| 7 * | 7 * |
| 8 * Allows for easy access to required JS objects. | 8 * Allows for easy access to required JS objects. |
| 9 */ | 9 */ |
| 10 part of chrome; | 10 part of chrome; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 /// Registers rules to handle events. | 220 /// Registers rules to handle events. |
| 221 /// | 221 /// |
| 222 /// [eventName] is the name of the event this function affects and [rules] are | 222 /// [eventName] is the name of the event this function affects and [rules] are |
| 223 /// the rules to be registered. These do not replace previously registered | 223 /// the rules to be registered. These do not replace previously registered |
| 224 /// rules. [callback] is called with registered rules. | 224 /// rules. [callback] is called with registered rules. |
| 225 /// | 225 /// |
| 226 void addRules(String eventName, List<Rule> rules, | 226 void addRules(String eventName, List<Rule> rules, |
| 227 [void callback(List<Rule> rules)]) { | 227 [void callback(List<Rule> rules)]) { |
| 228 // proxy the callback | 228 // proxy the callback |
| 229 void __proxy_callback(List rules) { | 229 void __proxy_callback(List rules) { |
| 230 if (?callback) { | 230 if (callback != null) { |
| 231 List<Rule> __proxy_rules = new List<Rule>(); | 231 List<Rule> __proxy_rules = new List<Rule>(); |
| 232 | 232 |
| 233 for (Object o in rules) | 233 for (Object o in rules) |
| 234 __proxy_rules.add(new Rule._proxy(o)); | 234 __proxy_rules.add(new Rule._proxy(o)); |
| 235 | 235 |
| 236 callback(__proxy_rules); | 236 callback(__proxy_rules); |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 | 239 |
| 240 JS('void', | 240 JS('void', |
| 241 '#.addRules(#, #, #)', | 241 '#.addRules(#, #, #)', |
| 242 this._jsObject, | 242 this._jsObject, |
| 243 convertArgument(eventName), | 243 convertArgument(eventName), |
| 244 convertArgument(rules), | 244 convertArgument(rules), |
| 245 convertDartClosureToJS(__proxy_callback, 1) | 245 convertDartClosureToJS(__proxy_callback, 1) |
| 246 ); | 246 ); |
| 247 } | 247 } |
| 248 | 248 |
| 249 /// Returns currently registered rules. | 249 /// Returns currently registered rules. |
| 250 /// | 250 /// |
| 251 /// [eventName] is the name of the event this function affects and, if an arra
y | 251 /// [eventName] is the name of the event this function affects and, if an arra
y |
| 252 /// is passed as [ruleIdentifiers], only rules with identifiers contained in | 252 /// is passed as [ruleIdentifiers], only rules with identifiers contained in |
| 253 /// this array are returned. [callback] is called with registered rules. | 253 /// this array are returned. [callback] is called with registered rules. |
| 254 /// | 254 /// |
| 255 void getRules(String eventName, [List<String> ruleIdentifiers, | 255 void getRules(String eventName, [List<String> ruleIdentifiers, |
| 256 void callback(List<Rule> rules)]) { | 256 void callback(List<Rule> rules)]) { |
| 257 // proxy the callback | 257 // proxy the callback |
| 258 void __proxy_callback(List rules) { | 258 void __proxy_callback(List rules) { |
| 259 if (?callback) { | 259 if (callback != null) { |
| 260 List<Rule> __proxy_rules = new List<Rule>(); | 260 List<Rule> __proxy_rules = new List<Rule>(); |
| 261 | 261 |
| 262 for (Object o in rules) | 262 for (Object o in rules) |
| 263 __proxy_rules.add(new Rule._proxy(o)); | 263 __proxy_rules.add(new Rule._proxy(o)); |
| 264 | 264 |
| 265 callback(__proxy_rules); | 265 callback(__proxy_rules); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 JS('void', | 269 JS('void', |
| (...skipping 16 matching lines...) Expand all Loading... |
| 286 void callback()]) => | 286 void callback()]) => |
| 287 JS('void', | 287 JS('void', |
| 288 '#.removeRules(#, #, #)', | 288 '#.removeRules(#, #, #)', |
| 289 this._jsObject, | 289 this._jsObject, |
| 290 convertArgument(eventName), | 290 convertArgument(eventName), |
| 291 convertArgument(ruleIdentifiers), | 291 convertArgument(ruleIdentifiers), |
| 292 convertDartClosureToJS(callback, 0) | 292 convertDartClosureToJS(callback, 0) |
| 293 ); | 293 ); |
| 294 } | 294 } |
| 295 | 295 |
| OLD | NEW |