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 "webcontentdecryptionmodulesession_impl.h" | 5 #include "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/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // passing it to the CDM. At a minimum, this should include checking that | 163 // passing it to the CDM. At a minimum, this should include checking that |
164 // the length and value (e.g. alphanumeric) are reasonable. | 164 // the length and value (e.g. alphanumeric) are reasonable. |
165 if (!base::IsStringASCII(session_id)) | 165 if (!base::IsStringASCII(session_id)) |
166 return false; | 166 return false; |
167 | 167 |
168 sanitized_session_id->assign(base::UTF16ToASCII(session_id)); | 168 sanitized_session_id->assign(base::UTF16ToASCII(session_id)); |
169 if (sanitized_session_id->length() > limits::kMaxSessionIdLength) | 169 if (sanitized_session_id->length() > limits::kMaxSessionIdLength) |
170 return false; | 170 return false; |
171 | 171 |
172 for (const char c : *sanitized_session_id) { | 172 for (const char c : *sanitized_session_id) { |
173 if (!IsAsciiAlpha(c) && !IsAsciiDigit(c)) | 173 if (!base::IsAsciiAlpha(c) && !base::IsAsciiDigit(c)) |
174 return false; | 174 return false; |
175 } | 175 } |
176 | 176 |
177 return true; | 177 return true; |
178 } | 178 } |
179 | 179 |
180 static bool SanitizeResponse(const std::string& key_system, | 180 static bool SanitizeResponse(const std::string& key_system, |
181 const uint8* response, | 181 const uint8* response, |
182 size_t response_length, | 182 size_t response_length, |
183 std::vector<uint8>* sanitized_response) { | 183 std::vector<uint8>* sanitized_response) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 return blink::WebContentDecryptionModuleResult::SessionNotFound; | 416 return blink::WebContentDecryptionModuleResult::SessionNotFound; |
417 | 417 |
418 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; | 418 DCHECK(session_id_.empty()) << "Session ID may not be changed once set."; |
419 session_id_ = session_id; | 419 session_id_ = session_id; |
420 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) | 420 return adapter_->RegisterSession(session_id_, weak_ptr_factory_.GetWeakPtr()) |
421 ? blink::WebContentDecryptionModuleResult::NewSession | 421 ? blink::WebContentDecryptionModuleResult::NewSession |
422 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; | 422 : blink::WebContentDecryptionModuleResult::SessionAlreadyExists; |
423 } | 423 } |
424 | 424 |
425 } // namespace media | 425 } // namespace media |
OLD | NEW |