Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: webkit/plugins/ppapi/ppapi_plugin_instance.cc

Issue 10824272: Add a skeleton gamepad resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 PluginModule* module) { 326 PluginModule* module) {
327 base::Callback<const void*(const char*)> get_plugin_interface_func = 327 base::Callback<const void*(const char*)> get_plugin_interface_func =
328 base::Bind(&PluginModule::GetPluginInterface, module); 328 base::Bind(&PluginModule::GetPluginInterface, module);
329 PPP_Instance_Combined* ppp_instance_combined = 329 PPP_Instance_Combined* ppp_instance_combined =
330 PPP_Instance_Combined::Create(get_plugin_interface_func); 330 PPP_Instance_Combined::Create(get_plugin_interface_func);
331 if (!ppp_instance_combined) 331 if (!ppp_instance_combined)
332 return NULL; 332 return NULL;
333 return new PluginInstance(delegate, module, ppp_instance_combined); 333 return new PluginInstance(delegate, module, ppp_instance_combined);
334 } 334 }
335 335
336 PluginInstance::GamepadImpl::GamepadImpl(PluginDelegate* delegate)
337 : delegate_(delegate) {
338 }
339
340 void PluginInstance::GamepadImpl::Sample(PP_GamepadsSampleData* data) {
341 WebKit::WebGamepads webkit_data;
342 delegate_->SampleGamepads(&webkit_data);
343 ConvertWebKitGamepadData(webkit_data, data);
344 }
345
336 PluginInstance::PluginInstance( 346 PluginInstance::PluginInstance(
337 PluginDelegate* delegate, 347 PluginDelegate* delegate,
338 PluginModule* module, 348 PluginModule* module,
339 ::ppapi::PPP_Instance_Combined* instance_interface) 349 ::ppapi::PPP_Instance_Combined* instance_interface)
340 : delegate_(delegate), 350 : delegate_(delegate),
341 module_(module), 351 module_(module),
342 instance_interface_(instance_interface), 352 instance_interface_(instance_interface),
343 pp_instance_(0), 353 pp_instance_(0),
344 container_(NULL), 354 container_(NULL),
345 full_frame_(false), 355 full_frame_(false),
346 sent_initial_did_change_view_(false), 356 sent_initial_did_change_view_(false),
347 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 357 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
348 has_webkit_focus_(false), 358 has_webkit_focus_(false),
349 has_content_area_focus_(false), 359 has_content_area_focus_(false),
350 find_identifier_(-1), 360 find_identifier_(-1),
351 plugin_decryption_interface_(NULL), 361 plugin_decryption_interface_(NULL),
352 plugin_find_interface_(NULL), 362 plugin_find_interface_(NULL),
353 plugin_input_event_interface_(NULL), 363 plugin_input_event_interface_(NULL),
354 plugin_messaging_interface_(NULL), 364 plugin_messaging_interface_(NULL),
355 plugin_mouse_lock_interface_(NULL), 365 plugin_mouse_lock_interface_(NULL),
356 plugin_pdf_interface_(NULL), 366 plugin_pdf_interface_(NULL),
357 plugin_private_interface_(NULL), 367 plugin_private_interface_(NULL),
358 plugin_selection_interface_(NULL), 368 plugin_selection_interface_(NULL),
359 plugin_textinput_interface_(NULL), 369 plugin_textinput_interface_(NULL),
360 plugin_zoom_interface_(NULL), 370 plugin_zoom_interface_(NULL),
361 checked_for_plugin_input_event_interface_(false), 371 checked_for_plugin_input_event_interface_(false),
362 checked_for_plugin_messaging_interface_(false), 372 checked_for_plugin_messaging_interface_(false),
373 gamepad_impl_(delegate),
363 plugin_print_interface_(NULL), 374 plugin_print_interface_(NULL),
364 plugin_graphics_3d_interface_(NULL), 375 plugin_graphics_3d_interface_(NULL),
365 always_on_top_(false), 376 always_on_top_(false),
366 fullscreen_container_(NULL), 377 fullscreen_container_(NULL),
367 flash_fullscreen_(false), 378 flash_fullscreen_(false),
368 desired_fullscreen_state_(false), 379 desired_fullscreen_state_(false),
369 message_channel_(NULL), 380 message_channel_(NULL),
370 sad_plugin_(NULL), 381 sad_plugin_(NULL),
371 input_event_mask_(0), 382 input_event_mask_(0),
372 filtered_input_event_mask_(0), 383 filtered_input_event_mask_(0),
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 if (!web_view) { 1555 if (!web_view) {
1545 NOTREACHED(); 1556 NOTREACHED();
1546 return false; 1557 return false;
1547 } 1558 }
1548 #else 1559 #else
1549 //FIXME 1560 //FIXME
1550 return container_->isRectTopmost(rect); 1561 return container_->isRectTopmost(rect);
1551 #endif 1562 #endif
1552 } 1563 }
1553 1564
1554 void PluginInstance::SampleGamepads(PP_Instance instance,
1555 PP_GamepadsSampleData* data) {
1556 WebKit::WebGamepads webkit_data;
1557 delegate()->SampleGamepads(&webkit_data);
1558 ConvertWebKitGamepadData(webkit_data, data);
1559 }
1560
1561 bool PluginInstance::IsViewAccelerated() { 1565 bool PluginInstance::IsViewAccelerated() {
1562 if (!container_) 1566 if (!container_)
1563 return false; 1567 return false;
1564 1568
1565 WebDocument document = container_->element().document(); 1569 WebDocument document = container_->element().document();
1566 WebFrame* frame = document.frame(); 1570 WebFrame* frame = document.frame();
1567 if (!frame) 1571 if (!frame)
1568 return false; 1572 return false;
1569 WebView* view = frame->view(); 1573 WebView* view = frame->view();
1570 if (!view) 1574 if (!view)
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2078 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) { 2082 PP_Bool PluginInstance::GetScreenSize(PP_Instance instance, PP_Size* size) {
2079 gfx::Size screen_size = delegate()->GetScreenSize(); 2083 gfx::Size screen_size = delegate()->GetScreenSize();
2080 *size = PP_MakeSize(screen_size.width(), screen_size.height()); 2084 *size = PP_MakeSize(screen_size.width(), screen_size.height());
2081 return PP_TRUE; 2085 return PP_TRUE;
2082 } 2086 }
2083 2087
2084 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() { 2088 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() {
2085 return &flash_impl_; 2089 return &flash_impl_;
2086 } 2090 }
2087 2091
2092 ::ppapi::thunk::PPB_Gamepad_API* PluginInstance::GetGamepadAPI(
2093 PP_Instance /* instance */) {
2094 return &gamepad_impl_;
2095 }
2096
2088 int32_t PluginInstance::RequestInputEvents(PP_Instance instance, 2097 int32_t PluginInstance::RequestInputEvents(PP_Instance instance,
2089 uint32_t event_classes) { 2098 uint32_t event_classes) {
2090 input_event_mask_ |= event_classes; 2099 input_event_mask_ |= event_classes;
2091 filtered_input_event_mask_ &= ~(event_classes); 2100 filtered_input_event_mask_ &= ~(event_classes);
2092 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH) 2101 if (event_classes & PP_INPUTEVENT_CLASS_TOUCH)
2093 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents()); 2102 container_->setIsAcceptingTouchEvents(IsAcceptingTouchEvents());
2094 return ValidateRequestInputEvents(false, event_classes); 2103 return ValidateRequestInputEvents(false, event_classes);
2095 } 2104 }
2096 2105
2097 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance, 2106 int32_t PluginInstance::RequestFilteringInputEvents(PP_Instance instance,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 screen_size_for_fullscreen_ = gfx::Size(); 2433 screen_size_for_fullscreen_ = gfx::Size();
2425 WebElement element = container_->element(); 2434 WebElement element = container_->element();
2426 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); 2435 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_);
2427 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); 2436 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_);
2428 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); 2437 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_);
2429 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); 2438 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_);
2430 } 2439 }
2431 2440
2432 } // namespace ppapi 2441 } // namespace ppapi
2433 } // namespace webkit 2442 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698