| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Native Client 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 <stdio.h> | |
| 6 #include "native_client/tests/fake_browser_ppapi/fake_instance.h" | |
| 7 | |
| 8 #include "native_client/src/include/nacl_macros.h" | |
| 9 #include "native_client/src/include/portability.h" | |
| 10 #include "native_client/tests/fake_browser_ppapi/fake_window.h" | |
| 11 #include "native_client/tests/fake_browser_ppapi/utility.h" | |
| 12 #include "ppapi/c/ppb_instance.h" | |
| 13 #include "ppapi/c/private/ppb_instance_private.h" | |
| 14 | |
| 15 using fake_browser_ppapi::DebugPrintf; | |
| 16 | |
| 17 namespace fake_browser_ppapi { | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 static PP_Bool BindGraphics(PP_Instance instance, PP_Resource device) { | |
| 22 return static_cast<PP_Bool>(GetInstance(instance)->BindGraphics(device)); | |
| 23 } | |
| 24 | |
| 25 static PP_Bool IsFullFrame(PP_Instance instance) { | |
| 26 return static_cast<PP_Bool>(GetInstance(instance)->IsFullFrame()); | |
| 27 } | |
| 28 | |
| 29 static PP_Var GetWindowObject(PP_Instance instance) { | |
| 30 return GetInstance(instance)->GetWindowObject(); | |
| 31 } | |
| 32 | |
| 33 static PP_Var GetOwnerElementObject(PP_Instance instance) { | |
| 34 return GetInstance(instance)->GetOwnerElementObject(); | |
| 35 } | |
| 36 | |
| 37 static PP_Var ExecuteScript(PP_Instance instance, | |
| 38 PP_Var script, | |
| 39 PP_Var* exception) { | |
| 40 return GetInstance(instance)->ExecuteScript(script, exception); | |
| 41 } | |
| 42 | |
| 43 } // namespace | |
| 44 | |
| 45 Instance Instance::kInvalidInstance; | |
| 46 | |
| 47 PP_Var Instance::GetWindowObject() { | |
| 48 DebugPrintf("Instance::GetWindowObject: instance=%"NACL_PRId32"\n", | |
| 49 instance_id_); | |
| 50 if (window_) | |
| 51 return window_->FakeWindowObject(); | |
| 52 else | |
| 53 return PP_MakeUndefined(); | |
| 54 } | |
| 55 | |
| 56 PP_Var Instance::GetOwnerElementObject() { | |
| 57 DebugPrintf("Instance::GetOwnerElementObject: instance=%"NACL_PRId32"\n", | |
| 58 instance_id_); | |
| 59 NACL_UNIMPLEMENTED(); | |
| 60 return PP_MakeUndefined(); | |
| 61 } | |
| 62 | |
| 63 bool Instance::BindGraphics(PP_Resource device) { | |
| 64 DebugPrintf("Instance::BindGraphicsDeviceContext: instance=%"NACL_PRId32"\n", | |
| 65 ", device=%"NACL_PRIu32"\n", | |
| 66 instance_id_, | |
| 67 device); | |
| 68 NACL_UNIMPLEMENTED(); | |
| 69 return false; | |
| 70 } | |
| 71 | |
| 72 bool Instance::IsFullFrame() { | |
| 73 DebugPrintf("Instance::IsFullFrame: instance=%"NACL_PRId32"\n", | |
| 74 instance_id_); | |
| 75 NACL_UNIMPLEMENTED(); | |
| 76 return false; | |
| 77 } | |
| 78 | |
| 79 PP_Var Instance::ExecuteScript(PP_Var script, | |
| 80 PP_Var* exception) { | |
| 81 DebugPrintf("Instance::ExecuteScript: instance=%"NACL_PRId32"\n", | |
| 82 instance_id_); | |
| 83 NACL_UNIMPLEMENTED(); | |
| 84 UNREFERENCED_PARAMETER(script); | |
| 85 UNREFERENCED_PARAMETER(exception); | |
| 86 return PP_MakeUndefined(); | |
| 87 } | |
| 88 | |
| 89 #ifdef PPAPI_INSTANCE_REMOVE_SCRIPTING | |
| 90 const PPB_Instance* Instance::GetInterface() { | |
| 91 static const PPB_Instance instance_interface = { | |
| 92 fake_browser_ppapi::BindGraphics, | |
| 93 fake_browser_ppapi::IsFullFrame | |
| 94 }; | |
| 95 return &instance_interface; | |
| 96 } | |
| 97 #else | |
| 98 const PPB_Instance* Instance::GetInterface() { | |
| 99 static const PPB_Instance instance_interface = { | |
| 100 fake_browser_ppapi::GetWindowObject, | |
| 101 fake_browser_ppapi::GetOwnerElementObject, | |
| 102 fake_browser_ppapi::BindGraphics, | |
| 103 fake_browser_ppapi::IsFullFrame, | |
| 104 fake_browser_ppapi::ExecuteScript | |
| 105 }; | |
| 106 return &instance_interface; | |
| 107 } | |
| 108 #endif | |
| 109 | |
| 110 const PPB_Instance_Private* Instance::GetPrivateInterface() { | |
| 111 static const PPB_Instance_Private instance_interface = { | |
| 112 fake_browser_ppapi::GetWindowObject, | |
| 113 fake_browser_ppapi::GetOwnerElementObject, | |
| 114 fake_browser_ppapi::ExecuteScript | |
| 115 }; | |
| 116 return &instance_interface; | |
| 117 } | |
| 118 | |
| 119 } // namespace fake_browser_ppapi | |
| OLD | NEW |