1 // Copyright 2014 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 "media/cdm/default_cdm_factory.h"
8 #include "base/bind_helpers.h"
9 #include "base/location.h"
10 #include "base/message_loop/message_loop_proxy.h"
11 #include "media/base/key_systems.h"
12 #include "media/cdm/aes_decryptor.h"
17 DefaultCdmFactory::DefaultCdmFactory() {
20 DefaultCdmFactory::~DefaultCdmFactory() {
23 void DefaultCdmFactory::Create(
24 const std::string
& key_system
,
25 bool allow_distinctive_identifier
,
26 bool allow_persistent_state
,
27 const GURL
& security_origin
,
28 const SessionMessageCB
& session_message_cb
,
29 const SessionClosedCB
& session_closed_cb
,
30 const LegacySessionErrorCB
& legacy_session_error_cb
,
31 const SessionKeysChangeCB
& session_keys_change_cb
,
32 const SessionExpirationUpdateCB
& session_expiration_update_cb
,
33 const CdmCreatedCB
& cdm_created_cb
) {
34 if (!security_origin
.is_valid() || !CanUseAesDecryptor(key_system
)) {
35 base::MessageLoopProxy::current()->PostTask(
36 FROM_HERE
, base::Bind(cdm_created_cb
, nullptr));
40 scoped_ptr
<MediaKeys
> cdm(
41 new AesDecryptor(security_origin
, session_message_cb
, session_closed_cb
,
42 session_keys_change_cb
));
43 base::MessageLoopProxy::current()->PostTask(
44 FROM_HERE
, base::Bind(cdm_created_cb
, base::Passed(&cdm
)));