OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" | 13 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 #if defined(ENABLE_PEPPER_CDMS) | 16 #if defined(ENABLE_PEPPER_CDMS) |
17 class WebLocalFrame; | 17 class WebLocalFrame; |
18 #endif | 18 #endif |
19 class WebSecurityOrigin; | 19 class WebSecurityOrigin; |
20 } | 20 } |
21 | 21 |
22 namespace media { | 22 namespace media { |
23 class Decryptor; | 23 class Decryptor; |
24 class MediaKeys; | 24 class MediaKeys; |
25 } | 25 } |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 class CdmSessionAdapter; | 29 class CdmSessionAdapter; |
30 #if defined(OS_ANDROID) | 30 #if defined(ENABLE_BROWSER_CDMS) |
31 class RendererCdmManager; | 31 class RendererCdmManager; |
32 #endif | 32 #endif |
33 class WebContentDecryptionModuleSessionImpl; | 33 class WebContentDecryptionModuleSessionImpl; |
34 | 34 |
35 class WebContentDecryptionModuleImpl | 35 class WebContentDecryptionModuleImpl |
36 : public blink::WebContentDecryptionModule { | 36 : public blink::WebContentDecryptionModule { |
37 public: | 37 public: |
38 static WebContentDecryptionModuleImpl* Create( | 38 static WebContentDecryptionModuleImpl* Create( |
39 #if defined(ENABLE_PEPPER_CDMS) | 39 #if defined(ENABLE_PEPPER_CDMS) |
40 blink::WebLocalFrame* frame, | 40 blink::WebLocalFrame* frame, |
41 #elif defined(OS_ANDROID) | 41 #elif defined(ENABLE_BROWSER_CDMS) |
42 RendererCdmManager* manager, | 42 RendererCdmManager* manager, |
43 #endif | 43 #endif |
44 const blink::WebSecurityOrigin& security_origin, | 44 const blink::WebSecurityOrigin& security_origin, |
45 const base::string16& key_system); | 45 const base::string16& key_system); |
46 | 46 |
47 virtual ~WebContentDecryptionModuleImpl(); | 47 virtual ~WebContentDecryptionModuleImpl(); |
48 | 48 |
49 // Returns the Decryptor associated with this CDM. May be NULL if no | 49 // Returns the Decryptor associated with this CDM. May be NULL if no |
50 // Decryptor associated with the MediaKeys object. | 50 // Decryptor associated with the MediaKeys object. |
51 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor | 51 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor |
52 // after WebContentDecryptionModule is freed. http://crbug.com/330324 | 52 // after WebContentDecryptionModule is freed. http://crbug.com/330324 |
53 media::Decryptor* GetDecryptor(); | 53 media::Decryptor* GetDecryptor(); |
54 | 54 |
55 #if defined(OS_ANDROID) | 55 #if defined(ENABLE_BROWSER_CDMS) |
56 // Returns the CDM ID associated with this object. May be kInvalidCdmId if no | 56 // Returns the CDM ID associated with this object. May be kInvalidCdmId if no |
57 // CDM ID is associated, such as when Clear Key is used. | 57 // CDM ID is associated, such as when Clear Key is used. |
58 int GetCdmId() const; | 58 int GetCdmId() const; |
59 #endif // defined(OS_ANDROID) | 59 #endif // defined(ENABLE_BROWSER_CDMS) |
60 | 60 |
61 // blink::WebContentDecryptionModule implementation. | 61 // blink::WebContentDecryptionModule implementation. |
62 virtual blink::WebContentDecryptionModuleSession* createSession( | 62 virtual blink::WebContentDecryptionModuleSession* createSession( |
63 blink::WebContentDecryptionModuleSession::Client* client); | 63 blink::WebContentDecryptionModuleSession::Client* client); |
64 | 64 |
65 private: | 65 private: |
66 // Takes reference to |adapter|. | 66 // Takes reference to |adapter|. |
67 WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter); | 67 WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter); |
68 | 68 |
69 scoped_refptr<CdmSessionAdapter> adapter_; | 69 scoped_refptr<CdmSessionAdapter> adapter_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl); | 71 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl); |
72 }; | 72 }; |
73 | 73 |
74 // Allow typecasting from blink type as this is the only implementation. | 74 // Allow typecasting from blink type as this is the only implementation. |
75 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl( | 75 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl( |
76 blink::WebContentDecryptionModule* cdm) { | 76 blink::WebContentDecryptionModule* cdm) { |
77 return static_cast<WebContentDecryptionModuleImpl*>(cdm); | 77 return static_cast<WebContentDecryptionModuleImpl*>(cdm); |
78 } | 78 } |
79 | 79 |
80 } // namespace content | 80 } // namespace content |
81 | 81 |
82 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ | 82 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_ |
OLD | NEW |