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
3 // found in the LICENSE file.
5 #ifndef MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
6 #define MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
11 #include "media/base/media_export.h"
12 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
13 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
16 #if defined(ENABLE_PEPPER_CDMS)
19 class WebSecurityOrigin
;
26 class CdmSessionAdapter
;
27 class WebContentDecryptionModuleSessionImpl
;
29 class MEDIA_EXPORT WebContentDecryptionModuleImpl
30 : public blink::WebContentDecryptionModule
{
32 // TODO(jrummell): Remove once WebContentDecryptionModuleResult always passed.
33 static WebContentDecryptionModuleImpl
* Create(
34 CdmFactory
* cdm_factory
,
35 const blink::WebSecurityOrigin
& security_origin
,
36 const base::string16
& key_system
);
37 static void Create(CdmFactory
* cdm_factory
,
38 const blink::WebSecurityOrigin
& security_origin
,
39 const base::string16
& key_system
,
40 blink::WebContentDecryptionModuleResult result
);
42 virtual ~WebContentDecryptionModuleImpl();
44 // blink::WebContentDecryptionModule implementation.
45 virtual blink::WebContentDecryptionModuleSession
* createSession();
46 // TODO(jrummell): Remove this method once blink updated.
47 virtual blink::WebContentDecryptionModuleSession
* createSession(
48 blink::WebContentDecryptionModuleSession::Client
* client
);
50 virtual void setServerCertificate(
51 const uint8
* server_certificate
,
52 size_t server_certificate_length
,
53 blink::WebContentDecryptionModuleResult result
);
55 // Returns the CdmContext associated with this CDM, which must not be nullptr.
56 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
57 // after WebContentDecryptionModule is freed. http://crbug.com/330324
58 CdmContext
* GetCdmContext();
61 // Takes reference to |adapter|.
62 WebContentDecryptionModuleImpl(scoped_refptr
<CdmSessionAdapter
> adapter
);
64 scoped_refptr
<CdmSessionAdapter
> adapter_
;
66 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl
);
69 // Allow typecasting from blink type as this is the only implementation.
70 inline WebContentDecryptionModuleImpl
* ToWebContentDecryptionModuleImpl(
71 blink::WebContentDecryptionModule
* cdm
) {
72 return static_cast<WebContentDecryptionModuleImpl
*>(cdm
);
77 #endif // MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULE_IMPL_H_