OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pepper/content_decryptor_delegate.h" | 5 #include "content/renderer/pepper/content_decryptor_delegate.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); | 584 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); |
585 return; | 585 return; |
586 } | 586 } |
587 | 587 |
588 session_created_cb_.Run(session_id, session_id_string->value()); | 588 session_created_cb_.Run(session_id, session_id_string->value()); |
589 } | 589 } |
590 | 590 |
591 void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, | 591 void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, |
592 PP_Var message_var, | 592 PP_Var message_var, |
593 PP_Var default_url_var) { | 593 PP_Var default_url_var) { |
| 594 // TODO(amogh.bihani): Replace all the default_url with destination_url. |
594 if (session_message_cb_.is_null()) | 595 if (session_message_cb_.is_null()) |
595 return; | 596 return; |
596 | 597 |
597 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); | 598 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); |
598 | 599 |
599 std::vector<uint8> message; | 600 std::vector<uint8> message; |
600 if (message_array_buffer) { | 601 if (message_array_buffer) { |
601 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); | 602 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); |
602 message.assign(data, data + message_array_buffer->ByteLength()); | 603 message.assign(data, data + message_array_buffer->ByteLength()); |
603 } | 604 } |
604 | 605 |
605 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); | 606 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); |
606 | 607 |
607 if (!default_url_string) { | 608 if (!default_url_string) { |
608 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); | 609 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); |
609 return; | 610 return; |
610 } | 611 } |
611 | 612 |
612 session_message_cb_.Run(session_id, message, default_url_string->value()); | 613 GURL verified_gurl = GURL(default_url_string->value()); |
| 614 if (!verified_gurl.is_valid() && !verified_gurl.is_empty()) { |
| 615 DLOG(WARNING) << "SessionMessage default_url is invalid : " |
| 616 << verified_gurl.possibly_invalid_spec(); |
| 617 verified_gurl = GURL::EmptyGURL(); // Replace invalid default_url. |
| 618 } |
| 619 |
| 620 session_message_cb_.Run(session_id, message, verified_gurl); |
613 } | 621 } |
614 | 622 |
615 void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) { | 623 void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) { |
616 if (session_ready_cb_.is_null()) | 624 if (session_ready_cb_.is_null()) |
617 return; | 625 return; |
618 | 626 |
619 session_ready_cb_.Run(session_id); | 627 session_ready_cb_.Run(session_id); |
620 } | 628 } |
621 | 629 |
622 void ContentDecryptorDelegate::OnSessionClosed(uint32 session_id) { | 630 void ContentDecryptorDelegate::OnSessionClosed(uint32 session_id) { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 const media::Decryptor::AudioBuffers empty_frames; | 1064 const media::Decryptor::AudioBuffers empty_frames; |
1057 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, | 1065 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, |
1058 empty_frames); | 1066 empty_frames); |
1059 } | 1067 } |
1060 | 1068 |
1061 if (!video_decode_cb_.is_null()) | 1069 if (!video_decode_cb_.is_null()) |
1062 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1070 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
1063 } | 1071 } |
1064 | 1072 |
1065 } // namespace content | 1073 } // namespace content |
OLD | NEW |