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

Side by Side Diff: chrome/renderer/resources/extensions/experimental.offscreenTabs_custom_bindings.js

Issue 9796012: Revert 127833 - Re-land alexbost's experimental offscreenTabs API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
(Empty)
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.
4
5 // Custom bindings for the experimental offscreenTabs API.
6
7 (function() {
8
9 native function GetChromeHidden();
10
11 GetChromeHidden().registerCustomHook(
12 'experimental.offscreenTabs', function(api) {
13 var apiFunctions = api.apiFunctions;
14
15 function maybeCopy(src, prop, dest) {
16 if (src[prop] !== undefined)
17 dest[prop] = src[prop];
18 };
19
20 function keyboardEventFilter(e) {
21 var result = {
22 type: e.type,
23 ctrlKey: e.ctrlKey,
24 shiftKey: e.shiftKey,
25 altKey: e.altKey,
26 metaKey: e.metaKey,
27 };
28 maybeCopy(e, 'keyCode', result);
29 maybeCopy(e, 'charCode', result);
30 return result;
31 };
32
33 function mouseEventFilter(e) {
34 var result = {
35 type: e.type,
36 ctrlKey: e.ctrlKey,
37 shiftKey: e.shiftKey,
38 altKey: e.altKey,
39 metaKey: e.metaKey,
40 button: e.button,
41 };
42 maybeCopy(e, 'wheelDeltaX', result);
43 maybeCopy(e, 'wheelDeltaY', result);
44 return result;
45 };
46
47 // We are making a copy of |arr|, but applying |func| to index 1.
48 function validate(arr, func) {
49 var newArr = [];
50 for (var i = 0; i < arr.length; i++)
51 newArr.push(i == 1 && typeof(arr) == 'object' ? func(arr[i]) : arr[i]);
52 return newArr;
53 }
54
55 apiFunctions.setUpdateArgumentsPreValidate(
56 'sendKeyboardEvent',
57 function() { return validate(arguments, keyboardEventFilter); });
58 apiFunctions.setUpdateArgumentsPreValidate(
59 'sendMouseEvent',
60 function() { return validate(arguments, mouseEventFilter); });
61 });
62
63 })();
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | chrome/test/data/extensions/api_test/get_views/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698