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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 scoped_array<const char*> array(new const char*[vector.size()]); | 301 scoped_array<const char*> array(new const char*[vector.size()]); |
302 for (size_t i = 0; i < vector.size(); ++i) | 302 for (size_t i = 0; i < vector.size(); ++i) |
303 array[i] = vector[i].c_str(); | 303 array[i] = vector[i].c_str(); |
304 return array.Pass(); | 304 return array.Pass(); |
305 } | 305 } |
306 | 306 |
307 } // namespace | 307 } // namespace |
308 | 308 |
309 // static | 309 // static |
310 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, | 310 PluginInstance* PluginInstance::Create(PluginDelegate* delegate, |
311 PluginModule* module) { | 311 PluginModule* module, |
| 312 WebPluginContainer* container, |
| 313 const GURL& plugin_url) { |
312 base::Callback<const void*(const char*)> get_plugin_interface_func = | 314 base::Callback<const void*(const char*)> get_plugin_interface_func = |
313 base::Bind(&PluginModule::GetPluginInterface, module); | 315 base::Bind(&PluginModule::GetPluginInterface, module); |
314 PPP_Instance_Combined* ppp_instance_combined = | 316 PPP_Instance_Combined* ppp_instance_combined = |
315 PPP_Instance_Combined::Create(get_plugin_interface_func); | 317 PPP_Instance_Combined::Create(get_plugin_interface_func); |
316 if (!ppp_instance_combined) | 318 if (!ppp_instance_combined) |
317 return NULL; | 319 return NULL; |
318 return new PluginInstance(delegate, module, ppp_instance_combined); | 320 return new PluginInstance(delegate, module, ppp_instance_combined, container, |
| 321 plugin_url); |
319 } | 322 } |
320 | 323 |
321 PluginInstance::GamepadImpl::GamepadImpl(PluginDelegate* delegate) | 324 PluginInstance::GamepadImpl::GamepadImpl(PluginDelegate* delegate) |
322 : Resource(::ppapi::Resource::Untracked()), | 325 : Resource(::ppapi::Resource::Untracked()), |
323 delegate_(delegate) { | 326 delegate_(delegate) { |
324 } | 327 } |
325 | 328 |
326 PPB_Gamepad_API* PluginInstance::GamepadImpl::AsPPB_Gamepad_API() { | 329 PPB_Gamepad_API* PluginInstance::GamepadImpl::AsPPB_Gamepad_API() { |
327 return this; | 330 return this; |
328 } | 331 } |
329 | 332 |
330 void PluginInstance::GamepadImpl::Sample(PP_GamepadsSampleData* data) { | 333 void PluginInstance::GamepadImpl::Sample(PP_GamepadsSampleData* data) { |
331 WebKit::WebGamepads webkit_data; | 334 WebKit::WebGamepads webkit_data; |
332 delegate_->SampleGamepads(&webkit_data); | 335 delegate_->SampleGamepads(&webkit_data); |
333 ConvertWebKitGamepadData( | 336 ConvertWebKitGamepadData( |
334 *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); | 337 *reinterpret_cast<const ::ppapi::WebKitGamepads*>(&webkit_data), data); |
335 } | 338 } |
336 | 339 |
337 PluginInstance::PluginInstance( | 340 PluginInstance::PluginInstance( |
338 PluginDelegate* delegate, | 341 PluginDelegate* delegate, |
339 PluginModule* module, | 342 PluginModule* module, |
340 ::ppapi::PPP_Instance_Combined* instance_interface) | 343 ::ppapi::PPP_Instance_Combined* instance_interface, |
| 344 WebPluginContainer* container, |
| 345 const GURL& plugin_url) |
341 : delegate_(delegate), | 346 : delegate_(delegate), |
342 module_(module), | 347 module_(module), |
343 instance_interface_(instance_interface), | 348 instance_interface_(instance_interface), |
344 pp_instance_(0), | 349 pp_instance_(0), |
345 container_(NULL), | 350 container_(container), |
| 351 plugin_url_(plugin_url), |
346 full_frame_(false), | 352 full_frame_(false), |
347 sent_initial_did_change_view_(false), | 353 sent_initial_did_change_view_(false), |
348 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 354 view_change_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
349 bound_graphics_2d_platform_(NULL), | 355 bound_graphics_2d_platform_(NULL), |
350 has_webkit_focus_(false), | 356 has_webkit_focus_(false), |
351 has_content_area_focus_(false), | 357 has_content_area_focus_(false), |
352 find_identifier_(-1), | 358 find_identifier_(-1), |
353 plugin_find_interface_(NULL), | 359 plugin_find_interface_(NULL), |
354 plugin_input_event_interface_(NULL), | 360 plugin_input_event_interface_(NULL), |
355 plugin_messaging_interface_(NULL), | 361 plugin_messaging_interface_(NULL), |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 // 3 : 3D content and GPU is not blacklisted | 559 // 3 : 3D content and GPU is not blacklisted |
554 // 4 : No 3D content and GPU is blacklisted on XP | 560 // 4 : No 3D content and GPU is blacklisted on XP |
555 // 5 : No 3D content and GPU is not blacklisted on XP | 561 // 5 : No 3D content and GPU is not blacklisted on XP |
556 // 6 : 3D content but GPU is blacklisted on XP | 562 // 6 : 3D content but GPU is blacklisted on XP |
557 // 7 : 3D content and GPU is not blacklisted on XP | 563 // 7 : 3D content and GPU is not blacklisted on XP |
558 UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", | 564 UMA_HISTOGRAM_ENUMERATION("Flash.UsesGPU", |
559 is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); | 565 is_xp * 4 + needs_gpu * 2 + prefs.is_webgl_supported, 8); |
560 #endif | 566 #endif |
561 } | 567 } |
562 | 568 |
563 bool PluginInstance::Initialize(WebPluginContainer* container, | 569 bool PluginInstance::Initialize(const std::vector<std::string>& arg_names, |
564 const std::vector<std::string>& arg_names, | |
565 const std::vector<std::string>& arg_values, | 570 const std::vector<std::string>& arg_values, |
566 const GURL& plugin_url, | |
567 bool full_frame) { | 571 bool full_frame) { |
568 container_ = container; | |
569 plugin_url_ = plugin_url; | |
570 full_frame_ = full_frame; | 572 full_frame_ = full_frame; |
571 | 573 |
572 UpdateTouchEventRequest(); | 574 UpdateTouchEventRequest(); |
573 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); | 575 container_->setWantsWheelEvents(IsAcceptingWheelEvents()); |
574 | 576 |
575 SetGPUHistogram(delegate_->GetPreferences(), arg_names, arg_values); | 577 SetGPUHistogram(delegate_->GetPreferences(), arg_names, arg_values); |
576 | 578 |
577 argn_ = arg_names; | 579 argn_ = arg_names; |
578 argv_ = arg_values; | 580 argv_ = arg_values; |
579 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_)); | 581 scoped_array<const char*> argn_array(StringVectorToArgArray(argn_)); |
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2123 return PP_TRUE; | 2125 return PP_TRUE; |
2124 } | 2126 } |
2125 | 2127 |
2126 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() { | 2128 ::ppapi::thunk::PPB_Flash_API* PluginInstance::GetFlashAPI() { |
2127 return &flash_impl_; | 2129 return &flash_impl_; |
2128 } | 2130 } |
2129 | 2131 |
2130 ::ppapi::Resource* PluginInstance::GetSingletonResource( | 2132 ::ppapi::Resource* PluginInstance::GetSingletonResource( |
2131 PP_Instance instance, | 2133 PP_Instance instance, |
2132 ::ppapi::SingletonResourceID id) { | 2134 ::ppapi::SingletonResourceID id) { |
2133 // Flash APIs aren't implemented in-process. | 2135 // Flash APIs and some others aren't implemented in-process. |
2134 switch (id) { | 2136 switch (id) { |
| 2137 case ::ppapi::BROKER_SINGLETON_ID: |
2135 case ::ppapi::FLASH_CLIPBOARD_SINGLETON_ID: | 2138 case ::ppapi::FLASH_CLIPBOARD_SINGLETON_ID: |
2136 case ::ppapi::FLASH_FILE_SINGLETON_ID: | 2139 case ::ppapi::FLASH_FILE_SINGLETON_ID: |
2137 case ::ppapi::FLASH_FULLSCREEN_SINGLETON_ID: | 2140 case ::ppapi::FLASH_FULLSCREEN_SINGLETON_ID: |
2138 case ::ppapi::FLASH_SINGLETON_ID: | 2141 case ::ppapi::FLASH_SINGLETON_ID: |
2139 NOTIMPLEMENTED(); | 2142 NOTIMPLEMENTED(); |
2140 return NULL; | 2143 return NULL; |
2141 case ::ppapi::GAMEPAD_SINGLETON_ID: | 2144 case ::ppapi::GAMEPAD_SINGLETON_ID: |
2142 return gamepad_impl_; | 2145 return gamepad_impl_; |
2143 } | 2146 } |
2144 | 2147 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2479 screen_size_for_fullscreen_ = gfx::Size(); | 2482 screen_size_for_fullscreen_ = gfx::Size(); |
2480 WebElement element = container_->element(); | 2483 WebElement element = container_->element(); |
2481 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2484 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2482 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2485 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2483 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2486 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2484 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2487 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2485 } | 2488 } |
2486 | 2489 |
2487 } // namespace ppapi | 2490 } // namespace ppapi |
2488 } // namespace webkit | 2491 } // namespace webkit |
OLD | NEW |