[ServiceWorker] Implement WebServiceWorkerContextClient::openWindow().
[chromium-blink-merge.git] / content / renderer / media / crypto / render_cdm_factory.cc
blob2defedcc19b03fb0a072c54417c1d1587ce8007d
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 #include "content/renderer/media/crypto/render_cdm_factory.h"
7 #include "base/logging.h"
8 #include "media/base/key_systems.h"
9 #include "media/cdm/aes_decryptor.h"
10 #include "url/gurl.h"
12 #if defined(ENABLE_PEPPER_CDMS)
13 #include "content/renderer/media/crypto/ppapi_decryptor.h"
14 #elif defined(ENABLE_BROWSER_CDMS)
15 #include "content/renderer/media/crypto/proxy_media_keys.h"
16 #endif // defined(ENABLE_PEPPER_CDMS)
18 namespace content {
20 #if defined(ENABLE_PEPPER_CDMS)
21 RenderCdmFactory::RenderCdmFactory(
22 const CreatePepperCdmCB& create_pepper_cdm_cb)
23 : create_pepper_cdm_cb_(create_pepper_cdm_cb) {
25 #elif defined(ENABLE_BROWSER_CDMS)
26 RenderCdmFactory::RenderCdmFactory(RendererCdmManager* manager)
27 : manager_(manager) {
29 #else
30 RenderCdmFactory::RenderCdmFactory() {
32 #endif // defined(ENABLE_PEPPER_CDMS)
34 RenderCdmFactory::~RenderCdmFactory() {
37 scoped_ptr<media::MediaKeys> RenderCdmFactory::Create(
38 const std::string& key_system,
39 const GURL& security_origin,
40 const media::SessionMessageCB& session_message_cb,
41 const media::SessionClosedCB& session_closed_cb,
42 const media::SessionErrorCB& session_error_cb,
43 const media::SessionKeysChangeCB& session_keys_change_cb,
44 const media::SessionExpirationUpdateCB& session_expiration_update_cb) {
45 // TODO(jrummell): Pass |security_origin| to all constructors.
46 // TODO(jrummell): Enable the following line once blink code updated to
47 // check the security origin before calling.
48 // DCHECK(security_origin.is_valid());
50 if (media::CanUseAesDecryptor(key_system)) {
51 return scoped_ptr<media::MediaKeys>(new media::AesDecryptor(
52 session_message_cb, session_closed_cb, session_keys_change_cb));
55 #if defined(ENABLE_PEPPER_CDMS)
56 return scoped_ptr<media::MediaKeys>(
57 PpapiDecryptor::Create(key_system,
58 security_origin,
59 create_pepper_cdm_cb_,
60 session_message_cb,
61 session_closed_cb,
62 session_error_cb,
63 session_keys_change_cb,
64 session_expiration_update_cb));
65 #elif defined(ENABLE_BROWSER_CDMS)
66 return scoped_ptr<media::MediaKeys>(
67 ProxyMediaKeys::Create(key_system,
68 security_origin,
69 manager_,
70 session_message_cb,
71 session_closed_cb,
72 session_error_cb,
73 session_keys_change_cb,
74 session_expiration_update_cb));
75 #else
76 return nullptr;
77 #endif // defined(ENABLE_PEPPER_CDMS)
80 } // namespace content