| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 #include "ui/gfx/codec/jpeg_codec.h" | 106 #include "ui/gfx/codec/jpeg_codec.h" |
| 107 #include "ui/gfx/gdi_util.h" | 107 #include "ui/gfx/gdi_util.h" |
| 108 #endif | 108 #endif |
| 109 | 109 |
| 110 using base::StringPrintf; | 110 using base::StringPrintf; |
| 111 using ppapi::InputEventData; | 111 using ppapi::InputEventData; |
| 112 using ppapi::PpapiGlobals; | 112 using ppapi::PpapiGlobals; |
| 113 using ppapi::PPB_InputEvent_Shared; | 113 using ppapi::PPB_InputEvent_Shared; |
| 114 using ppapi::PPB_View_Shared; | 114 using ppapi::PPB_View_Shared; |
| 115 using ppapi::PPP_Instance_Combined; | 115 using ppapi::PPP_Instance_Combined; |
| 116 using ppapi::Resource; |
| 116 using ppapi::ScopedPPResource; | 117 using ppapi::ScopedPPResource; |
| 117 using ppapi::StringVar; | 118 using ppapi::StringVar; |
| 118 using ppapi::TrackedCallback; | 119 using ppapi::TrackedCallback; |
| 119 using ppapi::thunk::EnterResourceNoLock; | 120 using ppapi::thunk::EnterResourceNoLock; |
| 120 using ppapi::thunk::PPB_Buffer_API; | 121 using ppapi::thunk::PPB_Buffer_API; |
| 122 using ppapi::thunk::PPB_Gamepad_API; |
| 121 using ppapi::thunk::PPB_Graphics2D_API; | 123 using ppapi::thunk::PPB_Graphics2D_API; |
| 122 using ppapi::thunk::PPB_Graphics3D_API; | 124 using ppapi::thunk::PPB_Graphics3D_API; |
| 123 using ppapi::thunk::PPB_ImageData_API; | 125 using ppapi::thunk::PPB_ImageData_API; |
| 124 using ppapi::Var; | 126 using ppapi::Var; |
| 125 using ppapi::ArrayBufferVar; | 127 using ppapi::ArrayBufferVar; |
| 126 using ppapi::ViewData; | 128 using ppapi::ViewData; |
| 127 using WebKit::WebBindings; | 129 using WebKit::WebBindings; |
| 128 using WebKit::WebCanvas; | 130 using WebKit::WebCanvas; |
| 129 using WebKit::WebCursorInfo; | 131 using WebKit::WebCursorInfo; |
| 130 using WebKit::WebDocument; | 132 using WebKit::WebDocument; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 base::Callback<const void*(const char*)> get_plugin_interface_func = | 313 base::Callback<const void*(const char*)> get_plugin_interface_func = |
| 312 base::Bind(&PluginModule::GetPluginInterface, module); | 314 base::Bind(&PluginModule::GetPluginInterface, module); |
| 313 PPP_Instance_Combined* ppp_instance_combined = | 315 PPP_Instance_Combined* ppp_instance_combined = |
| 314 PPP_Instance_Combined::Create(get_plugin_interface_func); | 316 PPP_Instance_Combined::Create(get_plugin_interface_func); |
| 315 if (!ppp_instance_combined) | 317 if (!ppp_instance_combined) |
| 316 return NULL; | 318 return NULL; |
| 317 return new PluginInstance(delegate, module, ppp_instance_combined); | 319 return new PluginInstance(delegate, module, ppp_instance_combined); |
| 318 } | 320 } |
| 319 | 321 |
| 320 PluginInstance::GamepadImpl::GamepadImpl(PluginDelegate* delegate) | 322 PluginInstance::GamepadImpl::GamepadImpl(PluginDelegate* delegate) |
| 321 : delegate_(delegate) { | 323 : Resource(::ppapi::Resource::Untracked()), |
| 324 delegate_(delegate) { |
| 325 } |
| 326 |
| 327 PPB_Gamepad_API* PluginInstance::GamepadImpl::AsPPB_Gamepad_API() { |
| 328 return this; |
| 322 } | 329 } |
| 323 | 330 |
| 324 void PluginInstance::GamepadImpl::Sample(PP_GamepadsSampleData* data) { | 331 void PluginInstance::GamepadImpl::Sample(PP_GamepadsSampleData* data) { |
| 325 WebKit::WebGamepads webkit_data; | 332 WebKit::WebGamepads webkit_data; |
| 326 delegate_->SampleGamepads(&webkit_data); | 333 delegate_->SampleGamepads(&webkit_data); |
| 327 ConvertWebKitGamepadData( | 334 ConvertWebKitGamepadData( |
| 328 *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); | 335 *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); |
| 329 } | 336 } |
| 330 | 337 |
| 331 PluginInstance::PluginInstance( | 338 PluginInstance::PluginInstance( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 348 plugin_messaging_interface_(NULL), | 355 plugin_messaging_interface_(NULL), |
| 349 plugin_mouse_lock_interface_(NULL), | 356 plugin_mouse_lock_interface_(NULL), |
| 350 plugin_pdf_interface_(NULL), | 357 plugin_pdf_interface_(NULL), |
| 351 plugin_private_interface_(NULL), | 358 plugin_private_interface_(NULL), |
| 352 plugin_selection_interface_(NULL), | 359 plugin_selection_interface_(NULL), |
| 353 plugin_textinput_interface_(NULL), | 360 plugin_textinput_interface_(NULL), |
| 354 plugin_zoom_interface_(NULL), | 361 plugin_zoom_interface_(NULL), |
| 355 checked_for_plugin_input_event_interface_(false), | 362 checked_for_plugin_input_event_interface_(false), |
| 356 checked_for_plugin_messaging_interface_(false), | 363 checked_for_plugin_messaging_interface_(false), |
| 357 checked_for_plugin_pdf_interface_(false), | 364 checked_for_plugin_pdf_interface_(false), |
| 358 gamepad_impl_(delegate), | 365 gamepad_impl_(new GamepadImpl(delegate)), |
| 359 plugin_print_interface_(NULL), | 366 plugin_print_interface_(NULL), |
| 360 plugin_graphics_3d_interface_(NULL), | 367 plugin_graphics_3d_interface_(NULL), |
| 361 always_on_top_(false), | 368 always_on_top_(false), |
| 362 fullscreen_container_(NULL), | 369 fullscreen_container_(NULL), |
| 363 flash_fullscreen_(false), | 370 flash_fullscreen_(false), |
| 364 desired_fullscreen_state_(false), | 371 desired_fullscreen_state_(false), |
| 365 message_channel_(NULL), | 372 message_channel_(NULL), |
| 366 sad_plugin_(NULL), | 373 sad_plugin_(NULL), |
| 367 input_event_mask_(0), | 374 input_event_mask_(0), |
| 368 filtered_input_event_mask_(0), | 375 filtered_input_event_mask_(0), |
| (...skipping 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { | 2117 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { |
| 2111 gfx::Size screen_size = delegate()->GetScreenSize(); | 2118 gfx::Size screen_size = delegate()->GetScreenSize(); |
| 2112 *size = PP_MakeSize(screen_size.width(), screen_size.height()); | 2119 *size = PP_MakeSize(screen_size.width(), screen_size.height()); |
| 2113 return PP_TRUE; | 2120 return PP_TRUE; |
| 2114 } | 2121 } |
| 2115 | 2122 |
| 2116 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() { | 2123 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() { |
| 2117 return &flash_impl_; | 2124 return &flash_impl_; |
| 2118 } | 2125 } |
| 2119 | 2126 |
| 2120 ::ppapi::thunk::PPB_Flash_Clipboard_API* | 2127 ::ppapi::Resource* PluginInstance::GetSingletonResource( |
| 2121 PluginInstance::GetFlashClipboardAPI(PP_Instance /*instance*/) { | 2128 PP_Instance instance, |
| 2122 NOTIMPLEMENTED(); | 2129 ::ppapi::SingletonResourceID id) { |
| 2130 // Flash APIs aren't implemented in-process. |
| 2131 switch (id) { |
| 2132 case ::ppapi::FLASH_SINGLETON_ID: |
| 2133 case ::ppapi::FLASH_CLIPBOARD_SINGLETON_ID: |
| 2134 NOTIMPLEMENTED(); |
| 2135 return NULL; |
| 2136 case ::ppapi::GAMEPAD_SINGLETON_ID: |
| 2137 return gamepad_impl_; |
| 2138 } |
| 2139 |
| 2140 NOTREACHED(); |
| 2123 return NULL; | 2141 return NULL; |
| 2124 } | 2142 } |
| 2125 | 2143 |
| 2126 ::ppapi::thunk::PPB_Flash_Functions_API* | |
| 2127 PluginInstance::GetFlashFunctionsAPI(PP_Instance /*instance*/) { | |
| 2128 NOTIMPLEMENTED(); | |
| 2129 return NULL; | |
| 2130 } | |
| 2131 | |
| 2132 ::ppapi::thunk::PPB_Gamepad_API* PluginInstance::GetGamepadAPI( | |
| 2133 PP_Instance /* instance */) { | |
| 2134 return &gamepad_impl_; | |
| 2135 } | |
| 2136 | |
| 2137 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, | 2144 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, |
| 2138 uint32_t event_classes) { | 2145 uint32_t event_classes) { |
| 2139 input_event_mask_ |= event_classes; | 2146 input_event_mask_ |= event_classes; |
| 2140 filtered_input_event_mask_ &= ~(event_classes); | 2147 filtered_input_event_mask_ &= ~(event_classes); |
| 2141 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) | 2148 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) |
| 2142 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents()); | 2149 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents()); |
| 2143 return ValidateRequestInputEvents(false, event_classes); | 2150 return ValidateRequestInputEvents(false, event_classes); |
| 2144 } | 2151 } |
| 2145 | 2152 |
| 2146 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, | 2153 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2470 screen_size_for_fullscreen_ = gfx::Size(); | 2477 screen_size_for_fullscreen_ = gfx::Size(); |
| 2471 WebElement element = container_->element(); | 2478 WebElement element = container_->element(); |
| 2472 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2479 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 2473 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2480 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 2474 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2481 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 2475 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2482 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 2476 } | 2483 } |
| 2477 | 2484 |
| 2478 } // namespace ppapi | 2485 } // namespace ppapi |
| 2479 } // namespace webkit | 2486 } // namespace webkit |
| OLD | NEW |