Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / renderer / media / webcontentdecryptionmodule_impl.h
blob2619e5610b3eeea3a0ca232bd018536aac3a85e5
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 <string>
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"
15 namespace blink {
16 #if defined(ENABLE_PEPPER_CDMS)
17 class WebLocalFrame;
18 #endif
19 class WebSecurityOrigin;
22 namespace media {
23 class Decryptor;
24 class MediaKeys;
27 namespace content {
29 class CdmSessionAdapter;
30 #if defined(ENABLE_BROWSER_CDMS)
31 class RendererCdmManager;
32 #endif
33 class WebContentDecryptionModuleSessionImpl;
35 class WebContentDecryptionModuleImpl
36 : public blink::WebContentDecryptionModule {
37 public:
38 static WebContentDecryptionModuleImpl* Create(
39 #if defined(ENABLE_PEPPER_CDMS)
40 blink::WebLocalFrame* frame,
41 #elif defined(ENABLE_BROWSER_CDMS)
42 RendererCdmManager* manager,
43 #endif
44 const blink::WebSecurityOrigin& security_origin,
45 const base::string16& key_system);
47 virtual ~WebContentDecryptionModuleImpl();
49 // Returns the Decryptor associated with this CDM. May be NULL if no
50 // Decryptor associated with the MediaKeys object.
51 // TODO(jrummell): Figure out lifetimes, as WMPI may still use the decryptor
52 // after WebContentDecryptionModule is freed. http://crbug.com/330324
53 media::Decryptor* GetDecryptor();
55 #if defined(ENABLE_BROWSER_CDMS)
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.
58 int GetCdmId() const;
59 #endif // defined(ENABLE_BROWSER_CDMS)
61 // blink::WebContentDecryptionModule implementation.
62 virtual blink::WebContentDecryptionModuleSession* createSession();
63 // TODO(jrummell): Remove this method once blink updated.
64 virtual blink::WebContentDecryptionModuleSession* createSession(
65 blink::WebContentDecryptionModuleSession::Client* client);
67 private:
68 // Takes reference to |adapter|.
69 WebContentDecryptionModuleImpl(scoped_refptr<CdmSessionAdapter> adapter);
71 scoped_refptr<CdmSessionAdapter> adapter_;
73 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleImpl);
76 // Allow typecasting from blink type as this is the only implementation.
77 inline WebContentDecryptionModuleImpl* ToWebContentDecryptionModuleImpl(
78 blink::WebContentDecryptionModule* cdm) {
79 return static_cast<WebContentDecryptionModuleImpl*>(cdm);
82 } // namespace content
84 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULE_IMPL_H_