Index: chrome/renderer/resources/extensions/enterprise_certificates_custom_bindings.js |
diff --git a/chrome/renderer/resources/extensions/enterprise_certificates_custom_bindings.js b/chrome/renderer/resources/extensions/enterprise_certificates_custom_bindings.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f9a75c916a6f1d6461ad4033df38b519cf11b294 |
--- /dev/null |
+++ b/chrome/renderer/resources/extensions/enterprise_certificates_custom_bindings.js |
@@ -0,0 +1,46 @@ |
+// Copyright 2014 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 binding for the enterprise.certificates API. |
+ |
+var binding = require('binding').Binding.create('enterprise.certificates'); |
+var utils = require('utils'); |
+var internalAPI = require('enterprise.certificatesInternal').binding; |
+var internalAPISchema = requireNative('schema_registry') |
+ .GetSchema('enterprise.certificatesInternal'); |
+ |
+// Token class definition. |
+var Token = function(tokenName) { |
+ privates(this).tokenName_ = tokenName; |
+}; |
+ |
+Object.defineProperty(Token.prototype, 'name', { |
+ get: function() { |
+ return privates(this).tokenName_; |
+} |
+, enumerable : true |
+}); |
+ |
+Token.prototype.importClientCertificate = function(key, certificate, callback) { |
+ var schema = utils.lookup(internalAPISchema.functions, |
+ 'name', |
+ 'importClientCertificateAndWebCryptoKey'); |
+ internalAPI.importClientCertificateAndWebCryptoKey( |
+ key, certificate, this.name, callback); |
+}; |
+ |
+binding.registerCustomHook(function(api) { |
+ var apiFunctions = api.apiFunctions; |
+ |
+ var ret = apiFunctions.setHandleRequest('getTokens', function(callback) { |
+ console.log(internalAPI); |
+ console.log(internalAPI.getTokens); |
+ internalAPI.getTokens(function(tokenNames) { |
+ callback($Array.map( |
+ tokenNames, function(tokenName) { return new Token(tokenName); })); |
+ }); |
+ }); |
+}); |
+ |
+exports.binding = binding.generate(); |