| 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 "ppapi/proxy/platform_verification_private_resource.h" | 5 #include "ppapi/proxy/platform_verification_private_resource.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/proxy/dispatch_reply_message.h" | 9 #include "ppapi/proxy/dispatch_reply_message.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 SendCreate(BROWSER, PpapiHostMsg_PlatformVerification_Create()); | 23 SendCreate(BROWSER, PpapiHostMsg_PlatformVerification_Create()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 PlatformVerificationPrivateResource::~PlatformVerificationPrivateResource() {} | 26 PlatformVerificationPrivateResource::~PlatformVerificationPrivateResource() {} |
| 27 | 27 |
| 28 thunk::PPB_PlatformVerification_API* | 28 thunk::PPB_PlatformVerification_API* |
| 29 PlatformVerificationPrivateResource::AsPPB_PlatformVerification_API() { | 29 PlatformVerificationPrivateResource::AsPPB_PlatformVerification_API() { |
| 30 return this; | 30 return this; |
| 31 } | 31 } |
| 32 | 32 |
| 33 int32_t PlatformVerificationPrivateResource::CanChallengePlatform( | |
| 34 PP_Bool* can_challenge_platform, | |
| 35 const scoped_refptr<TrackedCallback>& callback) { | |
| 36 if (!can_challenge_platform) | |
| 37 return PP_ERROR_BADARGUMENT; | |
| 38 | |
| 39 Call<PpapiHostMsg_PlatformVerification_CanChallengePlatformReply>( | |
| 40 BROWSER, PpapiHostMsg_PlatformVerification_CanChallengePlatform(), | |
| 41 base::Bind( | |
| 42 &PlatformVerificationPrivateResource::OnCanChallengePlatformReply, | |
| 43 base::Unretained(this), can_challenge_platform, callback)); | |
| 44 | |
| 45 return PP_OK_COMPLETIONPENDING; | |
| 46 } | |
| 47 | |
| 48 void PlatformVerificationPrivateResource::OnCanChallengePlatformReply( | |
| 49 PP_Bool* can_challenge_platform, | |
| 50 const scoped_refptr<TrackedCallback>& callback, | |
| 51 const ResourceMessageReplyParams& params, | |
| 52 bool can_challenge_platform_response) { | |
| 53 if (!TrackedCallback::IsPending(callback) || | |
| 54 TrackedCallback::IsScheduledToRun(callback)) { | |
| 55 return; | |
| 56 } | |
| 57 | |
| 58 *can_challenge_platform = PP_FromBool(can_challenge_platform_response); | |
| 59 callback->Run(params.result()); | |
| 60 } | |
| 61 | |
| 62 int32_t PlatformVerificationPrivateResource::ChallengePlatform( | 33 int32_t PlatformVerificationPrivateResource::ChallengePlatform( |
| 63 const PP_Var& service_id, | 34 const PP_Var& service_id, |
| 64 const PP_Var& challenge, | 35 const PP_Var& challenge, |
| 65 PP_Var* signed_data, | 36 PP_Var* signed_data, |
| 66 PP_Var* signed_data_signature, | 37 PP_Var* signed_data_signature, |
| 67 PP_Var* platform_key_certificate, | 38 PP_Var* platform_key_certificate, |
| 68 const scoped_refptr<TrackedCallback>& callback) { | 39 const scoped_refptr<TrackedCallback>& callback) { |
| 69 // Prevent null types for obvious reasons, but also ref-counted types to avoid | 40 // Prevent null types for obvious reasons, but also ref-counted types to avoid |
| 70 // leaks on challenge failures (since they're only written to on success). | 41 // leaks on challenge failures (since they're only written to on success). |
| 71 if (!signed_data || !signed_data_signature || !platform_key_certificate || | 42 if (!signed_data || !signed_data_signature || !platform_key_certificate || |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 raw_signed_data_signature.size(), | 94 raw_signed_data_signature.size(), |
| 124 &raw_signed_data_signature.front()))->GetPPVar(); | 95 &raw_signed_data_signature.front()))->GetPPVar(); |
| 125 *(output_params.platform_key_certificate) = | 96 *(output_params.platform_key_certificate) = |
| 126 (new StringVar(raw_platform_key_certificate))->GetPPVar(); | 97 (new StringVar(raw_platform_key_certificate))->GetPPVar(); |
| 127 } | 98 } |
| 128 output_params.callback->Run(params.result()); | 99 output_params.callback->Run(params.result()); |
| 129 } | 100 } |
| 130 | 101 |
| 131 } // namespace proxy | 102 } // namespace proxy |
| 132 } // namespace ppapi | 103 } // namespace ppapi |
| OLD | NEW |