OLD | NEW |
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/key_system_config_selector.h" | 5 #include "media/blink/key_system_config_selector.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 | 718 |
719 std::string key_system_ascii = | 719 std::string key_system_ascii = |
720 base::UTF16ToASCII(base::StringPiece16(key_system)); | 720 base::UTF16ToASCII(base::StringPiece16(key_system)); |
721 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) { | 721 if (!key_systems_->IsSupportedKeySystem(key_system_ascii)) { |
722 not_supported_cb.Run("Unsupported keySystem"); | 722 not_supported_cb.Run("Unsupported keySystem"); |
723 return; | 723 return; |
724 } | 724 } |
725 | 725 |
726 // 7.2-7.4. Implemented by OnSelectConfig(). | 726 // 7.2-7.4. Implemented by OnSelectConfig(). |
727 // TODO(sandersd): This should be async, ideally not on the main thread. | 727 // TODO(sandersd): This should be async, ideally not on the main thread. |
728 scoped_ptr<SelectionRequest> request(new SelectionRequest()); | 728 std::unique_ptr<SelectionRequest> request(new SelectionRequest()); |
729 request->key_system = key_system_ascii; | 729 request->key_system = key_system_ascii; |
730 request->candidate_configurations = candidate_configurations; | 730 request->candidate_configurations = candidate_configurations; |
731 request->security_origin = security_origin; | 731 request->security_origin = security_origin; |
732 request->are_secure_codecs_supported = are_secure_codecs_supported; | 732 request->are_secure_codecs_supported = are_secure_codecs_supported; |
733 request->succeeded_cb = succeeded_cb; | 733 request->succeeded_cb = succeeded_cb; |
734 request->not_supported_cb = not_supported_cb; | 734 request->not_supported_cb = not_supported_cb; |
735 SelectConfigInternal(std::move(request)); | 735 SelectConfigInternal(std::move(request)); |
736 } | 736 } |
737 | 737 |
738 void KeySystemConfigSelector::SelectConfigInternal( | 738 void KeySystemConfigSelector::SelectConfigInternal( |
739 scoped_ptr<SelectionRequest> request) { | 739 std::unique_ptr<SelectionRequest> request) { |
740 // Continued from requestMediaKeySystemAccess(), step 7.1, from | 740 // Continued from requestMediaKeySystemAccess(), step 7.1, from |
741 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess | 741 // https://w3c.github.io/encrypted-media/#requestmediakeysystemaccess |
742 // | 742 // |
743 // 7.2. Let implementation be the implementation of keySystem. | 743 // 7.2. Let implementation be the implementation of keySystem. |
744 // (|key_systems_| fills this role.) | 744 // (|key_systems_| fills this role.) |
745 // 7.3. For each value in supportedConfigurations: | 745 // 7.3. For each value in supportedConfigurations: |
746 for (size_t i = 0; i < request->candidate_configurations.size(); i++) { | 746 for (size_t i = 0; i < request->candidate_configurations.size(); i++) { |
747 // 7.3.1. Let candidate configuration be the value. | 747 // 7.3.1. Let candidate configuration be the value. |
748 // 7.3.2. Let supported configuration be the result of executing the Get | 748 // 7.3.2. Let supported configuration be the result of executing the Get |
749 // Supported Configuration algorithm on implementation, candidate | 749 // Supported Configuration algorithm on implementation, candidate |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 } | 795 } |
796 } | 796 } |
797 | 797 |
798 // 7.4. Reject promise with a new DOMException whose name is | 798 // 7.4. Reject promise with a new DOMException whose name is |
799 // NotSupportedError. | 799 // NotSupportedError. |
800 request->not_supported_cb.Run( | 800 request->not_supported_cb.Run( |
801 "None of the requested configurations were supported."); | 801 "None of the requested configurations were supported."); |
802 } | 802 } |
803 | 803 |
804 void KeySystemConfigSelector::OnPermissionResult( | 804 void KeySystemConfigSelector::OnPermissionResult( |
805 scoped_ptr<SelectionRequest> request, | 805 std::unique_ptr<SelectionRequest> request, |
806 bool is_permission_granted) { | 806 bool is_permission_granted) { |
807 request->was_permission_requested = true; | 807 request->was_permission_requested = true; |
808 request->is_permission_granted = is_permission_granted; | 808 request->is_permission_granted = is_permission_granted; |
809 SelectConfigInternal(std::move(request)); | 809 SelectConfigInternal(std::move(request)); |
810 } | 810 } |
811 | 811 |
812 } // namespace media | 812 } // namespace media |
OLD | NEW |