1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_
8 #if !defined(ENABLE_PEPPER_CDMS)
9 #error This file should only be included when ENABLE_PEPPER_CDMS is defined
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "content/renderer/media/crypto/pepper_cdm_wrapper.h"
18 class WebHelperPlugin
;
24 class ContentDecryptorDelegate
;
25 class PepperPluginInstanceImpl
;
27 // Deleter for blink::WebHelperPlugin.
28 struct WebHelperPluginDeleter
{
29 void operator()(blink::WebHelperPlugin
* plugin
) const;
32 // Implements a wrapper on blink::WebHelperPlugin so that the plugin gets
33 // destroyed properly. It owns all the objects derived from WebHelperPlugin
34 // (WebPlugin, PepperPluginInstanceImpl, ContentDecryptionDelegate), and will
35 // free them as necessary when this wrapper is destroyed. In particular, it
36 // takes a reference to PepperPluginInstanceImpl so it won't go away until
37 // this object is destroyed.
39 // Implemented so that lower layers in Chromium don't need to be aware of
41 class PepperCdmWrapperImpl
: public PepperCdmWrapper
{
43 static scoped_ptr
<PepperCdmWrapper
> Create(blink::WebLocalFrame
* frame
,
44 const std::string
& pluginType
,
45 const GURL
& security_origin
);
47 virtual ~PepperCdmWrapperImpl();
49 // Returns the ContentDecryptorDelegate* associated with this plugin.
50 virtual ContentDecryptorDelegate
* GetCdmDelegate() OVERRIDE
;
53 typedef scoped_ptr
<blink::WebHelperPlugin
, WebHelperPluginDeleter
>
56 // Takes ownership of |helper_plugin| and |plugin_instance|.
58 ScopedHelperPlugin helper_plugin
,
59 const scoped_refptr
<PepperPluginInstanceImpl
>& plugin_instance
);
61 ScopedHelperPlugin helper_plugin_
;
62 scoped_refptr
<PepperPluginInstanceImpl
> plugin_instance_
;
64 DISALLOW_COPY_AND_ASSIGN(PepperCdmWrapperImpl
);
67 } // namespace content
69 #endif // CONTENT_RENDERER_MEDIA_CRYPTO_PEPPER_CDM_WRAPPER_IMPL_H_