OLD | NEW |
1 // Copyright (c) 2010 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 |
11 // provides a simple default implementation of Module::Get(). | 11 // provides a simple default implementation of Module::Get(). |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { | 117 PP_Var Instance_GetInstanceObject(PP_Instance pp_instance) { |
118 Module* module_singleton = Module::Get(); | 118 Module* module_singleton = Module::Get(); |
119 if (!module_singleton) | 119 if (!module_singleton) |
120 return Var().Detach(); | 120 return Var().Detach(); |
121 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); | 121 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
122 if (!instance) | 122 if (!instance) |
123 return Var().Detach(); | 123 return Var().Detach(); |
124 return instance->GetInstanceObject().Detach(); | 124 return instance->GetInstanceObject().Detach(); |
125 } | 125 } |
126 | 126 |
| 127 void Instance_HandleMessage(PP_Instance pp_instance, PP_Var var) { |
| 128 Module* module_singleton = Module::Get(); |
| 129 if (!module_singleton) |
| 130 return; |
| 131 Instance* instance = module_singleton->InstanceForPPInstance(pp_instance); |
| 132 if (!instance) |
| 133 return; |
| 134 instance->HandleMessage(Var(Var::PassRef(), var)); |
| 135 } |
| 136 |
127 static PPP_Instance instance_interface = { | 137 static PPP_Instance instance_interface = { |
128 &Instance_DidCreate, | 138 &Instance_DidCreate, |
129 &Instance_DidDestroy, | 139 &Instance_DidDestroy, |
130 &Instance_DidChangeView, | 140 &Instance_DidChangeView, |
131 &Instance_DidChangeFocus, | 141 &Instance_DidChangeFocus, |
132 &Instance_HandleInputEvent, | 142 &Instance_HandleInputEvent, |
133 &Instance_HandleDocumentLoad, | 143 &Instance_HandleDocumentLoad, |
134 &Instance_GetInstanceObject | 144 &Instance_GetInstanceObject, |
| 145 &Instance_HandleMessage |
135 }; | 146 }; |
136 | 147 |
137 // Module ---------------------------------------------------------------------- | 148 // Module ---------------------------------------------------------------------- |
138 | 149 |
139 Module::Module() : pp_module_(0), get_browser_interface_(NULL), core_(NULL) { | 150 Module::Module() : pp_module_(0), get_browser_interface_(NULL), core_(NULL) { |
140 } | 151 } |
141 | 152 |
142 Module::~Module() { | 153 Module::~Module() { |
143 delete core_; | 154 delete core_; |
144 core_ = NULL; | 155 core_ = NULL; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 const PPB_Core* core = reinterpret_cast<const PPB_Core*>(GetBrowserInterface( | 206 const PPB_Core* core = reinterpret_cast<const PPB_Core*>(GetBrowserInterface( |
196 PPB_CORE_INTERFACE)); | 207 PPB_CORE_INTERFACE)); |
197 if (!core) | 208 if (!core) |
198 return false; | 209 return false; |
199 core_ = new Core(core); | 210 core_ = new Core(core); |
200 | 211 |
201 return Init(); | 212 return Init(); |
202 } | 213 } |
203 | 214 |
204 } // namespace pp | 215 } // namespace pp |
OLD | NEW |