Upstream version 7.36.149.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 <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h"
14
15 namespace blink {
16 class WebLocalFrame;
17 class WebSecurityOrigin;
18 }
19
20 namespace media {
21 class Decryptor;
22 class MediaKeys;
23 }
24
25 namespace content {
26
27 class CdmSessionAdapter;
28 class WebContentDecryptionModuleSessionImpl;
29
30 class WebContentDecryptionModuleImpl
31     : public blink::WebContentDecryptionModule {
32  public:
33   static WebContentDecryptionModuleImpl* Create(
34       blink::WebLocalFrame* frame,
35       const blink::WebSecurityOrigin& security_origin,
36       const base::string16& key_system);
37
38   virtual ~WebContentDecryptionModuleImpl();
39
40   // Returns the Decryptor associated with this CDM. May be NULL if no
41   // Decryptor associated with the MediaKeys object.
42   // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
43   // after WebContentDecryptionModule is freed. http://crbug.com/330324
44   media::Decryptor* GetDecryptor();
45
46 #if defined(OS_ANDROID)
47   // Returns the CDM ID associated with this object. May be kInvalidCdmId if no
48   // CDM ID is associated, such as when Clear Key is used.
49   int GetCdmId() const;
50 #endif  // defined(OS_ANDROID)
51
52   // blink::WebContentDecryptionModule implementation.
53   virtual blink::WebContentDecryptionModuleSession* createSession(
54       blink::WebContentDecryptionModuleSession::Client* client);
55
56  private:
57   // Takes reference to |adapter|.
58   WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter);
59
60   scoped_refptr<CdmSessionAdapter> adapter_;
61
62   DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl);
63 };
64
65 // Allow typecasting from blink type as this is the only implementation.
66 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl(
67     blink::WebContentDecryptionModule* cdm) {
68   return static_cast<WebContentDecryptionModuleImpl*>(cdm);
69 }
70
71 }  // namespace content
72
73 #endif  // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_