| 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 "media/cdm/proxy_decryptor.h" | 5 #include "media/cdm/proxy_decryptor.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 security_origin, | 204 security_origin, |
| 205 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), | 205 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), |
| 206 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), | 206 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), |
| 207 base::Bind(&ProxyDecryptor::OnSessionError, weak_this), | 207 base::Bind(&ProxyDecryptor::OnSessionError, weak_this), |
| 208 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), | 208 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), |
| 209 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this)); | 209 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this)); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, | 212 void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, |
| 213 MediaKeys::MessageType message_type, | 213 MediaKeys::MessageType message_type, |
| 214 const std::vector<uint8>& message) { | 214 const std::vector<uint8>& message, |
| 215 const GURL& legacy_destination_url) { |
| 215 // Assumes that OnSessionCreated() has been called before this. | 216 // Assumes that OnSessionCreated() has been called before this. |
| 216 | 217 |
| 217 // EME v0.1b gets passed |destination_url| rather than |message_type|. | |
| 218 // Since we have no idea what the URL should be, return an empty one in all | |
| 219 // cases. | |
| 220 | |
| 221 // For ClearKey, convert the message from JSON into just passing the key | 218 // For ClearKey, convert the message from JSON into just passing the key |
| 222 // as the message. If unable to extract the key, return the message unchanged. | 219 // as the message. If unable to extract the key, return the message unchanged. |
| 223 if (is_clear_key_) { | 220 if (is_clear_key_) { |
| 224 std::vector<uint8> key; | 221 std::vector<uint8> key; |
| 225 if (ExtractFirstKeyIdFromLicenseRequest(message, &key)) { | 222 if (ExtractFirstKeyIdFromLicenseRequest(message, &key)) { |
| 226 key_message_cb_.Run(web_session_id, key, GURL()); | 223 key_message_cb_.Run(web_session_id, key, legacy_destination_url); |
| 227 return; | 224 return; |
| 228 } | 225 } |
| 229 } | 226 } |
| 230 | 227 |
| 231 key_message_cb_.Run(web_session_id, message, GURL()); | 228 key_message_cb_.Run(web_session_id, message, legacy_destination_url); |
| 232 } | 229 } |
| 233 | 230 |
| 234 void ProxyDecryptor::OnSessionKeysChange(const std::string& web_session_id, | 231 void ProxyDecryptor::OnSessionKeysChange(const std::string& web_session_id, |
| 235 bool has_additional_usable_key, | 232 bool has_additional_usable_key, |
| 236 CdmKeysInfo keys_info) { | 233 CdmKeysInfo keys_info) { |
| 237 // EME v0.1b doesn't support this event. | 234 // EME v0.1b doesn't support this event. |
| 238 } | 235 } |
| 239 | 236 |
| 240 void ProxyDecryptor::OnSessionExpirationUpdate( | 237 void ProxyDecryptor::OnSessionExpirationUpdate( |
| 241 const std::string& web_session_id, | 238 const std::string& web_session_id, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 bool is_persistent = | 299 bool is_persistent = |
| 303 session_type == PersistentSession || session_type == LoadSession; | 300 session_type == PersistentSession || session_type == LoadSession; |
| 304 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); | 301 active_sessions_.insert(std::make_pair(web_session_id, is_persistent)); |
| 305 | 302 |
| 306 // For LoadSession(), generate the KeyAdded event. | 303 // For LoadSession(), generate the KeyAdded event. |
| 307 if (session_type == LoadSession) | 304 if (session_type == LoadSession) |
| 308 GenerateKeyAdded(web_session_id); | 305 GenerateKeyAdded(web_session_id); |
| 309 } | 306 } |
| 310 | 307 |
| 311 } // namespace media | 308 } // namespace media |
| OLD | NEW |