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/cpp/private/platform_verification.h" | 5 #include "ppapi/cpp/private/platform_verification.h" |
6 | 6 |
7 #include "ppapi/c/pp_bool.h" | 7 #include "ppapi/c/pp_bool.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/c/private/ppb_platform_verification_private.h" | 9 #include "ppapi/c/private/ppb_platform_verification_private.h" |
10 #include "ppapi/cpp/instance_handle.h" | 10 #include "ppapi/cpp/instance_handle.h" |
11 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
12 #include "ppapi/cpp/var.h" | 12 #include "ppapi/cpp/var.h" |
13 | 13 |
14 namespace pp { | 14 namespace pp { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 template <> const char* interface_name<PPB_PlatformVerification_Private_0_1>() { | 18 template <> const char* interface_name<PPB_PlatformVerification_Private_0_2>() { |
19 return PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1; | 19 return PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_2; |
20 } | 20 } |
21 | 21 |
22 inline bool HasInterface() { | 22 inline bool HasInterface() { |
23 return has_interface<PPB_PlatformVerification_Private_0_1>(); | 23 return has_interface<PPB_PlatformVerification_Private_0_2>(); |
24 } | 24 } |
25 | 25 |
26 inline const PPB_PlatformVerification_Private_0_1* GetInterface() { | 26 inline const PPB_PlatformVerification_Private_0_2* GetInterface() { |
27 return get_interface<PPB_PlatformVerification_Private_0_1>(); | 27 return get_interface<PPB_PlatformVerification_Private_0_2>(); |
28 } | 28 } |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 PlatformVerification::PlatformVerification(const InstanceHandle& instance) { | 32 PlatformVerification::PlatformVerification(const InstanceHandle& instance) { |
33 if (HasInterface()) | 33 if (HasInterface()) |
34 PassRefFromConstructor(GetInterface()->Create(instance.pp_instance())); | 34 PassRefFromConstructor(GetInterface()->Create(instance.pp_instance())); |
35 } | 35 } |
36 | 36 |
37 PlatformVerification::~PlatformVerification() {} | 37 PlatformVerification::~PlatformVerification() {} |
38 | 38 |
39 int32_t PlatformVerification::CanChallengePlatform( | |
40 const CompletionCallbackWithOutput<bool>& callback) { | |
41 if (!HasInterface()) | |
42 return callback.MayForce(PP_ERROR_NOINTERFACE); | |
43 | |
44 return GetInterface()->CanChallengePlatform( | |
45 pp_resource(), callback.output(), callback.pp_completion_callback()); | |
46 } | |
47 | |
48 int32_t PlatformVerification::ChallengePlatform( | 39 int32_t PlatformVerification::ChallengePlatform( |
49 const Var& service_id, | 40 const Var& service_id, |
50 const Var& challenge, | 41 const Var& challenge, |
51 Var* signed_data, | 42 Var* signed_data, |
52 Var* signed_data_signature, | 43 Var* signed_data_signature, |
53 Var* platform_key_certificate, | 44 Var* platform_key_certificate, |
54 const CompletionCallback& callback) { | 45 const CompletionCallback& callback) { |
55 if (!HasInterface()) | 46 if (!HasInterface()) |
56 return callback.MayForce(PP_ERROR_NOINTERFACE); | 47 return callback.MayForce(PP_ERROR_NOINTERFACE); |
57 | 48 |
58 return GetInterface()->ChallengePlatform( | 49 return GetInterface()->ChallengePlatform( |
59 pp_resource(), service_id.pp_var(), challenge.pp_var(), | 50 pp_resource(), service_id.pp_var(), challenge.pp_var(), |
60 const_cast<PP_Var*>(&signed_data->pp_var()), | 51 const_cast<PP_Var*>(&signed_data->pp_var()), |
61 const_cast<PP_Var*>(&signed_data_signature->pp_var()), | 52 const_cast<PP_Var*>(&signed_data_signature->pp_var()), |
62 const_cast<PP_Var*>(&platform_key_certificate->pp_var()), | 53 const_cast<PP_Var*>(&platform_key_certificate->pp_var()), |
63 callback.pp_completion_callback()); | 54 callback.pp_completion_callback()); |
64 } | 55 } |
65 | 56 |
66 } // namespace pp | 57 } // namespace pp |
OLD | NEW |