Chromium Code Reviews| Index: media/cdm/ppapi/cdm_adapter.cc |
| diff --git a/media/cdm/ppapi/cdm_adapter.cc b/media/cdm/ppapi/cdm_adapter.cc |
| index c0a39a56d2faa7610cb612e92f1bd12e3bdb1ffc..c3d3c2cdb2df60f3048be2ab698b272332a0132b 100644 |
| --- a/media/cdm/ppapi/cdm_adapter.cc |
| +++ b/media/cdm/ppapi/cdm_adapter.cc |
| @@ -302,6 +302,8 @@ CdmAdapter::CdmAdapter(PP_Instance instance, pp::Module* module) |
| #endif |
| allocator_(this), |
| cdm_(NULL), |
| + allow_distinctive_identifier_(false), |
| + allow_persistent_state_(false), |
| deferred_initialize_audio_decoder_(false), |
| deferred_audio_decoder_config_id_(0), |
| deferred_initialize_video_decoder_(false), |
| @@ -334,10 +336,13 @@ bool CdmAdapter::CreateCdmInstance(const std::string& key_system) { |
| // (CreateSession()) or session loading (LoadSession()). |
| // TODO(xhwang): If necessary, we need to store the error here if we want to |
| // support more specific error reporting (other than "Unknown"). |
| -void CdmAdapter::Initialize(const std::string& key_system) { |
| +void CdmAdapter::Initialize(const std::string& key_system, |
| + bool allow_distinctive_identifier, |
| + bool allow_persistent_state) { |
| PP_DCHECK(!key_system.empty()); |
| PP_DCHECK(key_system_.empty() || (key_system_ == key_system && cdm_)); |
| + |
|
jrummell
2015/03/06 21:40:47
nit: I don't think 2 blank lines are needed.
ddorwin
2015/03/06 21:42:54
remove
sandersd (OOO until July 31)
2015/03/06 22:36:58
Done.
|
| #if defined(CHECK_DOCUMENT_URL) |
| PP_URLComponents_Dev url_components = {}; |
| const pp::URLUtil_Dev* url_util = pp::URLUtil_Dev::Get(); |
| @@ -362,6 +367,8 @@ void CdmAdapter::Initialize(const std::string& key_system) { |
| PP_DCHECK(cdm_); |
| key_system_ = key_system; |
| + allow_distinctive_identifier_ = allow_distinctive_identifier; |
| + allow_persistent_state_ = allow_persistent_state; |
| } |
| void CdmAdapter::SetServerCertificate(uint32_t promise_id, |
| @@ -1106,29 +1113,34 @@ void CdmAdapter::SendPlatformChallenge(const char* service_id, |
| const char* challenge, |
| uint32_t challenge_size) { |
| #if defined(OS_CHROMEOS) |
| - pp::VarArrayBuffer challenge_var(challenge_size); |
| - uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); |
| - memcpy(var_data, challenge, challenge_size); |
| - |
| - std::string service_id_str(service_id, service_id_size); |
| - |
| - linked_ptr<PepperPlatformChallengeResponse> response( |
| - new PepperPlatformChallengeResponse()); |
| - |
| - int32_t result = platform_verification_.ChallengePlatform( |
| - pp::Var(service_id_str), |
| - challenge_var, |
| - &response->signed_data, |
| - &response->signed_data_signature, |
| - &response->platform_key_certificate, |
| - callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone, |
| - response)); |
| - challenge_var.Unmap(); |
| - if (result == PP_OK_COMPLETIONPENDING) |
| - return; |
| + // If access to a distinctive identifier is not allowed, prevent platform |
| + // verification so that no distinctive identifier will be available in the |
|
ddorwin
2015/03/06 21:42:54
... verification to prevent access to such an iden
sandersd (OOO until July 31)
2015/03/06 22:36:58
Done.
|
| + // first place. |
| + if (allow_distinctive_identifier_) { |
| + pp::VarArrayBuffer challenge_var(challenge_size); |
| + uint8_t* var_data = static_cast<uint8_t*>(challenge_var.Map()); |
| + memcpy(var_data, challenge, challenge_size); |
| + |
| + std::string service_id_str(service_id, service_id_size); |
| + |
| + linked_ptr<PepperPlatformChallengeResponse> response( |
| + new PepperPlatformChallengeResponse()); |
| + |
| + int32_t result = platform_verification_.ChallengePlatform( |
| + pp::Var(service_id_str), |
| + challenge_var, |
| + &response->signed_data, |
| + &response->signed_data_signature, |
| + &response->platform_key_certificate, |
| + callback_factory_.NewCallback(&CdmAdapter::SendPlatformChallengeDone, |
| + response)); |
| + challenge_var.Unmap(); |
| + if (result == PP_OK_COMPLETIONPENDING) |
| + return; |
| - // Fall through on error and issue an empty OnPlatformChallengeResponse(). |
| - PP_DCHECK(result != PP_OK); |
| + // Fall through on error and issue an empty OnPlatformChallengeResponse(). |
| + PP_DCHECK(result != PP_OK); |
| + } |
| #endif |
| cdm::PlatformChallengeResponse platform_challenge_response = {}; |
| @@ -1200,10 +1212,14 @@ void CdmAdapter::OnDeferredInitializationDone(cdm::StreamType stream_type, |
| // The CDM owns the returned object and must call FileIO::Close() to release it. |
| cdm::FileIO* CdmAdapter::CreateFileIO(cdm::FileIOClient* client) { |
| - return new CdmFileIOImpl( |
| - client, |
| - pp_instance(), |
| - callback_factory_.NewCallback(&CdmAdapter::OnFirstFileRead)); |
| + if (allow_persistent_state_) { |
| + return new CdmFileIOImpl( |
| + client, |
| + pp_instance(), |
| + callback_factory_.NewCallback(&CdmAdapter::OnFirstFileRead)); |
| + } |
| + |
| + return nullptr; |
| } |
| #if defined(OS_CHROMEOS) |