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 CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_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 "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
12 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
15 #if defined(ENABLE_PEPPER_CDMS)
18 class WebSecurityOrigin;
29 class CdmSessionAdapter;
30 class WebContentDecryptionModuleSessionImpl;
32 class WebContentDecryptionModuleImpl
33 : public blink::WebContentDecryptionModule {
35 static WebContentDecryptionModuleImpl* Create(
36 media::CdmFactory* cdm_factory,
37 const blink::WebSecurityOrigin& security_origin,
38 const base::string16& key_system);
40 virtual ~WebContentDecryptionModuleImpl();
42 // Returns the Decryptor associated with this CDM. May be NULL if no
43 // Decryptor associated with the MediaKeys object.
44 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
45 // after WebContentDecryptionModule is freed. http://crbug.com/330324
46 media::Decryptor* GetDecryptor();
48 #if defined(ENABLE_BROWSER_CDMS)
49 // Returns the CDM ID associated with this object. May be kInvalidCdmId if no
50 // CDM ID is associated, such as when Clear Key is used.
52 #endif // defined(ENABLE_BROWSER_CDMS)
54 // blink::WebContentDecryptionModule implementation.
55 virtual blink::WebContentDecryptionModuleSession* createSession();
56 // TODO(jrummell): Remove this method once blink updated.
57 virtual blink::WebContentDecryptionModuleSession* createSession(
58 blink::WebContentDecryptionModuleSession::Client* client);
60 virtual void setServerCertificate(
61 const uint8* server_certificate,
62 size_t server_certificate_length,
63 blink::WebContentDecryptionModuleResult result);
66 // Takes reference to |adapter|.
67 WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter);
69 scoped_refptr<CdmSessionAdapter> adapter_;
71 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl);
74 // Allow typecasting from blink type as this is the only implementation.
75 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl(
76 blink::WebContentDecryptionModule* cdm) {
77 return static_cast<WebContentDecryptionModuleImpl*>(cdm);
80 } // namespace content
82 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_