| 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 <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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 base::Bind(&ProxyDecryptor::OnSessionClosed, | 223 base::Bind(&ProxyDecryptor::OnSessionClosed, |
| 224 weak_ptr_factory_.GetWeakPtr()), | 224 weak_ptr_factory_.GetWeakPtr()), |
| 225 base::Bind(&ProxyDecryptor::OnSessionError, | 225 base::Bind(&ProxyDecryptor::OnSessionError, |
| 226 weak_ptr_factory_.GetWeakPtr())); | 226 weak_ptr_factory_.GetWeakPtr())); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, | 229 void ProxyDecryptor::OnSessionMessage(const std::string& web_session_id, |
| 230 const std::vector<uint8>& message, | 230 const std::vector<uint8>& message, |
| 231 const GURL& destination_url) { | 231 const GURL& destination_url) { |
| 232 // Assumes that OnSessionCreated() has been called before this. | 232 // Assumes that OnSessionCreated() has been called before this. |
| 233 |
| 234 // For ClearKey, convert the message from JSON into just passing the key |
| 235 // as the message. If unable to extract the key, return the message unchanged. |
| 236 if (is_clear_key_) { |
| 237 std::vector<uint8> key; |
| 238 if (media::ExtractLicenseKey(message, key)) { |
| 239 key_message_cb_.Run(web_session_id, key, destination_url); |
| 240 return; |
| 241 } |
| 242 } |
| 243 |
| 233 key_message_cb_.Run(web_session_id, message, destination_url); | 244 key_message_cb_.Run(web_session_id, message, destination_url); |
| 234 } | 245 } |
| 235 | 246 |
| 236 void ProxyDecryptor::OnSessionReady(const std::string& web_session_id) { | 247 void ProxyDecryptor::OnSessionReady(const std::string& web_session_id) { |
| 237 key_added_cb_.Run(web_session_id); | 248 key_added_cb_.Run(web_session_id); |
| 238 } | 249 } |
| 239 | 250 |
| 240 void ProxyDecryptor::OnSessionClosed(const std::string& web_session_id) { | 251 void ProxyDecryptor::OnSessionClosed(const std::string& web_session_id) { |
| 241 base::hash_map<std::string, bool>::iterator it = | 252 base::hash_map<std::string, bool>::iterator it = |
| 242 active_sessions_.find(web_session_id); | 253 active_sessions_.find(web_session_id); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 296 } |
| 286 key_error_cb_.Run(web_session_id, error_code, system_code); | 297 key_error_cb_.Run(web_session_id, error_code, system_code); |
| 287 } | 298 } |
| 288 | 299 |
| 289 void ProxyDecryptor::SetSessionId(bool persistent, | 300 void ProxyDecryptor::SetSessionId(bool persistent, |
| 290 const std::string& web_session_id) { | 301 const std::string& web_session_id) { |
| 291 active_sessions_.insert(std::make_pair(web_session_id, persistent)); | 302 active_sessions_.insert(std::make_pair(web_session_id, persistent)); |
| 292 } | 303 } |
| 293 | 304 |
| 294 } // namespace content | 305 } // namespace content |
| OLD | NEW |