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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { | 103 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { |
104 Module* module_singleton = Module::Get(); | 104 Module* module_singleton = Module::Get(); |
105 if (!module_singleton) | 105 if (!module_singleton) |
106 return; | 106 return; |
107 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 107 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
108 if (!instance) | 108 if (!instance) |
109 return; | 109 return; |
110 instance->DidChangeFocus(PP_ToBool(has_focus)); | 110 instance->DidChangeFocus(PP_ToBool(has_focus)); |
111 } | 111 } |
112 | 112 |
113 PP_Bool Instance_HandleInputEvent(PP_Instance pp_instance, | |
114 const PP_InputEvent* event) { | |
115 Module* module_singleton = Module::Get(); | |
116 if (!module_singleton) | |
117 return PP_FALSE; | |
118 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | |
119 if (!instance) | |
120 return PP_FALSE; | |
121 return PP_FromBool(instance->HandleInputEvent(*event)); | |
122 } | |
123 | |
124 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 113 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
125 PP_Resource pp_url_loader) { | 114 PP_Resource pp_url_loader) { |
126 Module* module_singleton = Module::Get(); | 115 Module* module_singleton = Module::Get(); |
127 if (!module_singleton) | 116 if (!module_singleton) |
128 return PP_FALSE; | 117 return PP_FALSE; |
129 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 118 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
130 if (!instance) | 119 if (!instance) |
131 return PP_FALSE; | 120 return PP_FALSE; |
132 return PP_FromBool(instance->HandleDocumentLoad(URLLoader(pp_url_loader))); | 121 return PP_FromBool(instance->HandleDocumentLoad(URLLoader(pp_url_loader))); |
133 } | 122 } |
134 | 123 |
135 static PPP_Instance instance_interface = { | 124 static PPP_Instance instance_interface = { |
136 &Instance_DidCreate, | 125 &Instance_DidCreate, |
137 &Instance_DidDestroy, | 126 &Instance_DidDestroy, |
138 &Instance_DidChangeView, | 127 &Instance_DidChangeView, |
139 &Instance_DidChangeFocus, | 128 &Instance_DidChangeFocus, |
140 &Instance_HandleInputEvent, | |
141 &Instance_HandleDocumentLoad | 129 &Instance_HandleDocumentLoad |
142 }; | 130 }; |
143 | 131 |
144 // PPP_Messaging implementation ------------------------------------------------ | 132 // PPP_Messaging implementation ------------------------------------------------ |
145 | 133 |
146 void Messaging_HandleMessage(PP_Instance pp_instance, PP_Var var) { | 134 void Messaging_HandleMessage(PP_Instance pp_instance, PP_Var var) { |
147 Module* module_singleton = Module::Get(); | 135 Module* module_singleton = Module::Get(); |
148 if (!module_singleton) | 136 if (!module_singleton) |
149 return; | 137 return; |
150 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 138 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 const PPB_Core* core = reinterpret_cast<const PPB_Core*>(GetBrowserInterface( | 210 const PPB_Core* core = reinterpret_cast<const PPB_Core*>(GetBrowserInterface( |
223 PPB_CORE_INTERFACE)); | 211 PPB_CORE_INTERFACE)); |
224 if (!core) | 212 if (!core) |
225 return false; | 213 return false; |
226 core_ = new Core(core); | 214 core_ = new Core(core); |
227 | 215 |
228 return Init(); | 216 return Init(); |
229 } | 217 } |
230 | 218 |
231 } // namespace pp | 219 } // namespace pp |
OLD | NEW |