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

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

Issue 2712983004: Simplify/Cleanup MediaClient (Closed)
Patch Set: Fix test leak Created 3 years, 8 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
« no previous file with comments | « media/blink/webencryptedmediaclient_impl.h ('k') | media/blink/webmediaplayer_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 2014 The Chromium Authors. All rights reserved. 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 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/webencryptedmediaclient_impl.h" 5 #include "media/blink/webencryptedmediaclient_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/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.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/key_systems.h" 14 #include "media/base/key_systems.h"
15 #include "media/base/media_client.h" 15 #include "media/base/media_log.h"
16 #include "media/base/media_permission.h" 16 #include "media/base/media_permission.h"
17 #include "media/blink/webcontentdecryptionmodule_impl.h" 17 #include "media/blink/webcontentdecryptionmodule_impl.h"
18 #include "media/blink/webcontentdecryptionmoduleaccess_impl.h" 18 #include "media/blink/webcontentdecryptionmoduleaccess_impl.h"
19 #include "third_party/WebKit/public/platform/URLConversion.h" 19 #include "third_party/WebKit/public/platform/URLConversion.h"
20 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" 20 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
21 #include "third_party/WebKit/public/platform/WebEncryptedMediaRequest.h" 21 #include "third_party/WebKit/public/platform/WebEncryptedMediaRequest.h"
22 #include "third_party/WebKit/public/platform/WebMediaKeySystemConfiguration.h" 22 #include "third_party/WebKit/public/platform/WebMediaKeySystemConfiguration.h"
23 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 23 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
24 #include "third_party/WebKit/public/platform/WebString.h" 24 #include "third_party/WebKit/public/platform/WebString.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 const std::string uma_name_; 83 const std::string uma_name_;
84 bool is_request_reported_; 84 bool is_request_reported_;
85 bool is_support_reported_; 85 bool is_support_reported_;
86 }; 86 };
87 87
88 WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl( 88 WebEncryptedMediaClientImpl::WebEncryptedMediaClientImpl(
89 base::Callback<bool(void)> are_secure_codecs_supported_cb, 89 base::Callback<bool(void)> are_secure_codecs_supported_cb,
90 CdmFactory* cdm_factory, 90 CdmFactory* cdm_factory,
91 MediaPermission* media_permission) 91 MediaPermission* media_permission,
92 const scoped_refptr<MediaLog>& media_log)
92 : are_secure_codecs_supported_cb_(are_secure_codecs_supported_cb), 93 : are_secure_codecs_supported_cb_(are_secure_codecs_supported_cb),
93 cdm_factory_(cdm_factory), 94 cdm_factory_(cdm_factory),
94 key_system_config_selector_(KeySystems::GetInstance(), media_permission), 95 key_system_config_selector_(KeySystems::GetInstance(), media_permission),
96 media_log_(media_log),
95 weak_factory_(this) { 97 weak_factory_(this) {
96 DCHECK(cdm_factory_); 98 DCHECK(cdm_factory_);
97 } 99 }
98 100
99 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() { 101 WebEncryptedMediaClientImpl::~WebEncryptedMediaClientImpl() {
100 } 102 }
101 103
102 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess( 104 void WebEncryptedMediaClientImpl::requestMediaKeySystemAccess(
103 blink::WebEncryptedMediaRequest request) { 105 blink::WebEncryptedMediaRequest request) {
104 GetReporter(request.keySystem())->ReportRequested(); 106 GetReporter(request.keySystem())->ReportRequested();
105 107
106 if (GetMediaClient()) { 108 media_log_->RecordRapporWithSecurityOrigin("Media.OriginUrl.EME");
107 GURL security_origin(url::Origin(request.getSecurityOrigin()).GetURL()); 109 if (!request.getSecurityOrigin().isPotentiallyTrustworthy()) {
108 110 media_log_->RecordRapporWithSecurityOrigin("Media.OriginUrl.EME.Insecure");
109 GetMediaClient()->RecordRapporURL("Media.OriginUrl.EME", security_origin);
110
111 if (!request.getSecurityOrigin().isPotentiallyTrustworthy()) {
112 GetMediaClient()->RecordRapporURL("Media.OriginUrl.EME.Insecure",
113 security_origin);
114 }
115 } 111 }
116 112
117 key_system_config_selector_.SelectConfig( 113 key_system_config_selector_.SelectConfig(
118 request.keySystem(), request.supportedConfigurations(), 114 request.keySystem(), request.supportedConfigurations(),
119 request.getSecurityOrigin(), are_secure_codecs_supported_cb_.Run(), 115 request.getSecurityOrigin(), are_secure_codecs_supported_cb_.Run(),
120 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded, 116 base::Bind(&WebEncryptedMediaClientImpl::OnRequestSucceeded,
121 weak_factory_.GetWeakPtr(), request), 117 weak_factory_.GetWeakPtr(), request),
122 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported, 118 base::Bind(&WebEncryptedMediaClientImpl::OnRequestNotSupported,
123 weak_factory_.GetWeakPtr(), request)); 119 weak_factory_.GetWeakPtr(), request));
124 } 120 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 169
174 // Return a per-frame singleton so that UMA reports will be once-per-frame. 170 // Return a per-frame singleton so that UMA reports will be once-per-frame.
175 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii); 171 std::string uma_name = GetKeySystemNameForUMA(key_system_ascii);
176 std::unique_ptr<Reporter>& reporter = reporters_[uma_name]; 172 std::unique_ptr<Reporter>& reporter = reporters_[uma_name];
177 if (!reporter) 173 if (!reporter)
178 reporter = base::MakeUnique<Reporter>(uma_name); 174 reporter = base::MakeUnique<Reporter>(uma_name);
179 return reporter.get(); 175 return reporter.get();
180 } 176 }
181 177
182 } // namespace media 178 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webencryptedmediaclient_impl.h ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698