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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // No permission required when AesDecryptor is used or when the key system is | 127 // No permission required when AesDecryptor is used or when the key system is |
128 // external clear key. | 128 // external clear key. |
129 DCHECK(!key_system_.empty()); | 129 DCHECK(!key_system_.empty()); |
130 if (CanUseAesDecryptor(key_system_) || IsExternalClearKey(key_system_)) { | 130 if (CanUseAesDecryptor(key_system_) || IsExternalClearKey(key_system_)) { |
131 OnPermissionStatus(session_type, init_data_type, init_data_vector, | 131 OnPermissionStatus(session_type, init_data_type, init_data_vector, |
132 promise.Pass(), true /* granted */); | 132 promise.Pass(), true /* granted */); |
133 return true; | 133 return true; |
134 } | 134 } |
135 | 135 |
136 #if defined(OS_CHROMEOS) | 136 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
137 media_permission_->RequestPermission( | 137 media_permission_->RequestPermission( |
138 MediaPermission::PROTECTED_MEDIA_IDENTIFIER, security_origin_, | 138 MediaPermission::PROTECTED_MEDIA_IDENTIFIER, security_origin_, |
139 base::Bind(&ProxyDecryptor::OnPermissionStatus, | 139 base::Bind(&ProxyDecryptor::OnPermissionStatus, |
140 weak_ptr_factory_.GetWeakPtr(), session_type, init_data_type, | 140 weak_ptr_factory_.GetWeakPtr(), session_type, init_data_type, |
141 init_data_vector, base::Passed(&promise))); | 141 init_data_vector, base::Passed(&promise))); |
142 #else | 142 #else |
143 // TODO(xhwang): Fix the Android path by requesting permission for key systems | |
144 // that don't use AesDecryptor in M43. | |
145 OnPermissionStatus(session_type, init_data_type, init_data_vector, | 143 OnPermissionStatus(session_type, init_data_type, init_data_vector, |
146 promise.Pass(), true /* granted */); | 144 promise.Pass(), true /* granted */); |
147 #endif | 145 #endif |
148 | 146 |
149 return true; | 147 return true; |
150 } | 148 } |
151 | 149 |
152 void ProxyDecryptor::OnPermissionStatus( | 150 void ProxyDecryptor::OnPermissionStatus( |
153 MediaKeys::SessionType session_type, | 151 MediaKeys::SessionType session_type, |
154 const std::string& init_data_type, | 152 const std::string& init_data_type, |
155 const std::vector<uint8>& init_data, | 153 const std::vector<uint8>& init_data, |
156 scoped_ptr<NewSessionCdmPromise> promise, | 154 scoped_ptr<NewSessionCdmPromise> promise, |
157 bool granted) { | 155 bool granted) { |
158 // ProxyDecryptor is only used by Prefixed EME, where RequestPermission() is | 156 // ProxyDecryptor is only used by Prefixed EME, where RequestPermission() is |
159 // only for triggering the permission UI. Later CheckPermission() will be | 157 // only for triggering the permission UI. Later CheckPermission() will be |
160 // called (e.g. in PlatformVerificationFlow) and the permission status will be | 158 // called (e.g. in PlatformVerificationFlow on ChromeOS; in BrowserCdmManager |
161 // evaluated there. | 159 // on Android) and the permission status will be evaluated then. |
162 DVLOG_IF(1, !granted) << "Permission request rejected."; | 160 DVLOG_IF(1, !granted) << "Permission request rejected."; |
163 | 161 |
164 const uint8* init_data_vector_data = | 162 const uint8* init_data_vector_data = |
165 (init_data.size() > 0) ? &init_data[0] : nullptr; | 163 (init_data.size() > 0) ? &init_data[0] : nullptr; |
166 | 164 |
167 media_keys_->CreateSessionAndGenerateRequest( | 165 media_keys_->CreateSessionAndGenerateRequest( |
168 session_type, init_data_type, init_data_vector_data, init_data.size(), | 166 session_type, init_data_type, init_data_vector_data, init_data.size(), |
169 promise.Pass()); | 167 promise.Pass()); |
170 } | 168 } |
171 | 169 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 bool is_persistent = | 344 bool is_persistent = |
347 session_type == PersistentSession || session_type == LoadSession; | 345 session_type == PersistentSession || session_type == LoadSession; |
348 active_sessions_.insert(std::make_pair(session_id, is_persistent)); | 346 active_sessions_.insert(std::make_pair(session_id, is_persistent)); |
349 | 347 |
350 // For LoadSession(), generate the KeyAdded event. | 348 // For LoadSession(), generate the KeyAdded event. |
351 if (session_type == LoadSession) | 349 if (session_type == LoadSession) |
352 GenerateKeyAdded(session_id); | 350 GenerateKeyAdded(session_id); |
353 } | 351 } |
354 | 352 |
355 } // namespace media | 353 } // namespace media |
OLD | NEW |