| OLD | NEW |
| 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/webcontentdecryptionmodulesession_impl.h" | 5 #include "content/renderer/media/webcontentdecryptionmodulesession_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { | 80 blink::WebString WebContentDecryptionModuleSessionImpl::sessionId() const { |
| 81 return blink::WebString::fromUTF8(web_session_id_); | 81 return blink::WebString::fromUTF8(web_session_id_); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void WebContentDecryptionModuleSessionImpl::initializeNewSession( | 84 void WebContentDecryptionModuleSessionImpl::initializeNewSession( |
| 85 const blink::WebString& init_data_type, | 85 const blink::WebString& init_data_type, |
| 86 const uint8* init_data, | 86 const uint8* init_data, |
| 87 size_t init_data_length) { | 87 size_t init_data_length) { |
| 88 // TODO(ddorwin): Guard against this in supported types check and remove this. | 88 DCHECK(base::IsStringASCII(init_data_type)); |
| 89 // Chromium only supports ASCII MIME types. | |
| 90 if (!base::IsStringASCII(init_data_type)) { | |
| 91 NOTREACHED(); | |
| 92 OnSessionError(media::MediaKeys::NOT_SUPPORTED_ERROR, | |
| 93 0, | |
| 94 "The initialization data type " + init_data_type.utf8() + | |
| 95 " is not supported by the key system."); | |
| 96 return; | |
| 97 } | |
| 98 | 89 |
| 99 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); | 90 std::string init_data_type_as_ascii = base::UTF16ToASCII(init_data_type); |
| 100 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) | 91 DLOG_IF(WARNING, init_data_type_as_ascii.find('/') != std::string::npos) |
| 101 << "init_data_type '" << init_data_type_as_ascii | 92 << "init_data_type '" << init_data_type_as_ascii |
| 102 << "' may be a MIME type"; | 93 << "' may be a MIME type"; |
| 103 | 94 |
| 95 // Attempt to translate content types. |
| 96 // TODO(sandersd): Remove once tests stop using content types. |
| 97 // http://crbug.com/385874 |
| 98 if (init_data_type_as_ascii == "audio/mp4" || |
| 99 init_data_type_as_ascii == "video/mp4") { |
| 100 init_data_type_as_ascii = "cenc"; |
| 101 } else if (init_data_type_as_ascii == "audio/webm" || |
| 102 init_data_type_as_ascii == "video/webm") { |
| 103 init_data_type_as_ascii = "webm"; |
| 104 } |
| 105 |
| 104 scoped_ptr<media::NewSessionCdmPromise> promise( | 106 scoped_ptr<media::NewSessionCdmPromise> promise( |
| 105 new media::NewSessionCdmPromise( | 107 new media::NewSessionCdmPromise( |
| 106 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, | 108 base::Bind(&WebContentDecryptionModuleSessionImpl::SessionCreated, |
| 107 weak_ptr_factory_.GetWeakPtr(), | 109 weak_ptr_factory_.GetWeakPtr(), |
| 108 kReservedIndex), | 110 kReservedIndex), |
| 109 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError, | 111 base::Bind(&WebContentDecryptionModuleSessionImpl::OnSessionError, |
| 110 weak_ptr_factory_.GetWeakPtr()))); | 112 weak_ptr_factory_.GetWeakPtr()))); |
| 111 adapter_->InitializeNewSession(init_data_type_as_ascii, | 113 adapter_->InitializeNewSession(init_data_type_as_ascii, |
| 112 init_data, | 114 init_data, |
| 113 init_data_length, | 115 init_data_length, |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 300 |
| 299 uint32 WebContentDecryptionModuleSessionImpl::AddResult( | 301 uint32 WebContentDecryptionModuleSessionImpl::AddResult( |
| 300 blink::WebContentDecryptionModuleResult result) { | 302 blink::WebContentDecryptionModuleResult result) { |
| 301 uint32 result_index = next_available_result_index_++; | 303 uint32 result_index = next_available_result_index_++; |
| 302 DCHECK(result_index != kReservedIndex); | 304 DCHECK(result_index != kReservedIndex); |
| 303 outstanding_results_.insert(std::make_pair(result_index, result)); | 305 outstanding_results_.insert(std::make_pair(result_index, result)); |
| 304 return result_index; | 306 return result_index; |
| 305 } | 307 } |
| 306 | 308 |
| 307 } // namespace content | 309 } // namespace content |
| OLD | NEW |