| 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 #include "chrome/renderer/extensions/enterprise_platform_keys_natives.h" | 5 #include "chrome/renderer/extensions/enterprise_platform_keys_natives.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/renderer/extensions/chrome_v8_context.h" | 10 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 11 #include "content/public/renderer/v8_value_converter.h" | 11 #include "content/public/renderer/v8_value_converter.h" |
| 12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" | 12 #include "third_party/WebKit/public/platform/WebCryptoAlgorithm.h" |
| 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
| 14 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
| 15 #include "third_party/WebKit/public/platform/WebVector.h" |
| 15 #include "third_party/WebKit/public/web/WebCryptoNormalize.h" | 16 #include "third_party/WebKit/public/web/WebCryptoNormalize.h" |
| 16 | 17 |
| 17 namespace extensions { | 18 namespace extensions { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 bool StringToWebCryptoOperation(const std::string& str, | 22 bool StringToWebCryptoOperation(const std::string& str, |
| 22 blink::WebCryptoOperation* op) { | 23 blink::WebCryptoOperation* op) { |
| 23 if (str == "GenerateKey") { | 24 if (str == "GenerateKey") { |
| 24 *op = blink::WebCryptoOperationGenerateKey; | 25 *op = blink::WebCryptoOperationGenerateKey; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 43 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 43 const blink::WebCryptoAlgorithmInfo* info = | 44 const blink::WebCryptoAlgorithmInfo* info = |
| 44 blink::WebCryptoAlgorithm::lookupAlgorithmInfo(algorithm.id()); | 45 blink::WebCryptoAlgorithm::lookupAlgorithmInfo(algorithm.id()); |
| 45 dict->SetStringWithoutPathExpansion("name", info->name); | 46 dict->SetStringWithoutPathExpansion("name", info->name); |
| 46 const blink::WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGen = | 47 const blink::WebCryptoRsaHashedKeyGenParams* rsaHashedKeyGen = |
| 47 algorithm.rsaHashedKeyGenParams(); | 48 algorithm.rsaHashedKeyGenParams(); |
| 48 if (rsaHashedKeyGen) { | 49 if (rsaHashedKeyGen) { |
| 49 dict->SetIntegerWithoutPathExpansion("modulusLength", | 50 dict->SetIntegerWithoutPathExpansion("modulusLength", |
| 50 rsaHashedKeyGen->modulusLengthBits()); | 51 rsaHashedKeyGen->modulusLengthBits()); |
| 52 const blink::WebVector<unsigned char>& public_exponent = |
| 53 rsaHashedKeyGen->publicExponent(); |
| 54 dict->SetWithoutPathExpansion( |
| 55 "publicExponent", |
| 56 base::BinaryValue::CreateWithCopiedBuffer( |
| 57 reinterpret_cast<const char*>(public_exponent.data()), |
| 58 public_exponent.size())); |
| 51 } | 59 } |
| 52 // Otherwise, |algorithm| is missing support here or no parameters were | 60 // Otherwise, |algorithm| is missing support here or no parameters were |
| 53 // required. | 61 // required. |
| 54 return dict.Pass(); | 62 return dict.Pass(); |
| 55 } | 63 } |
| 56 | 64 |
| 57 } // namespace | 65 } // namespace |
| 58 | 66 |
| 59 EnterprisePlatformKeysNatives::EnterprisePlatformKeysNatives( | 67 EnterprisePlatformKeysNatives::EnterprisePlatformKeysNatives( |
| 60 ScriptContext* context) | 68 ScriptContext* context) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 if (!algorithm_dict) | 101 if (!algorithm_dict) |
| 94 return; | 102 return; |
| 95 | 103 |
| 96 scoped_ptr<content::V8ValueConverter> converter( | 104 scoped_ptr<content::V8ValueConverter> converter( |
| 97 content::V8ValueConverter::create()); | 105 content::V8ValueConverter::create()); |
| 98 call_info.GetReturnValue().Set( | 106 call_info.GetReturnValue().Set( |
| 99 converter->ToV8Value(algorithm_dict.get(), context()->v8_context())); | 107 converter->ToV8Value(algorithm_dict.get(), context()->v8_context())); |
| 100 } | 108 } |
| 101 | 109 |
| 102 } // namespace extensions | 110 } // namespace extensions |
| OLD | NEW |