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

Side by Side Diff: media/blink/webcontentdecryptionmodule_impl.cc

Issue 2382973002: Convert WebSecurityOrigin -> GURL without re-parsing the url (Closed)
Patch Set: rebase on #427122 Created 4 years, 1 month 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
« no previous file with comments | « media/blink/key_system_config_selector.cc ('k') | media/blink/webencryptedmediaclient_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "media/blink/webcontentdecryptionmodule_impl.h" 5 #include "media/blink/webcontentdecryptionmodule_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/numerics/safe_conversions.h" 11 #include "base/numerics/safe_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "media/base/cdm_promise.h" 14 #include "media/base/cdm_promise.h"
15 #include "media/base/key_systems.h" 15 #include "media/base/key_systems.h"
16 #include "media/base/media_keys.h" 16 #include "media/base/media_keys.h"
17 #include "media/blink/cdm_result_promise.h" 17 #include "media/blink/cdm_result_promise.h"
18 #include "media/blink/cdm_session_adapter.h" 18 #include "media/blink/cdm_session_adapter.h"
19 #include "media/blink/webcontentdecryptionmodulesession_impl.h" 19 #include "media/blink/webcontentdecryptionmodulesession_impl.h"
20 #include "third_party/WebKit/public/platform/URLConversion.h" 20 #include "third_party/WebKit/public/platform/URLConversion.h"
21 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 21 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
22 #include "third_party/WebKit/public/platform/WebString.h" 22 #include "third_party/WebKit/public/platform/WebString.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 #include "url/origin.h"
24 25
25 namespace media { 26 namespace media {
26 27
27 void WebContentDecryptionModuleImpl::Create( 28 void WebContentDecryptionModuleImpl::Create(
28 media::CdmFactory* cdm_factory, 29 media::CdmFactory* cdm_factory,
29 const base::string16& key_system, 30 const base::string16& key_system,
30 const blink::WebSecurityOrigin& security_origin, 31 const blink::WebSecurityOrigin& security_origin,
31 const CdmConfig& cdm_config, 32 const CdmConfig& cdm_config,
32 std::unique_ptr<blink::WebContentDecryptionModuleResult> result) { 33 std::unique_ptr<blink::WebContentDecryptionModuleResult> result) {
33 DCHECK(!security_origin.isNull()); 34 DCHECK(!security_origin.isNull());
(...skipping 22 matching lines...) Expand all
56 } 57 }
57 58
58 // If unique security origin, don't try to create the CDM. 59 // If unique security origin, don't try to create the CDM.
59 if (security_origin.isUnique() || security_origin.toString() == "null") { 60 if (security_origin.isUnique() || security_origin.toString() == "null") {
60 result->completeWithError( 61 result->completeWithError(
61 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, 62 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
62 "EME use is not allowed on unique origins."); 63 "EME use is not allowed on unique origins.");
63 return; 64 return;
64 } 65 }
65 66
66 GURL security_origin_as_gurl( 67 GURL security_origin_as_gurl(url::Origin(security_origin).GetURL());
67 blink::WebStringToGURL(security_origin.toString()));
68 68
69 // CdmSessionAdapter::CreateCdm() will keep a reference to |adapter|. Then 69 // CdmSessionAdapter::CreateCdm() will keep a reference to |adapter|. Then
70 // if WebContentDecryptionModuleImpl is successfully created (returned in 70 // if WebContentDecryptionModuleImpl is successfully created (returned in
71 // |result|), it will keep a reference to |adapter|. Otherwise, |adapter| will 71 // |result|), it will keep a reference to |adapter|. Otherwise, |adapter| will
72 // be destructed. 72 // be destructed.
73 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter()); 73 scoped_refptr<CdmSessionAdapter> adapter(new CdmSessionAdapter());
74 adapter->CreateCdm(cdm_factory, key_system_ascii, security_origin_as_gurl, 74 adapter->CreateCdm(cdm_factory, key_system_ascii, security_origin_as_gurl,
75 cdm_config, std::move(result)); 75 cdm_config, std::move(result));
76 } 76 }
77 77
(...skipping 21 matching lines...) Expand all
99 server_certificate + server_certificate_length), 99 server_certificate + server_certificate_length),
100 std::unique_ptr<SimpleCdmPromise>( 100 std::unique_ptr<SimpleCdmPromise>(
101 new CdmResultPromise<>(result, std::string()))); 101 new CdmResultPromise<>(result, std::string())));
102 } 102 }
103 103
104 scoped_refptr<MediaKeys> WebContentDecryptionModuleImpl::GetCdm() { 104 scoped_refptr<MediaKeys> WebContentDecryptionModuleImpl::GetCdm() {
105 return adapter_->GetCdm(); 105 return adapter_->GetCdm();
106 } 106 }
107 107
108 } // namespace media 108 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/key_system_config_selector.cc ('k') | media/blink/webencryptedmediaclient_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698