| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 var utils = require('utils'); | 5 var utils = require('utils'); |
| 6 var internalAPI = require('enterprise.platformKeys.internalAPI'); | 6 var internalAPI = require('enterprise.platformKeys.internalAPI'); |
| 7 var intersect = require('platformKeys.utils').intersect; | 7 var intersect = require('platformKeys.utils').intersect; |
| 8 var subtleCryptoModule = require('platformKeys.SubtleCrypto'); | 8 var subtleCryptoModule = require('platformKeys.SubtleCrypto'); |
| 9 var SubtleCrypto = subtleCryptoModule.SubtleCrypto; | |
| 10 var SubtleCryptoImpl = subtleCryptoModule.SubtleCryptoImpl; | 9 var SubtleCryptoImpl = subtleCryptoModule.SubtleCryptoImpl; |
| 11 var KeyPair = require('enterprise.platformKeys.KeyPair').KeyPair; | 10 var KeyPair = require('enterprise.platformKeys.KeyPair').KeyPair; |
| 12 var KeyUsage = require('platformKeys.Key').KeyUsage; | 11 var KeyUsage = require('platformKeys.Key').KeyUsage; |
| 13 | 12 |
| 14 var normalizeAlgorithm = | 13 var normalizeAlgorithm = |
| 15 requireNative('platform_keys_natives').NormalizeAlgorithm; | 14 requireNative('platform_keys_natives').NormalizeAlgorithm; |
| 16 | 15 |
| 17 // This error is thrown by the internal and public API's token functions and | 16 // This error is thrown by the internal and public API's token functions and |
| 18 // must be rethrown by this custom binding. Keep this in sync with the C++ part | 17 // must be rethrown by this custom binding. Keep this in sync with the C++ part |
| 19 // of this API. | 18 // of this API. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return; | 125 return; |
| 127 if (chrome.runtime.lastError) { | 126 if (chrome.runtime.lastError) { |
| 128 reject(CreateOperationError()); | 127 reject(CreateOperationError()); |
| 129 return; | 128 return; |
| 130 } | 129 } |
| 131 resolve(new KeyPair(spki, normalizedAlgorithmParameters, keyUsages)); | 130 resolve(new KeyPair(spki, normalizedAlgorithmParameters, keyUsages)); |
| 132 }); | 131 }); |
| 133 }); | 132 }); |
| 134 }; | 133 }; |
| 135 | 134 |
| 136 exports.SubtleCrypto = | 135 function SubtleCrypto() { |
| 137 utils.expose('SubtleCrypto', | 136 privates(SubtleCrypto).constructPrivate(this, arguments); |
| 138 EnterpriseSubtleCryptoImpl, | 137 } |
| 139 { | 138 utils.expose(SubtleCrypto, EnterpriseSubtleCryptoImpl, { |
| 140 superclass: SubtleCrypto, | 139 superclass: subtleCryptoModule.SubtleCrypto, |
| 141 functions: ['generateKey'] | 140 functions: [ |
| 142 // ['sign', 'exportKey'] are exposed by the base class | 141 'generateKey', |
| 143 }); | 142 // 'sign', 'exportKey' are exposed by the base class |
| 143 ], |
| 144 }); |
| 145 |
| 146 exports.$set('SubtleCrypto', SubtleCrypto); |
| OLD | NEW |