| Index: chrome/renderer/resources/extensions/permissions_custom_bindings.js
|
| diff --git a/chrome/renderer/resources/extensions/permissions_custom_bindings.js b/chrome/renderer/resources/extensions/permissions_custom_bindings.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..82a0b0aa78286060567c2e1c91aa953804715469
|
| --- /dev/null
|
| +++ b/chrome/renderer/resources/extensions/permissions_custom_bindings.js
|
| @@ -0,0 +1,36 @@
|
| +// 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] + '|' + a[keys[0]];
|
| + }
|
| + }
|
| +
|
| + return arguments;
|
| + });
|
| +});
|
|
|