| 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/blink/webcontentdecryptionmoduleaccess_impl.h" | 5 #include "media/blink/webcontentdecryptionmoduleaccess_impl.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 11 #include "media/blink/webencryptedmediaclient_impl.h" | 11 #include "media/blink/webencryptedmediaclient_impl.h" |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 | 14 |
| 15 // The caller owns the created cdm (passed back using |result|). | 15 // The caller owns the created cdm (passed back using |result|). |
| 16 static void CreateCdm(const base::WeakPtr<WebEncryptedMediaClientImpl>& client, | 16 static void CreateCdm(const base::WeakPtr<WebEncryptedMediaClientImpl>& client, |
| 17 const blink::WebString& key_system, | 17 const blink::WebString& key_system, |
| 18 bool allow_distinctive_identifier, |
| 19 bool allow_persistent_state, |
| 18 const blink::WebSecurityOrigin& security_origin, | 20 const blink::WebSecurityOrigin& security_origin, |
| 19 blink::WebContentDecryptionModuleResult result) { | 21 blink::WebContentDecryptionModuleResult result) { |
| 20 // If |client| is gone (due to the frame getting destroyed), it is | 22 // If |client| is gone (due to the frame getting destroyed), it is |
| 21 // impossible to create the CDM, so fail. | 23 // impossible to create the CDM, so fail. |
| 22 if (!client) { | 24 if (!client) { |
| 23 result.completeWithError( | 25 result.completeWithError( |
| 24 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0, | 26 blink::WebContentDecryptionModuleExceptionInvalidStateError, 0, |
| 25 "Failed to create CDM."); | 27 "Failed to create CDM."); |
| 26 return; | 28 return; |
| 27 } | 29 } |
| 28 | 30 |
| 29 client->CreateCdm(key_system, security_origin, result); | 31 client->CreateCdm(key_system, allow_distinctive_identifier, |
| 32 allow_persistent_state, security_origin, result); |
| 30 } | 33 } |
| 31 | 34 |
| 32 WebContentDecryptionModuleAccessImpl* | 35 WebContentDecryptionModuleAccessImpl* |
| 33 WebContentDecryptionModuleAccessImpl::Create( | 36 WebContentDecryptionModuleAccessImpl::Create( |
| 34 const blink::WebString& key_system, | 37 const blink::WebString& key_system, |
| 35 const blink::WebMediaKeySystemConfiguration& configuration, | 38 const blink::WebMediaKeySystemConfiguration& configuration, |
| 36 const blink::WebSecurityOrigin& security_origin, | 39 const blink::WebSecurityOrigin& security_origin, |
| 37 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) { | 40 const base::WeakPtr<WebEncryptedMediaClientImpl>& client) { |
| 38 return new WebContentDecryptionModuleAccessImpl(key_system, configuration, | 41 return new WebContentDecryptionModuleAccessImpl(key_system, configuration, |
| 39 security_origin, client); | 42 security_origin, client); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 53 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() { | 56 WebContentDecryptionModuleAccessImpl::~WebContentDecryptionModuleAccessImpl() { |
| 54 } | 57 } |
| 55 | 58 |
| 56 blink::WebMediaKeySystemConfiguration | 59 blink::WebMediaKeySystemConfiguration |
| 57 WebContentDecryptionModuleAccessImpl::getConfiguration() { | 60 WebContentDecryptionModuleAccessImpl::getConfiguration() { |
| 58 return configuration_; | 61 return configuration_; |
| 59 } | 62 } |
| 60 | 63 |
| 61 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule( | 64 void WebContentDecryptionModuleAccessImpl::createContentDecryptionModule( |
| 62 blink::WebContentDecryptionModuleResult result) { | 65 blink::WebContentDecryptionModuleResult result) { |
| 66 // Convert the accumulated configuration requirements to bools. Accumulated |
| 67 // configurations never have optional requirements. |
| 68 DCHECK(configuration_.distinctiveIdentifier != |
| 69 blink::WebMediaKeySystemConfiguration::Requirement::Optional); |
| 70 DCHECK(configuration_.persistentState != |
| 71 blink::WebMediaKeySystemConfiguration::Requirement::Optional); |
| 72 bool allow_distinctive_identifier = |
| 73 (configuration_.distinctiveIdentifier == |
| 74 blink::WebMediaKeySystemConfiguration::Requirement::Required); |
| 75 bool allow_persistent_state = |
| 76 (configuration_.persistentState == |
| 77 blink::WebMediaKeySystemConfiguration::Requirement::Required); |
| 78 |
| 63 // This method needs to run asynchronously, as it may need to load the CDM. | 79 // This method needs to run asynchronously, as it may need to load the CDM. |
| 64 // As this object's lifetime is controlled by MediaKeySystemAccess on the | 80 // As this object's lifetime is controlled by MediaKeySystemAccess on the |
| 65 // blink side, copy all values needed by CreateCdm() in case the blink object | 81 // blink side, copy all values needed by CreateCdm() in case the blink object |
| 66 // gets garbage-collected. | 82 // gets garbage-collected. |
| 67 base::MessageLoopProxy::current()->PostTask( | 83 base::MessageLoopProxy::current()->PostTask( |
| 68 FROM_HERE, | 84 FROM_HERE, |
| 69 base::Bind(&CreateCdm, client_, key_system_, security_origin_, result)); | 85 base::Bind(&CreateCdm, client_, key_system_, allow_distinctive_identifier, |
| 86 allow_persistent_state, security_origin_, result)); |
| 70 } | 87 } |
| 71 | 88 |
| 72 } // namespace media | 89 } // namespace media |
| OLD | NEW |