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

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

Issue 887873003: media: Add DefaultMediaPermission. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 10 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 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/encrypted_media_player_support.h" 5 #include "media/blink/encrypted_media_player_support.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes. 108 // Most WebM files use KeyId of 16 bytes. CENC init data is always >16 bytes.
109 if (init_data_length == 16) 109 if (init_data_length == 16)
110 return "webm"; 110 return "webm";
111 111
112 return "cenc"; 112 return "cenc";
113 } 113 }
114 114
115 EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport( 115 EncryptedMediaPlayerSupport::EncryptedMediaPlayerSupport(
116 scoped_ptr<CdmFactory> cdm_factory, 116 scoped_ptr<CdmFactory> cdm_factory,
117 blink::WebMediaPlayerClient* client, 117 blink::WebMediaPlayerClient* client,
118 MediaPermission* media_permission,
118 const SetCdmContextCB& set_cdm_context_cb) 119 const SetCdmContextCB& set_cdm_context_cb)
119 : cdm_factory_(cdm_factory.Pass()), 120 : cdm_factory_(cdm_factory.Pass()),
120 client_(client), 121 client_(client),
122 media_permission_(media_permission),
121 set_cdm_context_cb_(set_cdm_context_cb) { 123 set_cdm_context_cb_(set_cdm_context_cb) {
122 } 124 }
123 125
124 EncryptedMediaPlayerSupport::~EncryptedMediaPlayerSupport() { 126 EncryptedMediaPlayerSupport::~EncryptedMediaPlayerSupport() {
125 } 127 }
126 128
127 WebMediaPlayer::MediaKeyException 129 WebMediaPlayer::MediaKeyException
128 EncryptedMediaPlayerSupport::GenerateKeyRequest( 130 EncryptedMediaPlayerSupport::GenerateKeyRequest(
129 blink::WebLocalFrame* frame, 131 blink::WebLocalFrame* frame,
130 const WebString& key_system, 132 const WebString& key_system,
(...skipping 18 matching lines...) Expand all
149 const std::string& key_system, 151 const std::string& key_system,
150 const unsigned char* init_data, 152 const unsigned char* init_data,
151 unsigned init_data_length) { 153 unsigned init_data_length) {
152 if (!IsConcreteSupportedKeySystem(key_system)) 154 if (!IsConcreteSupportedKeySystem(key_system))
153 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; 155 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
154 156
155 // We do not support run-time switching between key systems for now. 157 // We do not support run-time switching between key systems for now.
156 if (current_key_system_.empty()) { 158 if (current_key_system_.empty()) {
157 if (!proxy_decryptor_) { 159 if (!proxy_decryptor_) {
158 proxy_decryptor_.reset(new ProxyDecryptor( 160 proxy_decryptor_.reset(new ProxyDecryptor(
161 media_permission_,
159 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded), 162 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyAdded),
160 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError), 163 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyError),
161 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage))); 164 BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnKeyMessage)));
162 } 165 }
163 166
164 GURL security_origin(frame->document().securityOrigin().toString()); 167 GURL security_origin(frame->document().securityOrigin().toString());
165 168
166 if (!proxy_decryptor_->InitializeCDM(cdm_factory_.get(), key_system, 169 if (!proxy_decryptor_->InitializeCDM(cdm_factory_.get(), key_system,
167 security_origin)) { 170 security_origin)) {
168 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; 171 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 326
324 client_->keyMessage( 327 client_->keyMessage(
325 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), 328 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)),
326 WebString::fromUTF8(session_id), 329 WebString::fromUTF8(session_id),
327 message.empty() ? NULL : &message[0], 330 message.empty() ? NULL : &message[0],
328 base::saturated_cast<unsigned int>(message.size()), 331 base::saturated_cast<unsigned int>(message.size()),
329 destination_url); 332 destination_url);
330 } 333 }
331 334
332 } // namespace media 335 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/encrypted_media_player_support.h ('k') | media/blink/webencryptedmediaclient_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698