| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 WebCryptoKeyUsageMask keyUsageStringToMask(const String& usageString) | 92 WebCryptoKeyUsageMask keyUsageStringToMask(const String& usageString) |
| 93 { | 93 { |
| 94 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { | 94 for (size_t i = 0; i < WTF_ARRAY_LENGTH(keyUsageMappings); ++i) { |
| 95 if (keyUsageMappings[i].name == usageString) | 95 if (keyUsageMappings[i].name == usageString) |
| 96 return keyUsageMappings[i].value; | 96 return keyUsageMappings[i].value; |
| 97 } | 97 } |
| 98 return 0; | 98 return 0; |
| 99 } | 99 } |
| 100 | 100 |
| 101 class DictionaryBuilder : public blink::WebCryptoKeyAlgorithmDictionary { | 101 class DictionaryBuilder : public WebCryptoKeyAlgorithmDictionary { |
| 102 public: | 102 public: |
| 103 explicit DictionaryBuilder(V8ObjectBuilder& builder) | 103 explicit DictionaryBuilder(V8ObjectBuilder& builder) |
| 104 : m_builder(builder) | 104 : m_builder(builder) |
| 105 { | 105 { |
| 106 } | 106 } |
| 107 | 107 |
| 108 virtual void setString(const char* propertyName, const char* value) | 108 virtual void setString(const char* propertyName, const char* value) |
| 109 { | 109 { |
| 110 m_builder.addString(propertyName, value); | 110 m_builder.addString(propertyName, value); |
| 111 } | 111 } |
| 112 | 112 |
| 113 virtual void setUint(const char* propertyName, unsigned value) | 113 virtual void setUint(const char* propertyName, unsigned value) |
| 114 { | 114 { |
| 115 m_builder.addNumber(propertyName, value); | 115 m_builder.addNumber(propertyName, value); |
| 116 } | 116 } |
| 117 | 117 |
| 118 virtual void setAlgorithm(const char* propertyName, const blink::WebCryptoAl
gorithm& algorithm) | 118 virtual void setAlgorithm(const char* propertyName, const WebCryptoAlgorithm
& algorithm) |
| 119 { | 119 { |
| 120 ASSERT(algorithm.paramsType() == blink::WebCryptoAlgorithmParamsTypeNone
); | 120 ASSERT(algorithm.paramsType() == WebCryptoAlgorithmParamsTypeNone); |
| 121 | 121 |
| 122 V8ObjectBuilder algorithmValue(m_builder.scriptState()); | 122 V8ObjectBuilder algorithmValue(m_builder.scriptState()); |
| 123 algorithmValue.addString("name", blink::WebCryptoAlgorithm::lookupAlgori
thmInfo(algorithm.id())->name); | 123 algorithmValue.addString("name", WebCryptoAlgorithm::lookupAlgorithmInfo
(algorithm.id())->name); |
| 124 m_builder.add(propertyName, algorithmValue); | 124 m_builder.add(propertyName, algorithmValue); |
| 125 } | 125 } |
| 126 | 126 |
| 127 virtual void setUint8Array(const char* propertyName, const blink::WebVector<
unsigned char>& vector) | 127 virtual void setUint8Array(const char* propertyName, const WebVector<unsigne
d char>& vector) |
| 128 { | 128 { |
| 129 m_builder.add(propertyName, DOMUint8Array::create(vector.data(), vector.
size())); | 129 m_builder.add(propertyName, DOMUint8Array::create(vector.data(), vector.
size())); |
| 130 } | 130 } |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 V8ObjectBuilder& m_builder; | 133 V8ObjectBuilder& m_builder; |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace | 136 } // namespace |
| 137 | 137 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 if (!usage) { | 224 if (!usage) { |
| 225 result->completeWithError(WebCryptoErrorTypeType, "Invalid keyUsages
argument"); | 225 result->completeWithError(WebCryptoErrorTypeType, "Invalid keyUsages
argument"); |
| 226 return false; | 226 return false; |
| 227 } | 227 } |
| 228 mask |= usage; | 228 mask |= usage; |
| 229 } | 229 } |
| 230 return true; | 230 return true; |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |