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

Side by Side Diff: chrome/renderer/resources/extensions/permissions_custom_bindings.js

Issue 15841013: Make miscellaneous_bindings and event_bindings Required as needed. Previously (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Custom binding for the Permissions API. 5 // Custom binding for the Permissions API.
6 6
7 var binding = require('binding').Binding.create('permissions'); 7 var binding = require('binding').Binding.create('permissions');
8 8
9 var Event = require('event_bindings').Event;
9 var sendRequest = require('sendRequest').sendRequest; 10 var sendRequest = require('sendRequest').sendRequest;
10 11
11 // These custom binding are only necessary because it is not currently 12 // These custom binding are only necessary because it is not currently
12 // possible to have a union of types as the type of the items in an array. 13 // possible to have a union of types as the type of the items in an array.
13 // Once that is fixed, this entire file should go away. 14 // Once that is fixed, this entire file should go away.
14 // See, 15 // See,
15 // https://code.google.com/p/chromium/issues/detail?id=162044 16 // https://code.google.com/p/chromium/issues/detail?id=162044
16 // https://code.google.com/p/chromium/issues/detail?id=162042 17 // https://code.google.com/p/chromium/issues/detail?id=162042
17 // TODO(bryeung): delete this file. 18 // TODO(bryeung): delete this file.
18 binding.registerCustomHook(function(api) { 19 binding.registerCustomHook(function(api) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }); 79 });
79 80
80 // Also convert complex permissions back to objects for events. The 81 // Also convert complex permissions back to objects for events. The
81 // dispatchToListener call happens after argument validation, which works 82 // dispatchToListener call happens after argument validation, which works
82 // around the problem that Permissions.permissions is supposed to be a list 83 // around the problem that Permissions.permissions is supposed to be a list
83 // of strings. 84 // of strings.
84 permissions.onAdded.dispatchToListener = function(callback, args) { 85 permissions.onAdded.dispatchToListener = function(callback, args) {
85 for (var i = 0; i < args[0].permissions.length; i += 1) { 86 for (var i = 0; i < args[0].permissions.length; i += 1) {
86 args[0].permissions[i] = maybeConvertToObject(args[0].permissions[i]); 87 args[0].permissions[i] = maybeConvertToObject(args[0].permissions[i]);
87 } 88 }
88 chrome.Event.prototype.dispatchToListener(callback, args); 89 Event.prototype.dispatchToListener(callback, args);
89 }; 90 };
90 permissions.onRemoved.dispatchToListener = 91 permissions.onRemoved.dispatchToListener =
91 permissions.onAdded.dispatchToListener; 92 permissions.onAdded.dispatchToListener;
92 }); 93 });
93 94
94 exports.binding = binding.generate(); 95 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698