OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 "mojo/examples/pepper_container_app/plugin_instance.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "mojo/examples/pepper_container_app/graphics_3d_resource.h" |
| 9 #include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h" |
| 10 #include "ppapi/c/pp_errors.h" |
| 11 #include "ppapi/c/pp_var.h" |
| 12 #include "ppapi/c/ppp_graphics_3d.h" |
| 13 #include "ppapi/c/ppp_instance.h" |
| 14 #include "ppapi/shared_impl/ppb_view_shared.h" |
| 15 #include "ppapi/shared_impl/proxy_lock.h" |
| 16 #include "ppapi/shared_impl/tracked_callback.h" |
| 17 #include "ppapi/thunk/enter.h" |
| 18 #include "ppapi/thunk/ppb_graphics_3d_api.h" |
| 19 |
| 20 namespace mojo { |
| 21 namespace examples { |
| 22 |
| 23 PluginInstance::PluginInstance(scoped_refptr<PluginModule> plugin_module) |
| 24 : pp_instance_(0), |
| 25 plugin_module_(plugin_module) { |
| 26 pp_instance_ = MojoPpapiGlobals::Get()->AddInstance(this); |
| 27 } |
| 28 |
| 29 PluginInstance::~PluginInstance() { |
| 30 MojoPpapiGlobals::Get()->InstanceDeleted(pp_instance_); |
| 31 } |
| 32 |
| 33 bool PluginInstance::DidCreate() { |
| 34 ppapi::ProxyAutoUnlock unlock; |
| 35 const PPP_Instance_1_1* instance_interface = |
| 36 static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface( |
| 37 PPP_INSTANCE_INTERFACE_1_1)); |
| 38 return !!instance_interface->DidCreate(pp_instance(), 0, NULL, NULL); |
| 39 } |
| 40 |
| 41 void PluginInstance::DidDestroy() { |
| 42 ppapi::ProxyAutoUnlock unlock; |
| 43 const PPP_Instance_1_1* instance_interface = |
| 44 static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface( |
| 45 PPP_INSTANCE_INTERFACE_1_1)); |
| 46 instance_interface->DidDestroy(pp_instance()); |
| 47 } |
| 48 |
| 49 void PluginInstance::DidChangeView(const PP_Rect& bounds) { |
| 50 ppapi::ViewData view_data; |
| 51 view_data.rect = bounds; |
| 52 view_data.is_fullscreen = false; |
| 53 view_data.is_page_visible = true; |
| 54 view_data.clip_rect = bounds; |
| 55 view_data.device_scale = 1.0f; |
| 56 view_data.css_scale = 1.0f; |
| 57 |
| 58 ppapi::ScopedPPResource resource(ppapi::ScopedPPResource::PassRef(), |
| 59 (new ppapi::PPB_View_Shared( |
| 60 ppapi::OBJECT_IS_IMPL, pp_instance(), view_data))->GetReference()); |
| 61 { |
| 62 ppapi::ProxyAutoUnlock unlock; |
| 63 const PPP_Instance_1_1* instance_interface = |
| 64 static_cast<const PPP_Instance_1_1*>(plugin_module_->GetPluginInterface( |
| 65 PPP_INSTANCE_INTERFACE_1_1)); |
| 66 instance_interface->DidChangeView(pp_instance(), resource); |
| 67 } |
| 68 } |
| 69 |
| 70 void PluginInstance::Graphics3DContextLost() { |
| 71 ppapi::ProxyAutoUnlock unlock; |
| 72 const PPP_Graphics3D_1_0* graphic_3d_interface = |
| 73 static_cast<const PPP_Graphics3D_1_0*>(plugin_module_->GetPluginInterface( |
| 74 PPP_GRAPHICS_3D_INTERFACE_1_0)); |
| 75 // TODO(yzshen): Maybe we only need to notify for the bound graphics context? |
| 76 graphic_3d_interface->Graphics3DContextLost(pp_instance()); |
| 77 } |
| 78 |
| 79 bool PluginInstance::IsBoundGraphics(PP_Resource device) const { |
| 80 return device != 0 && device == bound_graphics_.get(); |
| 81 } |
| 82 |
| 83 PP_Bool PluginInstance::BindGraphics(PP_Instance instance, PP_Resource device) { |
| 84 if (bound_graphics_.get() == device) |
| 85 return PP_TRUE; |
| 86 |
| 87 ppapi::thunk::EnterResourceNoLock<ppapi::thunk::PPB_Graphics3D_API> |
| 88 enter(device, false); |
| 89 if (enter.failed()) |
| 90 return PP_FALSE; |
| 91 |
| 92 bound_graphics_ = device; |
| 93 static_cast<Graphics3DResource*>(enter.object())->BindGraphics(); |
| 94 |
| 95 return PP_TRUE; |
| 96 } |
| 97 |
| 98 PP_Bool PluginInstance::IsFullFrame(PP_Instance instance) { |
| 99 NOTIMPLEMENTED(); |
| 100 return PP_FALSE; |
| 101 } |
| 102 |
| 103 const ppapi::ViewData* PluginInstance::GetViewData(PP_Instance instance) { |
| 104 NOTIMPLEMENTED(); |
| 105 return NULL; |
| 106 } |
| 107 |
| 108 PP_Bool PluginInstance::FlashIsFullscreen(PP_Instance instance) { |
| 109 NOTIMPLEMENTED(); |
| 110 return PP_FALSE; |
| 111 } |
| 112 |
| 113 PP_Var PluginInstance::GetWindowObject(PP_Instance instance) { |
| 114 NOTIMPLEMENTED(); |
| 115 return PP_MakeUndefined(); |
| 116 } |
| 117 |
| 118 PP_Var PluginInstance::GetOwnerElementObject(PP_Instance instance) { |
| 119 NOTIMPLEMENTED(); |
| 120 return PP_MakeUndefined(); |
| 121 } |
| 122 |
| 123 PP_Var PluginInstance::ExecuteScript(PP_Instance instance, |
| 124 PP_Var script, |
| 125 PP_Var* exception) { |
| 126 NOTIMPLEMENTED(); |
| 127 return PP_MakeUndefined(); |
| 128 } |
| 129 |
| 130 uint32_t PluginInstance::GetAudioHardwareOutputSampleRate( |
| 131 PP_Instance instance) { |
| 132 NOTIMPLEMENTED(); |
| 133 return 0; |
| 134 } |
| 135 |
| 136 uint32_t PluginInstance::GetAudioHardwareOutputBufferSize( |
| 137 PP_Instance instance) { |
| 138 NOTIMPLEMENTED(); |
| 139 return 0; |
| 140 } |
| 141 |
| 142 PP_Var PluginInstance::GetDefaultCharSet(PP_Instance instance) { |
| 143 NOTIMPLEMENTED(); |
| 144 return PP_MakeUndefined(); |
| 145 } |
| 146 |
| 147 void PluginInstance::Log(PP_Instance instance, |
| 148 PP_LogLevel log_level, |
| 149 PP_Var value) { |
| 150 NOTIMPLEMENTED(); |
| 151 } |
| 152 |
| 153 void PluginInstance::LogWithSource(PP_Instance instance, |
| 154 PP_LogLevel log_level, |
| 155 PP_Var source, |
| 156 PP_Var value) { |
| 157 NOTIMPLEMENTED(); |
| 158 } |
| 159 |
| 160 void PluginInstance::SetPluginToHandleFindRequests(PP_Instance instance) { |
| 161 NOTIMPLEMENTED(); |
| 162 } |
| 163 |
| 164 void PluginInstance::NumberOfFindResultsChanged(PP_Instance instance, |
| 165 int32_t total, |
| 166 PP_Bool final_result) { |
| 167 NOTIMPLEMENTED(); |
| 168 } |
| 169 |
| 170 void PluginInstance::SelectedFindResultChanged(PP_Instance instance, |
| 171 int32_t index) { |
| 172 NOTIMPLEMENTED(); |
| 173 } |
| 174 |
| 175 PP_Bool PluginInstance::IsFullscreen(PP_Instance instance) { |
| 176 NOTIMPLEMENTED(); |
| 177 return PP_FALSE; |
| 178 } |
| 179 |
| 180 PP_Bool PluginInstance::SetFullscreen(PP_Instance instance, |
| 181 PP_Bool fullscreen) { |
| 182 NOTIMPLEMENTED(); |
| 183 return PP_FALSE; |
| 184 } |
| 185 |
| 186 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { |
| 187 NOTIMPLEMENTED(); |
| 188 return PP_FALSE; |
| 189 } |
| 190 |
| 191 ppapi::Resource* PluginInstance::GetSingletonResource( |
| 192 PP_Instance instance, |
| 193 ppapi::SingletonResourceID id) { |
| 194 NOTIMPLEMENTED(); |
| 195 return NULL; |
| 196 } |
| 197 |
| 198 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, |
| 199 uint32_t event_classes) { |
| 200 NOTIMPLEMENTED(); |
| 201 return PP_ERROR_FAILED; |
| 202 } |
| 203 |
| 204 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, |
| 205 uint32_t event_classes) { |
| 206 NOTIMPLEMENTED(); |
| 207 return PP_ERROR_FAILED; |
| 208 } |
| 209 |
| 210 void PluginInstance::ClearInputEventRequest(PP_Instance instance, |
| 211 uint32_t event_classes) { |
| 212 NOTIMPLEMENTED(); |
| 213 } |
| 214 |
| 215 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { |
| 216 NOTIMPLEMENTED(); |
| 217 } |
| 218 |
| 219 PP_Bool PluginInstance::SetCursor(PP_Instance instance, |
| 220 PP_MouseCursor_Type type, |
| 221 PP_Resource image, |
| 222 const PP_Point* hot_spot) { |
| 223 NOTIMPLEMENTED(); |
| 224 return PP_FALSE; |
| 225 } |
| 226 |
| 227 int32_t PluginInstance::LockMouse( |
| 228 PP_Instance instance, |
| 229 scoped_refptr<ppapi::TrackedCallback> callback) { |
| 230 NOTIMPLEMENTED(); |
| 231 return PP_ERROR_FAILED; |
| 232 } |
| 233 |
| 234 void PluginInstance::UnlockMouse(PP_Instance instance) { |
| 235 NOTIMPLEMENTED(); |
| 236 } |
| 237 |
| 238 void PluginInstance::SetTextInputType(PP_Instance instance, |
| 239 PP_TextInput_Type type) { |
| 240 NOTIMPLEMENTED(); |
| 241 } |
| 242 |
| 243 void PluginInstance::UpdateCaretPosition(PP_Instance instance, |
| 244 const PP_Rect& caret, |
| 245 const PP_Rect& bounding_box) { |
| 246 NOTIMPLEMENTED(); |
| 247 } |
| 248 |
| 249 void PluginInstance::CancelCompositionText(PP_Instance instance) { |
| 250 NOTIMPLEMENTED(); |
| 251 } |
| 252 |
| 253 void PluginInstance::SelectionChanged(PP_Instance instance) { |
| 254 NOTIMPLEMENTED(); |
| 255 } |
| 256 |
| 257 void PluginInstance::UpdateSurroundingText(PP_Instance instance, |
| 258 const char* text, |
| 259 uint32_t caret, |
| 260 uint32_t anchor) { |
| 261 NOTIMPLEMENTED(); |
| 262 } |
| 263 |
| 264 void PluginInstance::ZoomChanged(PP_Instance instance, double factor) { |
| 265 NOTIMPLEMENTED(); |
| 266 } |
| 267 |
| 268 void PluginInstance::ZoomLimitsChanged(PP_Instance instance, |
| 269 double minimum_factor, |
| 270 double maximum_factor) { |
| 271 NOTIMPLEMENTED(); |
| 272 } |
| 273 |
| 274 PP_Var PluginInstance::GetDocumentURL(PP_Instance instance, |
| 275 PP_URLComponents_Dev* components) { |
| 276 NOTIMPLEMENTED(); |
| 277 return PP_MakeUndefined(); |
| 278 } |
| 279 |
| 280 void PluginInstance::SessionCreated(PP_Instance instance, |
| 281 uint32_t session_id, |
| 282 PP_Var web_session_id) { |
| 283 NOTIMPLEMENTED(); |
| 284 } |
| 285 |
| 286 void PluginInstance::SessionMessage(PP_Instance instance, |
| 287 uint32_t session_id, |
| 288 PP_Var message, |
| 289 PP_Var destination_url) { |
| 290 NOTIMPLEMENTED(); |
| 291 } |
| 292 |
| 293 void PluginInstance::SessionReady(PP_Instance instance, uint32_t session_id) { |
| 294 NOTIMPLEMENTED(); |
| 295 } |
| 296 |
| 297 void PluginInstance::SessionClosed(PP_Instance instance, uint32_t session_id) { |
| 298 NOTIMPLEMENTED(); |
| 299 } |
| 300 |
| 301 void PluginInstance::SessionError(PP_Instance instance, |
| 302 uint32_t session_id, |
| 303 int32_t media_error, |
| 304 uint32_t system_code) { |
| 305 NOTIMPLEMENTED(); |
| 306 } |
| 307 |
| 308 void PluginInstance::DeliverBlock(PP_Instance instance, |
| 309 PP_Resource decrypted_block, |
| 310 const PP_DecryptedBlockInfo* block_info) { |
| 311 NOTIMPLEMENTED(); |
| 312 } |
| 313 |
| 314 void PluginInstance::DecoderInitializeDone(PP_Instance instance, |
| 315 PP_DecryptorStreamType decoder_type, |
| 316 uint32_t request_id, |
| 317 PP_Bool success) { |
| 318 NOTIMPLEMENTED(); |
| 319 } |
| 320 |
| 321 void PluginInstance::DecoderDeinitializeDone( |
| 322 PP_Instance instance, |
| 323 PP_DecryptorStreamType decoder_type, |
| 324 uint32_t request_id) { |
| 325 NOTIMPLEMENTED(); |
| 326 } |
| 327 |
| 328 void PluginInstance::DecoderResetDone(PP_Instance instance, |
| 329 PP_DecryptorStreamType decoder_type, |
| 330 uint32_t request_id) { |
| 331 NOTIMPLEMENTED(); |
| 332 } |
| 333 |
| 334 void PluginInstance::DeliverFrame(PP_Instance instance, |
| 335 PP_Resource decrypted_frame, |
| 336 const PP_DecryptedFrameInfo* frame_info) { |
| 337 NOTIMPLEMENTED(); |
| 338 } |
| 339 |
| 340 void PluginInstance::DeliverSamples(PP_Instance instance, |
| 341 PP_Resource audio_frames, |
| 342 const PP_DecryptedSampleInfo* sample_info) { |
| 343 NOTIMPLEMENTED(); |
| 344 } |
| 345 |
| 346 PP_Var PluginInstance::ResolveRelativeToDocument( |
| 347 PP_Instance instance, |
| 348 PP_Var relative, |
| 349 PP_URLComponents_Dev* components) { |
| 350 NOTIMPLEMENTED(); |
| 351 return PP_MakeUndefined(); |
| 352 } |
| 353 |
| 354 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { |
| 355 NOTIMPLEMENTED(); |
| 356 return PP_FALSE; |
| 357 } |
| 358 |
| 359 PP_Bool PluginInstance::DocumentCanAccessDocument(PP_Instance instance, |
| 360 PP_Instance target) { |
| 361 NOTIMPLEMENTED(); |
| 362 return PP_FALSE; |
| 363 } |
| 364 |
| 365 PP_Var PluginInstance::GetPluginInstanceURL(PP_Instance instance, |
| 366 PP_URLComponents_Dev* components) { |
| 367 NOTIMPLEMENTED(); |
| 368 return PP_MakeUndefined(); |
| 369 } |
| 370 |
| 371 PP_Var PluginInstance::GetPluginReferrerURL(PP_Instance instance, |
| 372 PP_URLComponents_Dev* components) { |
| 373 NOTIMPLEMENTED(); |
| 374 return PP_MakeUndefined(); |
| 375 } |
| 376 |
| 377 } // namespace examples |
| 378 } // namespace mojo |
OLD | NEW |