| 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/crypto/content_decryption_module_factory.h" | 5 #include "content/renderer/media/crypto/content_decryption_module_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/renderer/media/crypto/key_systems.h" | 8 #include "content/renderer/media/crypto/key_systems.h" |
| 9 #include "media/cdm/aes_decryptor.h" | 9 #include "media/cdm/aes_decryptor.h" |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #endif // defined(ENABLE_PEPPER_CDMS) | 21 #endif // defined(ENABLE_PEPPER_CDMS) |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 #if defined(ENABLE_PEPPER_CDMS) | 25 #if defined(ENABLE_PEPPER_CDMS) |
| 26 // Returns the PepperPluginInstanceImpl associated with the Helper Plugin. | 26 // Returns the PepperPluginInstanceImpl associated with the Helper Plugin. |
| 27 // If a non-NULL pointer is returned, the caller must call | 27 // If a non-NULL pointer is returned, the caller must call |
| 28 // closeHelperPluginSoon() when the Helper Plugin is no longer needed. | 28 // closeHelperPluginSoon() when the Helper Plugin is no longer needed. |
| 29 static scoped_refptr<PepperPluginInstanceImpl> CreateHelperPlugin( | 29 static scoped_refptr<PepperPluginInstanceImpl> CreateHelperPlugin( |
| 30 const std::string& plugin_type, | 30 const std::string& plugin_type, |
| 31 WebKit::WebMediaPlayerClient* web_media_player_client, | 31 blink::WebMediaPlayerClient* web_media_player_client, |
| 32 WebKit::WebFrame* web_frame) { | 32 blink::WebFrame* web_frame) { |
| 33 DCHECK(web_media_player_client); | 33 DCHECK(web_media_player_client); |
| 34 DCHECK(web_frame); | 34 DCHECK(web_frame); |
| 35 | 35 |
| 36 WebKit::WebPlugin* web_plugin = web_media_player_client->createHelperPlugin( | 36 blink::WebPlugin* web_plugin = web_media_player_client->createHelperPlugin( |
| 37 WebKit::WebString::fromUTF8(plugin_type), web_frame); | 37 blink::WebString::fromUTF8(plugin_type), web_frame); |
| 38 if (!web_plugin) | 38 if (!web_plugin) |
| 39 return NULL; | 39 return NULL; |
| 40 | 40 |
| 41 DCHECK(!web_plugin->isPlaceholder()); // Prevented by Blink. | 41 DCHECK(!web_plugin->isPlaceholder()); // Prevented by Blink. |
| 42 // Only Pepper plugins are supported, so it must be a ppapi object. | 42 // Only Pepper plugins are supported, so it must be a ppapi object. |
| 43 PepperWebPluginImpl* ppapi_plugin = | 43 PepperWebPluginImpl* ppapi_plugin = |
| 44 static_cast<PepperWebPluginImpl*>(web_plugin); | 44 static_cast<PepperWebPluginImpl*>(web_plugin); |
| 45 return ppapi_plugin->instance(); | 45 return ppapi_plugin->instance(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 static scoped_ptr<media::MediaKeys> CreatePpapiDecryptor( | 48 static scoped_ptr<media::MediaKeys> CreatePpapiDecryptor( |
| 49 const std::string& key_system, | 49 const std::string& key_system, |
| 50 const media::KeyAddedCB& key_added_cb, | 50 const media::KeyAddedCB& key_added_cb, |
| 51 const media::KeyErrorCB& key_error_cb, | 51 const media::KeyErrorCB& key_error_cb, |
| 52 const media::KeyMessageCB& key_message_cb, | 52 const media::KeyMessageCB& key_message_cb, |
| 53 const base::Closure& destroy_plugin_cb, | 53 const base::Closure& destroy_plugin_cb, |
| 54 WebKit::WebMediaPlayerClient* web_media_player_client, | 54 blink::WebMediaPlayerClient* web_media_player_client, |
| 55 WebKit::WebFrame* web_frame) { | 55 blink::WebFrame* web_frame) { |
| 56 DCHECK(web_media_player_client); | 56 DCHECK(web_media_player_client); |
| 57 DCHECK(web_frame); | 57 DCHECK(web_frame); |
| 58 | 58 |
| 59 std::string plugin_type = GetPepperType(key_system); | 59 std::string plugin_type = GetPepperType(key_system); |
| 60 DCHECK(!plugin_type.empty()); | 60 DCHECK(!plugin_type.empty()); |
| 61 const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance = | 61 const scoped_refptr<PepperPluginInstanceImpl>& plugin_instance = |
| 62 CreateHelperPlugin(plugin_type, web_media_player_client, web_frame); | 62 CreateHelperPlugin(plugin_type, web_media_player_client, web_frame); |
| 63 if (!plugin_instance.get()) { | 63 if (!plugin_instance.get()) { |
| 64 DLOG(ERROR) << "ProxyDecryptor: plugin instance creation failed."; | 64 DLOG(ERROR) << "ProxyDecryptor: plugin instance creation failed."; |
| 65 return scoped_ptr<media::MediaKeys>(); | 65 return scoped_ptr<media::MediaKeys>(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 scoped_ptr<PpapiDecryptor> decryptor = | 68 scoped_ptr<PpapiDecryptor> decryptor = |
| 69 PpapiDecryptor::Create(key_system, | 69 PpapiDecryptor::Create(key_system, |
| 70 plugin_instance, | 70 plugin_instance, |
| 71 key_added_cb, | 71 key_added_cb, |
| 72 key_error_cb, | 72 key_error_cb, |
| 73 key_message_cb, | 73 key_message_cb, |
| 74 destroy_plugin_cb); | 74 destroy_plugin_cb); |
| 75 | 75 |
| 76 if (!decryptor) | 76 if (!decryptor) |
| 77 destroy_plugin_cb.Run(); | 77 destroy_plugin_cb.Run(); |
| 78 // Else the new object will call destroy_plugin_cb to destroy Helper Plugin. | 78 // Else the new object will call destroy_plugin_cb to destroy Helper Plugin. |
| 79 | 79 |
| 80 return scoped_ptr<media::MediaKeys>(decryptor.Pass()); | 80 return scoped_ptr<media::MediaKeys>(decryptor.Pass()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void ContentDecryptionModuleFactory::DestroyHelperPlugin( | 83 void ContentDecryptionModuleFactory::DestroyHelperPlugin( |
| 84 WebKit::WebMediaPlayerClient* web_media_player_client, | 84 blink::WebMediaPlayerClient* web_media_player_client, |
| 85 WebKit::WebFrame* web_frame) { | 85 blink::WebFrame* web_frame) { |
| 86 web_media_player_client->closeHelperPluginSoon(web_frame); | 86 web_media_player_client->closeHelperPluginSoon(web_frame); |
| 87 } | 87 } |
| 88 #endif // defined(ENABLE_PEPPER_CDMS) | 88 #endif // defined(ENABLE_PEPPER_CDMS) |
| 89 | 89 |
| 90 scoped_ptr<media::MediaKeys> ContentDecryptionModuleFactory::Create( | 90 scoped_ptr<media::MediaKeys> ContentDecryptionModuleFactory::Create( |
| 91 const std::string& key_system, | 91 const std::string& key_system, |
| 92 #if defined(ENABLE_PEPPER_CDMS) | 92 #if defined(ENABLE_PEPPER_CDMS) |
| 93 WebKit::WebMediaPlayerClient* web_media_player_client, | 93 blink::WebMediaPlayerClient* web_media_player_client, |
| 94 WebKit::WebFrame* web_frame, | 94 blink::WebFrame* web_frame, |
| 95 const base::Closure& destroy_plugin_cb, | 95 const base::Closure& destroy_plugin_cb, |
| 96 #elif defined(OS_ANDROID) | 96 #elif defined(OS_ANDROID) |
| 97 RendererMediaPlayerManager* manager, | 97 RendererMediaPlayerManager* manager, |
| 98 int media_keys_id, | 98 int media_keys_id, |
| 99 const GURL& frame_url, | 99 const GURL& frame_url, |
| 100 #endif // defined(ENABLE_PEPPER_CDMS) | 100 #endif // defined(ENABLE_PEPPER_CDMS) |
| 101 const media::KeyAddedCB& key_added_cb, | 101 const media::KeyAddedCB& key_added_cb, |
| 102 const media::KeyErrorCB& key_error_cb, | 102 const media::KeyErrorCB& key_error_cb, |
| 103 const media::KeyMessageCB& key_message_cb) { | 103 const media::KeyMessageCB& key_message_cb) { |
| 104 if (CanUseAesDecryptor(key_system)) { | 104 if (CanUseAesDecryptor(key_system)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 119 scoped_ptr<ProxyMediaKeys> proxy_media_keys(new ProxyMediaKeys( | 119 scoped_ptr<ProxyMediaKeys> proxy_media_keys(new ProxyMediaKeys( |
| 120 manager, media_keys_id, key_added_cb, key_error_cb, key_message_cb)); | 120 manager, media_keys_id, key_added_cb, key_error_cb, key_message_cb)); |
| 121 proxy_media_keys->InitializeCDM(key_system, frame_url); | 121 proxy_media_keys->InitializeCDM(key_system, frame_url); |
| 122 return proxy_media_keys.PassAs<media::MediaKeys>(); | 122 return proxy_media_keys.PassAs<media::MediaKeys>(); |
| 123 #else | 123 #else |
| 124 return scoped_ptr<media::MediaKeys>(); | 124 return scoped_ptr<media::MediaKeys>(); |
| 125 #endif // defined(ENABLE_PEPPER_CDMS) | 125 #endif // defined(ENABLE_PEPPER_CDMS) |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace content | 128 } // namespace content |
| OLD | NEW |