| 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 "webcontentdecryptionmodule_impl.h" | 5 #include "webcontentdecryptionmodule_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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "media/base/cdm_promise.h" | 13 #include "media/base/cdm_promise.h" |
| 14 #include "media/base/key_systems.h" | 14 #include "media/base/key_systems.h" |
| 15 #include "media/base/media_keys.h" | 15 #include "media/base/media_keys.h" |
| 16 #include "media/blink/cdm_result_promise.h" | 16 #include "media/blink/cdm_result_promise.h" |
| 17 #include "media/blink/cdm_session_adapter.h" | 17 #include "media/blink/cdm_session_adapter.h" |
| 18 #include "media/blink/webcontentdecryptionmodulesession_impl.h" | 18 #include "media/blink/webcontentdecryptionmodulesession_impl.h" |
| 19 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
| 20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 namespace media { | 23 namespace media { |
| 24 | 24 |
| 25 void WebContentDecryptionModuleImpl::Create( | 25 void WebContentDecryptionModuleImpl::Create( |
| 26 media::CdmFactory* cdm_factory, | 26 media::CdmFactory* cdm_factory, |
| 27 const base::string16& key_system, |
| 28 bool allow_distinctive_identifier, |
| 29 bool allow_persistent_state, |
| 27 const blink::WebSecurityOrigin& security_origin, | 30 const blink::WebSecurityOrigin& security_origin, |
| 28 const base::string16& key_system, | |
| 29 blink::WebContentDecryptionModuleResult result) { | 31 blink::WebContentDecryptionModuleResult result) { |
| 30 DCHECK(!security_origin.isNull()); | 32 DCHECK(!security_origin.isNull()); |
| 31 DCHECK(!key_system.empty()); | 33 DCHECK(!key_system.empty()); |
| 32 | 34 |
| 33 // TODO(ddorwin): Guard against this in supported types check and remove this. | 35 // TODO(ddorwin): Guard against this in supported types check and remove this. |
| 34 // Chromium only supports ASCII key systems. | 36 // Chromium only supports ASCII key systems. |
| 35 if (!base::IsStringASCII(key_system)) { | 37 if (!base::IsStringASCII(key_system)) { |
| 36 NOTREACHED(); | 38 NOTREACHED(); |
| 37 result.completeWithError( | 39 result.completeWithError( |
| 38 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | 40 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 58 "CDM use not allowed for unique security origin."); | 60 "CDM use not allowed for unique security origin."); |
| 59 return; | 61 return; |
| 60 } | 62 } |
| 61 | 63 |
| 62 GURL security_origin_as_gurl(security_origin.toString()); | 64 GURL security_origin_as_gurl(security_origin.toString()); |
| 63 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); | 65 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); |
| 64 | 66 |
| 65 // TODO(jrummell): Pass WebContentDecryptionModuleResult (or similar) to | 67 // TODO(jrummell): Pass WebContentDecryptionModuleResult (or similar) to |
| 66 // Initialize() so that more specific errors can be reported. | 68 // Initialize() so that more specific errors can be reported. |
| 67 if (!adapter->Initialize(cdm_factory, key_system_ascii, | 69 if (!adapter->Initialize(cdm_factory, key_system_ascii, |
| 68 security_origin_as_gurl)) { | 70 allow_distinctive_identifier, |
| 71 allow_persistent_state, security_origin_as_gurl)) { |
| 69 result.completeWithError( | 72 result.completeWithError( |
| 70 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | 73 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, |
| 71 "Failed to initialize CDM."); | 74 "Failed to initialize CDM."); |
| 72 return; | 75 return; |
| 73 } | 76 } |
| 74 | 77 |
| 75 result.completeWithContentDecryptionModule( | 78 result.completeWithContentDecryptionModule( |
| 76 new WebContentDecryptionModuleImpl(adapter)); | 79 new WebContentDecryptionModuleImpl(adapter)); |
| 77 } | 80 } |
| 78 | 81 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 100 base::saturated_cast<int>(server_certificate_length), | 103 base::saturated_cast<int>(server_certificate_length), |
| 101 scoped_ptr<SimpleCdmPromise>( | 104 scoped_ptr<SimpleCdmPromise>( |
| 102 new CdmResultPromise<>(result, std::string()))); | 105 new CdmResultPromise<>(result, std::string()))); |
| 103 } | 106 } |
| 104 | 107 |
| 105 CdmContext* WebContentDecryptionModuleImpl::GetCdmContext() { | 108 CdmContext* WebContentDecryptionModuleImpl::GetCdmContext() { |
| 106 return adapter_->GetCdmContext(); | 109 return adapter_->GetCdmContext(); |
| 107 } | 110 } |
| 108 | 111 |
| 109 } // namespace media | 112 } // namespace media |
| OLD | NEW |