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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "media/base/cdm_callback_promise.h" | 14 #include "media/base/cdm_callback_promise.h" |
15 #include "media/base/cdm_config.h" | |
16 #include "media/base/cdm_factory.h" | 15 #include "media/base/cdm_factory.h" |
17 #include "media/base/cdm_key_information.h" | 16 #include "media/base/cdm_key_information.h" |
18 #include "media/base/key_systems.h" | 17 #include "media/base/key_systems.h" |
19 #include "media/base/media_permission.h" | 18 #include "media/base/media_permission.h" |
20 #include "media/cdm/json_web_key.h" | 19 #include "media/cdm/json_web_key.h" |
21 #include "media/cdm/key_system_names.h" | 20 #include "media/cdm/key_system_names.h" |
22 | 21 |
23 namespace media { | 22 namespace media { |
24 | 23 |
25 // Special system code to signal a closed persistent session in a SessionError() | 24 // Special system code to signal a closed persistent session in a SessionError() |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const std::string& key_system, | 62 const std::string& key_system, |
64 const GURL& security_origin, | 63 const GURL& security_origin, |
65 const CdmContextReadyCB& cdm_context_ready_cb) { | 64 const CdmContextReadyCB& cdm_context_ready_cb) { |
66 DVLOG(1) << __FUNCTION__ << ": key_system = " << key_system; | 65 DVLOG(1) << __FUNCTION__ << ": key_system = " << key_system; |
67 DCHECK(!is_creating_cdm_); | 66 DCHECK(!is_creating_cdm_); |
68 DCHECK(!media_keys_); | 67 DCHECK(!media_keys_); |
69 | 68 |
70 // TODO(sandersd): Trigger permissions check here and use it to determine | 69 // TODO(sandersd): Trigger permissions check here and use it to determine |
71 // distinctive identifier support, instead of always requiring the | 70 // distinctive identifier support, instead of always requiring the |
72 // permission. http://crbug.com/455271 | 71 // permission. http://crbug.com/455271 |
73 CdmConfig cdm_config; | 72 bool allow_distinctive_identifier = true; |
74 cdm_config.allow_distinctive_identifier = true; | 73 bool allow_persistent_state = true; |
75 cdm_config.allow_persistent_state = true; | |
76 | 74 |
77 is_creating_cdm_ = true; | 75 is_creating_cdm_ = true; |
78 | 76 |
79 base::WeakPtr<ProxyDecryptor> weak_this = weak_ptr_factory_.GetWeakPtr(); | 77 base::WeakPtr<ProxyDecryptor> weak_this = weak_ptr_factory_.GetWeakPtr(); |
80 cdm_factory->Create( | 78 cdm_factory->Create( |
81 key_system, security_origin, cdm_config, | 79 key_system, allow_distinctive_identifier, allow_persistent_state, |
82 base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), | 80 security_origin, base::Bind(&ProxyDecryptor::OnSessionMessage, weak_this), |
83 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), | 81 base::Bind(&ProxyDecryptor::OnSessionClosed, weak_this), |
84 base::Bind(&ProxyDecryptor::OnLegacySessionError, weak_this), | 82 base::Bind(&ProxyDecryptor::OnLegacySessionError, weak_this), |
85 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), | 83 base::Bind(&ProxyDecryptor::OnSessionKeysChange, weak_this), |
86 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this), | 84 base::Bind(&ProxyDecryptor::OnSessionExpirationUpdate, weak_this), |
87 base::Bind(&ProxyDecryptor::OnCdmCreated, weak_this, key_system, | 85 base::Bind(&ProxyDecryptor::OnCdmCreated, weak_this, key_system, |
88 security_origin, cdm_context_ready_cb)); | 86 security_origin, cdm_context_ready_cb)); |
89 } | 87 } |
90 | 88 |
91 void ProxyDecryptor::OnCdmCreated(const std::string& key_system, | 89 void ProxyDecryptor::OnCdmCreated(const std::string& key_system, |
92 const GURL& security_origin, | 90 const GURL& security_origin, |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 bool is_persistent = | 388 bool is_persistent = |
391 session_type == PersistentSession || session_type == LoadSession; | 389 session_type == PersistentSession || session_type == LoadSession; |
392 active_sessions_.insert(std::make_pair(session_id, is_persistent)); | 390 active_sessions_.insert(std::make_pair(session_id, is_persistent)); |
393 | 391 |
394 // For LoadSession(), generate the KeyAdded event. | 392 // For LoadSession(), generate the KeyAdded event. |
395 if (session_type == LoadSession) | 393 if (session_type == LoadSession) |
396 GenerateKeyAdded(session_id); | 394 GenerateKeyAdded(session_id); |
397 } | 395 } |
398 | 396 |
399 } // namespace media | 397 } // namespace media |
OLD | NEW |