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

Side by Side Diff: chrome/renderer/extensions/enterprise_certificates_natives.cc

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 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 #include "chrome/renderer/extensions/enterprise_certificates_natives.h"
6
7 #include <string>
8
9 #include "third_party/WebKit/public/platform/Platform.h"
10 #include "third_party/WebKit/public/platform/WebCrypto.h"
11 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
12 #include "third_party/WebKit/public/web/WebScriptBindings.h"
13 #include "v8/include/v8.h"
14
15 namespace extensions {
16
17 EnterpriseCertificatesNatives::EnterpriseCertificatesNatives(
18 ChromeV8Context* context)
19 : ObjectBackedNativeHandler(context) {
20 RouteFunction("GetPrivateKey",
21 base::Bind(&EnterpriseCertificatesNatives::GetPrivateKey,
22 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
23 }
24
25 void EnterpriseCertificatesNatives::GetPrivateKey(
26 const v8::FunctionCallbackInfo<v8::Value>& call_info) {
27 const blink::WebCryptoKey* key =
28 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
29 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.
30 return;
31
32 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.
33 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.
34
35 v8::Handle<v8::Array> result =
36 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
37 for (size_t i = 0; i < keyData.size(); ++i) {
38 result->Set(
39 i, v8::Integer::NewFromUnsigned(call_info.GetIsolate(), keyData[i]));
40 }
41
42 call_info.GetReturnValue().Set(result);
43 }
44
45 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698