blob: faf03f8385474269a22c3f62cdf27cd9e276e229 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Custom bindings for the Permissions API.
var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
var sendRequest = require('sendRequest').sendRequest;
var lastError = require('lastError');
chromeHidden.registerCustomHook('permissions', function(api) {
var apiFunctions = api.apiFunctions;
apiFunctions.setUpdateArgumentsPreValidate('request',
function() {
if (arguments.length < 1)
return arguments;
var args = arguments[0].permissions;
if (!args)
return arguments;
for (var i = 0; i < args.length; i += 1) {
if (typeof(args[i]) == 'object') {
var a = args[i];
var keys = Object.keys(a);
if (keys.length != 1) {
throw new Error("Too many keys in object-style permission.");
}
arguments[0].permissions[i] = keys[0] + '|' +
JSON.stringify(a[keys[0]]);
}
}
return arguments;
});
});
|