OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/crypto/proxy_decryptor.h" | 5 #include "content/renderer/media/crypto/proxy_decryptor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // compatibility the error is not thrown, but rather reported as a | 142 // compatibility the error is not thrown, but rather reported as a |
143 // KeyError. | 143 // KeyError. |
144 key_error_cb_.Run(std::string(), media::MediaKeys::kUnknownError, 0); | 144 key_error_cb_.Run(std::string(), media::MediaKeys::kUnknownError, 0); |
145 return; | 145 return; |
146 } | 146 } |
147 | 147 |
148 // EME WD spec only supports a single array passed to the CDM. For | 148 // EME WD spec only supports a single array passed to the CDM. For |
149 // Clear Key using v0.1b, both arrays are used (|init_data| is key_id). | 149 // Clear Key using v0.1b, both arrays are used (|init_data| is key_id). |
150 // Since the EME WD spec supports the key as a JSON Web Key, | 150 // Since the EME WD spec supports the key as a JSON Web Key, |
151 // convert the 2 arrays to a JWK and pass it as the single array. | 151 // convert the 2 arrays to a JWK and pass it as the single array. |
152 // TODO(jrummell): When updating Decryptor interface to match WD, move the | 152 if (is_clear_key_) { |
153 // workaround for handling |init_data| == null here. | 153 // Decryptor doesn't support empty key ID (see http://crbug.com/123265). |
154 if (is_clear_key_ && init_data_length) { | 154 // So ensure a non-empty value is passed. |
| 155 if (!init_data) { |
| 156 static const uint8 kDummyInitData[1] = {0}; |
| 157 init_data = kDummyInitData; |
| 158 init_data_length = arraysize(kDummyInitData); |
| 159 } |
| 160 |
155 std::string jwk = | 161 std::string jwk = |
156 media::GenerateJWKSet(key, key_length, init_data, init_data_length); | 162 media::GenerateJWKSet(key, key_length, init_data, init_data_length); |
157 DCHECK(!jwk.empty()); | 163 DCHECK(!jwk.empty()); |
158 media_keys_->AddKey(reference_id, | 164 media_keys_->AddKey(reference_id, |
159 reinterpret_cast<const uint8*>(jwk.data()), jwk.size(), | 165 reinterpret_cast<const uint8*>(jwk.data()), jwk.size(), |
160 NULL, 0); | 166 NULL, 0); |
161 return; | 167 return; |
162 } | 168 } |
163 | 169 |
164 media_keys_->AddKey(reference_id, key, key_length, NULL, 0); | 170 media_keys_->AddKey(reference_id, key, key_length, NULL, 0); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 252 |
247 const std::string& ProxyDecryptor::LookupSessionId(uint32 reference_id) { | 253 const std::string& ProxyDecryptor::LookupSessionId(uint32 reference_id) { |
248 DCHECK_NE(reference_id, INVALID_REFERENCE_ID); | 254 DCHECK_NE(reference_id, INVALID_REFERENCE_ID); |
249 | 255 |
250 // Session may not exist if error happens during GenerateKeyRequest(). | 256 // Session may not exist if error happens during GenerateKeyRequest(). |
251 SessionIdMap::iterator it = sessions_.find(reference_id); | 257 SessionIdMap::iterator it = sessions_.find(reference_id); |
252 return (it != sessions_.end()) ? it->second : EmptyString(); | 258 return (it != sessions_.end()) ? it->second : EmptyString(); |
253 } | 259 } |
254 | 260 |
255 } // namespace content | 261 } // namespace content |
OLD | NEW |