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

Unified Diff: chrome/renderer/resources/extensions/permissions_custom_bindings.js

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android compilation Created 7 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 side-by-side diff with in-line comments
Download patch
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
index b32a57deb5e34e350a549405b5aeed636d95d2b0..e728080493f9344b8ecd30b3a8ef7e0ffebe4268 100644
--- a/chrome/renderer/resources/extensions/permissions_custom_bindings.js
+++ b/chrome/renderer/resources/extensions/permissions_custom_bindings.js
@@ -2,21 +2,23 @@
// 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.
+// Custom binding for the Permissions API.
+
+var binding = require('binding').Binding.create('permissions');
-var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
var sendRequest = require('sendRequest').sendRequest;
var lastError = require('lastError');
-// These custom bindings are only necessary because it is not currently
+// These custom binding are only necessary because it is not currently
// possible to have a union of types as the type of the items in an array.
// Once that is fixed, this entire file should go away.
// See,
// https://code.google.com/p/chromium/issues/detail?id=162044
// https://code.google.com/p/chromium/issues/detail?id=162042
// TODO(bryeung): delete this file.
-chromeHidden.registerCustomHook('permissions', function(api) {
+binding.registerCustomHook(function(api) {
var apiFunctions = api.apiFunctions;
+ var permissions = api.compiledApi;
function maybeConvertToObject(str) {
var parts = str.split('|');
@@ -80,12 +82,14 @@ chromeHidden.registerCustomHook('permissions', function(api) {
// dispatchToListener call happens after argument validation, which works
// around the problem that Permissions.permissions is supposed to be a list
// of strings.
- chrome.permissions.onAdded.dispatchToListener = function(callback, args) {
+ permissions.onAdded.dispatchToListener = function(callback, args) {
for (var i = 0; i < args[0].permissions.length; i += 1) {
args[0].permissions[i] = maybeConvertToObject(args[0].permissions[i]);
}
chrome.Event.prototype.dispatchToListener(callback, args);
};
- chrome.permissions.onRemoved.dispatchToListener =
- chrome.permissions.onAdded.dispatchToListener;
+ permissions.onRemoved.dispatchToListener =
+ permissions.onAdded.dispatchToListener;
});
+
+exports.binding = binding.generate();

Powered by Google App Engine
This is Rietveld 408576698