Index: chrome/renderer/extensions/enterprise_certificates_natives.cc |
diff --git a/chrome/renderer/extensions/enterprise_certificates_natives.cc b/chrome/renderer/extensions/enterprise_certificates_natives.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fa47365d13f1046b9c08b6a99f554dc486473add |
--- /dev/null |
+++ b/chrome/renderer/extensions/enterprise_certificates_natives.cc |
@@ -0,0 +1,45 @@ |
+// 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. |
+ |
+#include "chrome/renderer/extensions/enterprise_certificates_natives.h" |
+ |
+#include <string> |
+ |
+#include "third_party/WebKit/public/platform/Platform.h" |
+#include "third_party/WebKit/public/platform/WebCrypto.h" |
+#include "third_party/WebKit/public/platform/WebCryptoKey.h" |
+#include "third_party/WebKit/public/web/WebScriptBindings.h" |
+#include "v8/include/v8.h" |
+ |
+namespace extensions { |
+ |
+EnterpriseCertificatesNatives::EnterpriseCertificatesNatives( |
+ ChromeV8Context* context) |
+ : ObjectBackedNativeHandler(context) { |
+ RouteFunction("GetPrivateKey", |
+ base::Bind(&EnterpriseCertificatesNatives::GetPrivateKey, |
+ base::Unretained(this))); |
eroman
2014/04/10 18:45:46
I haven't read through the rest of this, change, b
pneubeck (no reviews)
2014/04/11 14:13:59
This seems to be the way how ObjectBackedNativeHan
|
+} |
+ |
+void EnterpriseCertificatesNatives::GetPrivateKey( |
+ const v8::FunctionCallbackInfo<v8::Value>& call_info) { |
+ const blink::WebCryptoKey* key = |
+ blink::WebScriptBindings::toWebCryptoKey(call_info[0].As<v8::Object>()); |
eroman
2014/04/10 18:45:46
This function doesn't exist, so presumably depends
pneubeck (no reviews)
2014/04/11 14:13:59
Added a link to the blink change to the commit mes
|
+ if (!key) |
eroman
2014/04/10 18:45:46
IMPORTANT: You should also check the key type. Sin
pneubeck (no reviews)
2014/04/11 14:13:59
Done.
|
+ return; |
+ |
+ blink::WebVector<unsigned char> keyData; |
eroman
2014/04/10 18:45:46
style: keyData --> key_data
pneubeck (no reviews)
2014/04/11 14:13:59
Done.
|
+ blink::Platform::current()->crypto()->serializeKeyForClone(*key, keyData); |
eroman
2014/04/10 18:45:46
IMPORTANT: serializeKeyForClone() returns a boolea
pneubeck (no reviews)
2014/04/11 14:13:59
Done.
|
+ |
+ v8::Handle<v8::Array> result = |
+ v8::Array::New(call_info.GetIsolate(), keyData.size()); |
eroman
2014/04/10 18:45:46
IMPORTANT: Please explain this. Why is the key bei
pneubeck (no reviews)
2014/04/11 14:13:59
kalman@ mentioned that the javascript side of the
|
+ for (size_t i = 0; i < keyData.size(); ++i) { |
+ result->Set( |
+ i, v8::Integer::NewFromUnsigned(call_info.GetIsolate(), keyData[i])); |
+ } |
+ |
+ call_info.GetReturnValue().Set(result); |
+} |
+ |
+} // namespace extensions |