| 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 "content/renderer/media/cdm_session_adapter.h" | 15 #include "content/renderer/media/cdm_session_adapter.h" |
| 15 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" | 16 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
| 16 #include "media/base/media_keys.h" | 17 #include "media/base/media_keys.h" |
| 17 | 18 |
| 18 #if defined(ENABLE_PEPPER_CDMS) | 19 #if defined(ENABLE_PEPPER_CDMS) |
| 19 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" | 20 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 namespace content { | 23 namespace content { |
| 23 | 24 |
| 24 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( | 25 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( |
| 25 const base::string16& key_system) { | 26 const base::string16& key_system) { |
| 26 // TODO(ddorwin): Guard against this in supported types check and remove this. | 27 // TODO(ddorwin): Guard against this in supported types check and remove this. |
| 27 // Chromium only supports ASCII key systems. | 28 // Chromium only supports ASCII key systems. |
| 28 if (!IsStringASCII(key_system)) { | 29 if (!IsStringASCII(key_system)) { |
| 29 NOTREACHED(); | 30 NOTREACHED(); |
| 30 return NULL; | 31 return NULL; |
| 31 } | 32 } |
| 32 | 33 |
| 33 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); | 34 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); |
| 34 if (!adapter->Initialize( | 35 if (!adapter->Initialize( |
| 35 #if defined(ENABLE_PEPPER_CDMS) | 36 #if defined(ENABLE_PEPPER_CDMS) |
| 36 // TODO(jrummell): Figure out how to get a WebFrame from Blink (or | 37 // TODO(jrummell): Figure out how to get a WebFrame from Blink (or |
| 37 // something equivalent) so the plugin can actually get created. | 38 // something equivalent) so the plugin can actually get created. |
| 38 // http://crbug.com/250049 | 39 // http://crbug.com/250049 |
| 39 base::Bind(&PepperCdmWrapperImpl::Create, | 40 base::Bind(&PepperCdmWrapperImpl::Create, |
| 40 static_cast<blink::WebFrame*>(NULL)), | 41 static_cast<blink::WebFrame*>(NULL)), |
| 41 #endif | 42 #endif |
| 42 UTF16ToASCII(key_system))) { | 43 base::UTF16ToASCII(key_system))) { |
| 43 return NULL; | 44 return NULL; |
| 44 } | 45 } |
| 45 | 46 |
| 46 return new WebContentDecryptionModuleImpl(adapter); | 47 return new WebContentDecryptionModuleImpl(adapter); |
| 47 } | 48 } |
| 48 | 49 |
| 49 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( | 50 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( |
| 50 scoped_refptr<CdmSessionAdapter> adapter) | 51 scoped_refptr<CdmSessionAdapter> adapter) |
| 51 : adapter_(adapter) { | 52 : adapter_(adapter) { |
| 52 } | 53 } |
| 53 | 54 |
| 54 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { | 55 WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() { |
| 55 } | 56 } |
| 56 | 57 |
| 57 // The caller owns the created session. | 58 // The caller owns the created session. |
| 58 blink::WebContentDecryptionModuleSession* | 59 blink::WebContentDecryptionModuleSession* |
| 59 WebContentDecryptionModuleImpl::createSession( | 60 WebContentDecryptionModuleImpl::createSession( |
| 60 blink::WebContentDecryptionModuleSession::Client* client) { | 61 blink::WebContentDecryptionModuleSession::Client* client) { |
| 61 return adapter_->CreateSession(client); | 62 return adapter_->CreateSession(client); |
| 62 } | 63 } |
| 63 | 64 |
| 64 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { | 65 media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() { |
| 65 return adapter_->GetDecryptor(); | 66 return adapter_->GetDecryptor(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace content | 69 } // namespace content |
| OLD | NEW |