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 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { | 2124 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { |
2118 gfx::Size screen_size = delegate()->GetScreenSize(); | 2125 gfx::Size screen_size = delegate()->GetScreenSize(); |
2119 *size = PP_MakeSize(screen_size.width(), screen_size.height()); | 2126 *size = PP_MakeSize(screen_size.width(), screen_size.height()); |
2120 return PP_TRUE; | 2127 return PP_TRUE; |
2121 } | 2128 } |
2122 | 2129 |
2123 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() { | 2130 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() { |
2124 return &flash_impl_; | 2131 return &flash_impl_; |
2125 } | 2132 } |
2126 | 2133 |
2127 ::ppapi::thunk::PPB_Flash_Clipboard_API* | 2134 ::ppapi::Resource* PluginInstance::GetSingletonResource( |
2128 PluginInstance::GetFlashClipboardAPI(PP_Instance /*instance*/) { | 2135 PP_Instance instance, |
2129 NOTIMPLEMENTED(); | 2136 ::ppapi::SingletonResourceID id) { |
| 2137 // Flash APIs aren't implemented in-process. |
| 2138 switch (id) { |
| 2139 case ::ppapi::FLASH_SINGLETON_ID: |
| 2140 case ::ppapi::FLASH_CLIPBOARD_SINGLETON_ID: |
| 2141 NOTIMPLEMENTED(); |
| 2142 return NULL; |
| 2143 case ::ppapi::GAMEPAD_SINGLETON_ID: |
| 2144 return gamepad_impl_; |
| 2145 } |
| 2146 |
| 2147 NOTREACHED(); |
2130 return NULL; | 2148 return NULL; |
2131 } | 2149 } |
2132 | 2150 |
2133 ::ppapi::thunk::PPB_Flash_Functions_API* | |
2134 PluginInstance::GetFlashFunctionsAPI(PP_Instance /*instance*/) { | |
2135 NOTIMPLEMENTED(); | |
2136 return NULL; | |
2137 } | |
2138 | |
2139 ::ppapi::thunk::PPB_Gamepad_API* PluginInstance::GetGamepadAPI( | |
2140 PP_Instance /* instance */) { | |
2141 return &gamepad_impl_; | |
2142 } | |
2143 | |
2144 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, | 2151 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, |
2145 uint32_t event_classes) { | 2152 uint32_t event_classes) { |
2146 input_event_mask_ |= event_classes; | 2153 input_event_mask_ |= event_classes; |
2147 filtered_input_event_mask_ &= ~(event_classes); | 2154 filtered_input_event_mask_ &= ~(event_classes); |
2148 RequestInputEventsHelper(event_classes); | 2155 RequestInputEventsHelper(event_classes); |
2149 return ValidateRequestInputEvents(false, event_classes); | 2156 return ValidateRequestInputEvents(false, event_classes); |
2150 } | 2157 } |
2151 | 2158 |
2152 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, | 2159 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, |
2153 uint32_t event_classes) { | 2160 uint32_t event_classes) { |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2474 screen_size_for_fullscreen_ = gfx::Size(); | 2481 screen_size_for_fullscreen_ = gfx::Size(); |
2475 WebElement element = container_->element(); | 2482 WebElement element = container_->element(); |
2476 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2483 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2477 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2484 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2478 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2485 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2479 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2486 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2480 } | 2487 } |
2481 | 2488 |
2482 } // namespace ppapi | 2489 } // namespace ppapi |
2483 } // namespace webkit | 2490 } // namespace webkit |
OLD | NEW |