1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Custom binding for the experimental offscreenTabs API.
7 var binding
= require('binding').Binding
.create('experimental.offscreenTabs');
9 binding
.registerCustomHook(
10 'experimental.offscreenTabs', function(api
) {
11 var apiFunctions
= api
.apiFunctions
;
13 function maybeCopy(src
, prop
, dest
) {
14 if (src
[prop
] !== undefined)
15 dest
[prop
] = src
[prop
];
18 function keyboardEventFilter(e
) {
26 maybeCopy(e
, 'keyCode', result
);
27 maybeCopy(e
, 'charCode', result
);
31 function mouseEventFilter(e
) {
40 maybeCopy(e
, 'wheelDeltaX', result
);
41 maybeCopy(e
, 'wheelDeltaY', result
);
45 // We are making a copy of |arr|, but applying |func| to index 1.
46 function validate(arr
, func
) {
48 for (var i
= 0; i
< arr
.length
; i
++) {
50 i
== 1 && typeof(arr
) == 'object' ? func(arr
[i
]) : arr
[i
]);
55 apiFunctions
.setUpdateArgumentsPreValidate(
57 function() { return validate(arguments
, keyboardEventFilter
); });
58 apiFunctions
.setUpdateArgumentsPreValidate(
60 function() { return validate(arguments
, mouseEventFilter
); });
63 exports
.binding
= binding
.generate();