| 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/webcontentdecryptionmodule_impl.h" | 5 #include "media/blink/webcontentdecryptionmodule_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "media/base/cdm_promise.h" | 14 #include "media/base/cdm_promise.h" |
| 15 #include "media/base/key_systems.h" | 15 #include "media/base/key_systems.h" |
| 16 #include "media/base/media_keys.h" | 16 #include "media/base/media_keys.h" |
| 17 #include "media/blink/cdm_result_promise.h" | 17 #include "media/blink/cdm_result_promise.h" |
| 18 #include "media/blink/cdm_session_adapter.h" | 18 #include "media/blink/cdm_session_adapter.h" |
| 19 #include "media/blink/webcontentdecryptionmodulesession_impl.h" | 19 #include "media/blink/webcontentdecryptionmodulesession_impl.h" |
| 20 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 20 #include "third_party/WebKit/public/platform/WebString.h" | 21 #include "third_party/WebKit/public/platform/WebString.h" |
| 21 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 22 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
| 23 | 24 |
| 24 namespace media { | 25 namespace media { |
| 25 | 26 |
| 26 void WebContentDecryptionModuleImpl::Create( | 27 void WebContentDecryptionModuleImpl::Create( |
| 27 media::CdmFactory* cdm_factory, | 28 media::CdmFactory* cdm_factory, |
| 28 const base::string16& key_system, | 29 const base::string16& key_system, |
| 29 const blink::WebSecurityOrigin& security_origin, | 30 const blink::WebSecurityOrigin& security_origin, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 55 } | 56 } |
| 56 | 57 |
| 57 // If unique security origin, don't try to create the CDM. | 58 // If unique security origin, don't try to create the CDM. |
| 58 if (security_origin.isUnique() || security_origin.toString() == "null") { | 59 if (security_origin.isUnique() || security_origin.toString() == "null") { |
| 59 result->completeWithError( | 60 result->completeWithError( |
| 60 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, | 61 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, |
| 61 "EME use is not allowed on unique origins."); | 62 "EME use is not allowed on unique origins."); |
| 62 return; | 63 return; |
| 63 } | 64 } |
| 64 | 65 |
| 65 GURL security_origin_as_gurl(security_origin.toString()); | 66 GURL security_origin_as_gurl( |
| 67 blink::WebStringToGURL(security_origin.toString())); |
| 66 | 68 |
| 67 // CdmSessionAdapter::CreateCdm() will keep a reference to |adapter|. Then | 69 // CdmSessionAdapter::CreateCdm() will keep a reference to |adapter|. Then |
| 68 // if WebContentDecryptionModuleImpl is successfully created (returned in | 70 // if WebContentDecryptionModuleImpl is successfully created (returned in |
| 69 // |result|), it will keep a reference to |adapter|. Otherwise, |adapter| will | 71 // |result|), it will keep a reference to |adapter|. Otherwise, |adapter| will |
| 70 // be destructed. | 72 // be destructed. |
| 71 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); | 73 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); |
| 72 adapter->CreateCdm(cdm_factory, key_system_ascii, security_origin_as_gurl, | 74 adapter->CreateCdm(cdm_factory, key_system_ascii, security_origin_as_gurl, |
| 73 cdm_config, std::move(result)); | 75 cdm_config, std::move(result)); |
| 74 } | 76 } |
| 75 | 77 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 97 server_certificate + server_certificate_length), | 99 server_certificate + server_certificate_length), |
| 98 scoped_ptr<SimpleCdmPromise>( | 100 scoped_ptr<SimpleCdmPromise>( |
| 99 new CdmResultPromise<>(result, std::string()))); | 101 new CdmResultPromise<>(result, std::string()))); |
| 100 } | 102 } |
| 101 | 103 |
| 102 CdmContext* WebContentDecryptionModuleImpl::GetCdmContext() { | 104 CdmContext* WebContentDecryptionModuleImpl::GetCdmContext() { |
| 103 return adapter_->GetCdmContext(); | 105 return adapter_->GetCdmContext(); |
| 104 } | 106 } |
| 105 | 107 |
| 106 } // namespace media | 108 } // namespace media |
| OLD | NEW |