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

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

Issue 11413099: Bluetooth API Permission Dialogs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix memory leak Created 8 years 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
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/resources/renderer_resources.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+ });
+});
« no previous file with comments | « chrome/renderer/extensions/dispatcher.cc ('k') | chrome/renderer/resources/renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698