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

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

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed to OO-style API with Token object. Created 6 years, 8 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Custom binding for the enterprise.certificates API.
6
7 var binding = require('binding').Binding.create('enterprise.certificates');
8 var utils = require('utils');
9 var internalAPI = require('enterprise.certificatesInternal').binding;
10 var internalAPISchema = requireNative('schema_registry')
11 .GetSchema('enterprise.certificatesInternal');
12
13 // Token class definition.
14 var Token = function(tokenName) {
15 privates(this).tokenName_ = tokenName;
16 };
17
18 Object.defineProperty(Token.prototype, 'name', {
19 get: function() {
20 return privates(this).tokenName_;
21 }
22 , enumerable : true
23 });
24
25 Token.prototype.importClientCertificate = function(key, certificate, callback) {
26 var schema = utils.lookup(internalAPISchema.functions,
27 'name',
28 'importClientCertificateAndWebCryptoKey');
29 internalAPI.importClientCertificateAndWebCryptoKey(
30 key, certificate, this.name, callback);
31 };
32
33 binding.registerCustomHook(function(api) {
34 var apiFunctions = api.apiFunctions;
35
36 var ret = apiFunctions.setHandleRequest('getTokens', function(callback) {
37 console.log(internalAPI);
38 console.log(internalAPI.getTokens);
39 internalAPI.getTokens(function(tokenNames) {
40 callback($Array.map(
41 tokenNames, function(tokenName) { return new Token(tokenName); }));
42 });
43 });
44 });
45
46 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698