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