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 "content/renderer/media/webcontentdecryptionmodule_impl.h" | 5 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "content/renderer/media/cdm_session_adapter.h" | 15 #include "content/renderer/media/cdm_session_adapter.h" |
16 #include "content/renderer/media/crypto/key_systems.h" | 16 #include "content/renderer/media/crypto/key_systems.h" |
17 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" | 17 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
| 18 #include "media/base/cdm_promise.h" |
18 #include "media/base/media_keys.h" | 19 #include "media/base/media_keys.h" |
19 #include "third_party/WebKit/public/platform/WebString.h" | 20 #include "third_party/WebKit/public/platform/WebString.h" |
20 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 21 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 | 23 |
23 #if defined(ENABLE_PEPPER_CDMS) | 24 #if defined(ENABLE_PEPPER_CDMS) |
24 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" | 25 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" |
25 #endif | 26 #endif |
26 | 27 |
27 namespace content { | 28 namespace content { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 key_system_ascii, | 72 key_system_ascii, |
72 security_origin_as_gurl)) { | 73 security_origin_as_gurl)) { |
73 return NULL; | 74 return NULL; |
74 } | 75 } |
75 | 76 |
76 return new WebContentDecryptionModuleImpl(adapter); | 77 return new WebContentDecryptionModuleImpl(adapter); |
77 } | 78 } |
78 | 79 |
79 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( | 80 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( |
80 scoped_refptr<CdmSessionAdapter> adapter) | 81 scoped_refptr<CdmSessionAdapter> adapter) |
81 : adapter_(adapter) {} | 82 : adapter_(adapter), weak_ptr_factory_(this) { |
| 83 } |
82 | 84 |
83 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { | 85 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { |
84 } | 86 } |
85 | 87 |
86 // The caller owns the created session. | 88 // The caller owns the created session. |
87 blink::WebContentDecryptionModuleSession* | 89 blink::WebContentDecryptionModuleSession* |
88 WebContentDecryptionModuleImpl::createSession() { | 90 WebContentDecryptionModuleImpl::createSession() { |
89 return adapter_->CreateSession(); | 91 return adapter_->CreateSession(); |
90 } | 92 } |
91 | 93 |
92 blink::WebContentDecryptionModuleSession* | 94 blink::WebContentDecryptionModuleSession* |
93 WebContentDecryptionModuleImpl::createSession( | 95 WebContentDecryptionModuleImpl::createSession( |
94 blink::WebContentDecryptionModuleSession::Client* client) { | 96 blink::WebContentDecryptionModuleSession::Client* client) { |
95 WebContentDecryptionModuleSessionImpl* session = adapter_->CreateSession(); | 97 WebContentDecryptionModuleSessionImpl* session = adapter_->CreateSession(); |
96 session->setClientInterface(client); | 98 session->setClientInterface(client); |
97 return session; | 99 return session; |
98 } | 100 } |
99 | 101 |
| 102 void WebContentDecryptionModuleImpl::setServerCertificate( |
| 103 const uint8* server_certificate, |
| 104 size_t server_certificate_length, |
| 105 blink::WebContentDecryptionModuleResult result) { |
| 106 DCHECK(server_certificate); |
| 107 scoped_ptr<media::SimpleCdmPromise> promise = |
| 108 outstanding_results_.CreateSimpleCdmPromise(result); |
| 109 adapter_->SetServerCertificate( |
| 110 server_certificate, server_certificate_length, promise.Pass()); |
| 111 } |
| 112 |
100 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { | 113 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { |
101 return adapter_->GetDecryptor(); | 114 return adapter_->GetDecryptor(); |
102 } | 115 } |
103 | 116 |
104 #if defined(ENABLE_BROWSER_CDMS) | 117 #if defined(ENABLE_BROWSER_CDMS) |
105 int WebContentDecryptionModuleImpl::GetCdmId() const { | 118 int WebContentDecryptionModuleImpl::GetCdmId() const { |
106 return adapter_->GetCdmId(); | 119 return adapter_->GetCdmId(); |
107 } | 120 } |
108 #endif // defined(ENABLE_BROWSER_CDMS) | 121 #endif // defined(ENABLE_BROWSER_CDMS) |
109 | 122 |
110 } // namespace content | 123 } // namespace content |
OLD | NEW |