Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / renderer / media / webcontentdecryptionmodule_impl.h
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.
4
5 #ifndef CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_
7
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"
13
14 namespace blink {
15 #if defined(ENABLE_PEPPER_CDMS)
16 class WebLocalFrame;
17 #endif
18 class WebSecurityOrigin;
19 }
20
21 namespace media {
22 class CdmFactory;
23 class Decryptor;
24 class MediaKeys;
25 }
26
27 namespace content {
28
29 class CdmSessionAdapter;
30 class WebContentDecryptionModuleSessionImpl;
31
32 class WebContentDecryptionModuleImpl
33     : public blink::WebContentDecryptionModule {
34  public:
35   static WebContentDecryptionModuleImpl* Create(
36       media::CdmFactory* cdm_factory,
37       const blink::WebSecurityOrigin& security_origin,
38       const base::string16& key_system);
39
40   virtual ~WebContentDecryptionModuleImpl();
41
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();
47
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.
51   int GetCdmId() const;
52 #endif  // defined(ENABLE_BROWSER_CDMS)
53
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);
59
60   virtual void setServerCertificate(
61       const uint8* server_certificate,
62       size_t server_certificate_length,
63       blink::WebContentDecryptionModuleResult result);
64
65  private:
66   // Takes reference to |adapter|.
67   WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter);
68
69   scoped_refptr<CdmSessionAdapter> adapter_;
70
71   DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl);
72 };
73
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);
78 }
79
80 }  // namespace content
81
82 #endif  // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_