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

Unified 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: Allow import of non-extractable keys. 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 side-by-side diff with in-line comments
Download patch
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..1d80f72f9505690266ece7652a18ea7e395a684d
--- /dev/null
+++ b/chrome/renderer/resources/extensions/enterprise_certificates_custom_bindings.js
@@ -0,0 +1,36 @@
+// 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 webRequest API.
+
+var binding = require('binding').Binding.create('enterprise.certificates');
+var certificatesInternal =
+ require('binding')
+ .Binding.create('enterprise.certificatesInternal')
+ .generate();
+// var sendRequest = require('sendRequest').sendRequest;
+var getPrivateKeyNative =
+ requireNative('enterprise_certificates_natives').GetPrivateKey;
+
+binding.registerCustomHook(function(api) {
+ var apiFunctions = api.apiFunctions;
+
+ var keyFormat = 'pkcs8';
+ var ret = apiFunctions.setHandleRequest('importClientCertificate',
+ function(key, cert, token, callback) {
+ console.log('Try native export');
+ var rawKey = new Uint8Array(getPrivateKeyNative(key)).buffer;
+ try {
+ certificatesInternal.importClientCertificate(
+ rawKey, cert, token, callback);
+ }
+ catch (e) {
+ console.log('catched error: ' + e);
+ }
+ return true;
+ });
+ console.log(ret);
+});
+
+exports.binding = binding.generate();

Powered by Google App Engine
This is Rietveld 408576698