blob: 0c4a901f74699a0c95c4910edb4624297f445a86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/renderer/media/webcontentdecryptionmodule_impl.h"
#include <map>
#include <vector>
#include "base/basictypes.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "content/renderer/media/cdm_session_adapter.h"
#include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
#include "media/base/media_keys.h"
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
#if defined(ENABLE_PEPPER_CDMS)
#include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h"
#endif
namespace blink {
class WebFrame;
}
namespace content {
WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create(
const base::string16& key_system) {
blink::WebSecurityOrigin no_origin;
return WebContentDecryptionModuleImpl::Create(NULL, no_origin, key_system);
}
WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create(
blink::WebFrame* frame,
const blink::WebSecurityOrigin& security_origin,
const base::string16& key_system) {
// TODO(jrummell): Use |security_origin| rather than using the document URL.
// TODO(jrummell): Once the other Create() method is removed, validate |frame|
// and |security_origin|.
DCHECK(!key_system.empty());
// TODO(ddorwin): Guard against this in supported types check and remove this.
// Chromium only supports ASCII key systems.
if (!IsStringASCII(key_system)) {
NOTREACHED();
return NULL;
}
scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter());
if (!adapter->Initialize(
#if defined(ENABLE_PEPPER_CDMS)
base::Bind(&PepperCdmWrapperImpl::Create, frame),
#endif
base::UTF16ToASCII(key_system))) {
return NULL;
}
return new WebContentDecryptionModuleImpl(adapter);
}
WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl(
scoped_refptr<CdmSessionAdapter> adapter)
: adapter_(adapter) {
}
WebContentDecryptionModuleImpl::~WebContentDecryptionModuleImpl() {
}
// The caller owns the created session.
blink::WebContentDecryptionModuleSession*
WebContentDecryptionModuleImpl::createSession(
blink::WebContentDecryptionModuleSession::Client* client) {
return adapter_->CreateSession(client);
}
media::Decryptor* WebContentDecryptionModuleImpl::GetDecryptor() {
return adapter_->GetDecryptor();
}
} // namespace content
|