| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Note that the single accessor, Module::Get(), is not actually implemented | 5 // Note that the single accessor, Module::Get(), is not actually implemented |
| 6 // in this file. This is an intentional hook that allows users of ppapi's | 6 // in this file. This is an intentional hook that allows users of ppapi's |
| 7 // C++ wrapper objects to provide difference semantics for how the singleton | 7 // C++ wrapper objects to provide difference semantics for how the singleton |
| 8 // object is accessed. | 8 // object is accessed. |
| 9 // | 9 // |
| 10 // In general, users of ppapi will also link in ppp_entrypoints.cc, which | 10 // In general, users of ppapi will also link in ppp_entrypoints.cc, which |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 #include "ppapi/cpp/module.h" | 24 #include "ppapi/cpp/module.h" |
| 25 | 25 |
| 26 #include <string.h> | 26 #include <string.h> |
| 27 | 27 |
| 28 #include "ppapi/c/pp_instance.h" | 28 #include "ppapi/c/pp_instance.h" |
| 29 #include "ppapi/c/pp_var.h" | 29 #include "ppapi/c/pp_var.h" |
| 30 #include "ppapi/c/ppp_input_event.h" | 30 #include "ppapi/c/ppp_input_event.h" |
| 31 #include "ppapi/c/ppp_instance.h" | 31 #include "ppapi/c/ppp_instance.h" |
| 32 #include "ppapi/c/ppp_messaging.h" | 32 #include "ppapi/c/ppp_messaging.h" |
| 33 #include "ppapi/cpp/common.h" | |
| 34 #include "ppapi/cpp/input_event.h" | 33 #include "ppapi/cpp/input_event.h" |
| 35 #include "ppapi/cpp/instance.h" | 34 #include "ppapi/cpp/instance.h" |
| 36 #include "ppapi/cpp/rect.h" | 35 #include "ppapi/cpp/rect.h" |
| 37 #include "ppapi/cpp/resource.h" | 36 #include "ppapi/cpp/resource.h" |
| 38 #include "ppapi/cpp/url_loader.h" | 37 #include "ppapi/cpp/url_loader.h" |
| 39 #include "ppapi/cpp/var.h" | 38 #include "ppapi/cpp/var.h" |
| 40 | 39 |
| 41 namespace pp { | 40 namespace pp { |
| 42 | 41 |
| 43 // PPP_InputEvent implementation ----------------------------------------------- | 42 // PPP_InputEvent implementation ----------------------------------------------- |
| 44 | 43 |
| 45 PP_Bool InputEvent_HandleEvent(PP_Instance pp_instance, PP_Resource resource) { | 44 PP_Bool InputEvent_HandleEvent(PP_Instance pp_instance, PP_Resource resource) { |
| 46 Module* module_singleton = Module::Get(); | 45 Module* module_singleton = Module::Get(); |
| 47 if (!module_singleton) | 46 if (!module_singleton) |
| 48 return PP_FALSE; | 47 return PP_FALSE; |
| 49 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 48 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
| 50 if (!instance) | 49 if (!instance) |
| 51 return PP_FALSE; | 50 return PP_FALSE; |
| 52 | 51 |
| 53 return BoolToPPBool(instance->HandleInputEvent(InputEvent(resource))); | 52 return PP_FromBool(instance->HandleInputEvent(InputEvent(resource))); |
| 54 } | 53 } |
| 55 | 54 |
| 56 const PPP_InputEvent input_event_interface = { | 55 const PPP_InputEvent input_event_interface = { |
| 57 &InputEvent_HandleEvent | 56 &InputEvent_HandleEvent |
| 58 }; | 57 }; |
| 59 | 58 |
| 60 // PPP_Instance implementation ------------------------------------------------- | 59 // PPP_Instance implementation ------------------------------------------------- |
| 61 | 60 |
| 62 PP_Bool Instance_DidCreate(PP_Instance pp_instance, | 61 PP_Bool Instance_DidCreate(PP_Instance pp_instance, |
| 63 uint32_t argc, | 62 uint32_t argc, |
| 64 const char* argn[], | 63 const char* argn[], |
| 65 const char* argv[]) { | 64 const char* argv[]) { |
| 66 Module* module_singleton = Module::Get(); | 65 Module* module_singleton = Module::Get(); |
| 67 if (!module_singleton) | 66 if (!module_singleton) |
| 68 return PP_FALSE; | 67 return PP_FALSE; |
| 69 | 68 |
| 70 Instance* instance = module_singleton->CreateInstance(pp_instance); | 69 Instance* instance = module_singleton->CreateInstance(pp_instance); |
| 71 if (!instance) | 70 if (!instance) |
| 72 return PP_FALSE; | 71 return PP_FALSE; |
| 73 module_singleton->current_instances_[pp_instance] = instance; | 72 module_singleton->current_instances_[pp_instance] = instance; |
| 74 return BoolToPPBool(instance->Init(argc, argn, argv)); | 73 return PP_FromBool(instance->Init(argc, argn, argv)); |
| 75 } | 74 } |
| 76 | 75 |
| 77 void Instance_DidDestroy(PP_Instance instance) { | 76 void Instance_DidDestroy(PP_Instance instance) { |
| 78 Module* module_singleton = Module::Get(); | 77 Module* module_singleton = Module::Get(); |
| 79 if (!module_singleton) | 78 if (!module_singleton) |
| 80 return; | 79 return; |
| 81 Module::InstanceMap::iterator found = | 80 Module::InstanceMap::iterator found = |
| 82 module_singleton->current_instances_.find(instance); | 81 module_singleton->current_instances_.find(instance); |
| 83 if (found == module_singleton->current_instances_.end()) | 82 if (found == module_singleton->current_instances_.end()) |
| 84 return; | 83 return; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 101 instance->DidChangeView(*position, *clip); | 100 instance->DidChangeView(*position, *clip); |
| 102 } | 101 } |
| 103 | 102 |
| 104 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { | 103 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { |
| 105 Module* module_singleton = Module::Get(); | 104 Module* module_singleton = Module::Get(); |
| 106 if (!module_singleton) | 105 if (!module_singleton) |
| 107 return; | 106 return; |
| 108 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 107 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
| 109 if (!instance) | 108 if (!instance) |
| 110 return; | 109 return; |
| 111 instance->DidChangeFocus(PPBoolToBool(has_focus)); | 110 instance->DidChangeFocus(PP_ToBool(has_focus)); |
| 112 } | 111 } |
| 113 | 112 |
| 114 PP_Bool Instance_HandleInputEvent(PP_Instance pp_instance, | 113 PP_Bool Instance_HandleInputEvent(PP_Instance pp_instance, |
| 115 const PP_InputEvent* event) { | 114 const PP_InputEvent* event) { |
| 116 Module* module_singleton = Module::Get(); | 115 Module* module_singleton = Module::Get(); |
| 117 if (!module_singleton) | 116 if (!module_singleton) |
| 118 return PP_FALSE; | 117 return PP_FALSE; |
| 119 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 118 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
| 120 if (!instance) | 119 if (!instance) |
| 121 return PP_FALSE; | 120 return PP_FALSE; |
| 122 return BoolToPPBool(instance->HandleInputEvent(*event)); | 121 return PP_FromBool(instance->HandleInputEvent(*event)); |
| 123 } | 122 } |
| 124 | 123 |
| 125 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 124 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
| 126 PP_Resource pp_url_loader) { | 125 PP_Resource pp_url_loader) { |
| 127 Module* module_singleton = Module::Get(); | 126 Module* module_singleton = Module::Get(); |
| 128 if (!module_singleton) | 127 if (!module_singleton) |
| 129 return PP_FALSE; | 128 return PP_FALSE; |
| 130 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 129 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
| 131 if (!instance) | 130 if (!instance) |
| 132 return PP_FALSE; | 131 return PP_FALSE; |
| 133 return BoolToPPBool( | 132 return PP_FromBool(instance->HandleDocumentLoad(URLLoader(pp_url_loader))); |
| 134 instance->HandleDocumentLoad(URLLoader(pp_url_loader))); | |
| 135 } | 133 } |
| 136 | 134 |
| 137 #ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING | 135 #ifndef PPAPI_INSTANCE_REMOVE_SCRIPTING |
| 138 PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { | 136 PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { |
| 139 Module* module_singleton = Module::Get(); | 137 Module* module_singleton = Module::Get(); |
| 140 if (!module_singleton) | 138 if (!module_singleton) |
| 141 return Var().Detach(); | 139 return Var().Detach(); |
| 142 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 140 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
| 143 if (!instance) | 141 if (!instance) |
| 144 return Var().Detach(); | 142 return Var().Detach(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 const PPB_Core* core = reinterpret_cast<const PPB_Core*>(GetBrowserInterface( | 237 const PPB_Core* core = reinterpret_cast<const PPB_Core*>(GetBrowserInterface( |
| 240 PPB_CORE_INTERFACE)); | 238 PPB_CORE_INTERFACE)); |
| 241 if (!core) | 239 if (!core) |
| 242 return false; | 240 return false; |
| 243 core_ = new Core(core); | 241 core_ = new Core(core); |
| 244 | 242 |
| 245 return Init(); | 243 return Init(); |
| 246 } | 244 } |
| 247 | 245 |
| 248 } // namespace pp | 246 } // namespace pp |
| OLD | NEW |