Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: content/renderer/media/webcontentdecryptionmodule_impl.cc

Issue 660673002: Introduce CdmFactory interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_result_promise
Patch Set: comments addressed Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 5 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
6 6
7 #include <map>
8 #include <vector>
9
10 #include "base/basictypes.h" 7 #include "base/basictypes.h"
11 #include "base/bind.h" 8 #include "base/bind.h"
12 #include "base/logging.h" 9 #include "base/logging.h"
13 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
15 #include "content/renderer/media/cdm_session_adapter.h" 12 #include "content/renderer/media/cdm_session_adapter.h"
16 #include "content/renderer/media/crypto/key_systems.h" 13 #include "content/renderer/media/crypto/key_systems.h"
17 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" 14 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h"
18 #include "media/base/cdm_promise.h" 15 #include "media/base/cdm_promise.h"
19 #include "media/base/media_keys.h" 16 #include "media/base/media_keys.h"
20 #include "media/blink/cdm_result_promise.h" 17 #include "media/blink/cdm_result_promise.h"
21 #include "third_party/WebKit/public/platform/WebString.h" 18 #include "third_party/WebKit/public/platform/WebString.h"
22 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 19 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
23 #include "url/gurl.h" 20 #include "url/gurl.h"
24 21
25 #if defined(ENABLE_PEPPER_CDMS)
26 #include "content/renderer/media/crypto/pepper_cdm_wrapper_impl.h"
27 #endif
28
29 namespace content { 22 namespace content {
30 23
31 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create( 24 WebContentDecryptionModuleImpl* WebContentDecryptionModuleImpl::Create(
32 #if defined(ENABLE_PEPPER_CDMS) 25 media::CdmFactory* cdm_factory,
33 blink::WebLocalFrame* frame,
34 #elif defined(ENABLE_BROWSER_CDMS)
35 RendererCdmManager* manager,
36 #endif
37 const blink::WebSecurityOrigin& security_origin, 26 const blink::WebSecurityOrigin& security_origin,
38 const base::string16& key_system) { 27 const base::string16& key_system) {
39 #if defined(ENABLE_PEPPER_CDMS)
40 DCHECK(frame);
41 #elif defined(ENABLE_BROWSER_CDMS)
42 DCHECK(manager);
43 #endif
44 DCHECK(!security_origin.isNull()); 28 DCHECK(!security_origin.isNull());
45 DCHECK(!key_system.empty()); 29 DCHECK(!key_system.empty());
46 30
47 // TODO(ddorwin): Guard against this in supported types check and remove this. 31 // TODO(ddorwin): Guard against this in supported types check and remove this.
48 // Chromium only supports ASCII key systems. 32 // Chromium only supports ASCII key systems.
49 if (!base::IsStringASCII(key_system)) { 33 if (!base::IsStringASCII(key_system)) {
50 NOTREACHED(); 34 NOTREACHED();
51 return NULL; 35 return NULL;
52 } 36 }
53 37
54 std::string key_system_ascii = base::UTF16ToASCII(key_system); 38 std::string key_system_ascii = base::UTF16ToASCII(key_system);
55 if (!IsConcreteSupportedKeySystem(key_system_ascii)) 39 if (!IsConcreteSupportedKeySystem(key_system_ascii))
56 return NULL; 40 return NULL;
57 41
58 // If unique security origin, don't try to create the CDM. 42 // If unique security origin, don't try to create the CDM.
59 if (security_origin.isUnique() || security_origin.toString() == "null") { 43 if (security_origin.isUnique() || security_origin.toString() == "null") {
60 DLOG(ERROR) << "CDM use not allowed for unique security origin."; 44 DLOG(ERROR) << "CDM use not allowed for unique security origin.";
61 return NULL; 45 return NULL;
62 } 46 }
63 47
64 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); 48 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter());
65 GURL security_origin_as_gurl(security_origin.toString()); 49 GURL security_origin_as_gurl(security_origin.toString());
66 50
67 if (!adapter->Initialize( 51 if (!adapter->Initialize(
68 #if defined(ENABLE_PEPPER_CDMS) 52 cdm_factory, key_system_ascii, security_origin_as_gurl)) {
69 base::Bind(&PepperCdmWrapperImpl::Create, frame),
70 #elif defined(ENABLE_BROWSER_CDMS)
71 manager,
72 #endif
73 key_system_ascii,
74 security_origin_as_gurl)) {
75 return NULL; 53 return NULL;
76 } 54 }
77 55
78 return new WebContentDecryptionModuleImpl(adapter); 56 return new WebContentDecryptionModuleImpl(adapter);
79 } 57 }
80 58
81 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl( 59 WebContentDecryptionModuleImpl::WebContentDecryptionModuleImpl(
82 scoped_refptr<CdmSessionAdapter> adapter) 60 scoped_refptr<CdmSessionAdapter> adapter)
83 : adapter_(adapter) { 61 : adapter_(adapter) {
84 } 62 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return adapter_->GetDecryptor(); 94 return adapter_->GetDecryptor();
117 } 95 }
118 96
119 #if defined(ENABLE_BROWSER_CDMS) 97 #if defined(ENABLE_BROWSER_CDMS)
120 int WebContentDecryptionModuleImpl::GetCdmId() const { 98 int WebContentDecryptionModuleImpl::GetCdmId() const {
121 return adapter_->GetCdmId(); 99 return adapter_->GetCdmId();
122 } 100 }
123 #endif // defined(ENABLE_BROWSER_CDMS) 101 #endif // defined(ENABLE_BROWSER_CDMS)
124 102
125 } // namespace content 103 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webcontentdecryptionmodule_impl.h ('k') | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698