| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 PluginModule* module, | 191 PluginModule* module, |
| 192 const void* ppp_instance_if_0_5) { | 192 const void* ppp_instance_if_0_5) { |
| 193 const PPP_Instance_0_5* interface = | 193 const PPP_Instance_0_5* interface = |
| 194 static_cast<const PPP_Instance_0_5*>(ppp_instance_if_0_5); | 194 static_cast<const PPP_Instance_0_5*>(ppp_instance_if_0_5); |
| 195 return new PluginInstance( | 195 return new PluginInstance( |
| 196 delegate, | 196 delegate, |
| 197 module, | 197 module, |
| 198 new ::ppapi::PPP_Instance_Combined(*interface)); | 198 new ::ppapi::PPP_Instance_Combined(*interface)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 // static | |
| 202 PluginInstance* PluginInstance::Create0_4(PluginDelegate* delegate, | |
| 203 PluginModule* module, | |
| 204 const void* ppp_instance_if_0_4) { | |
| 205 const PPP_Instance_0_4* interface = | |
| 206 static_cast<const PPP_Instance_0_4*>(ppp_instance_if_0_4); | |
| 207 return new PluginInstance( | |
| 208 delegate, | |
| 209 module, | |
| 210 new ::ppapi::PPP_Instance_Combined(*interface)); | |
| 211 } | |
| 212 | |
| 213 PluginInstance::PluginInstance( | 201 PluginInstance::PluginInstance( |
| 214 PluginDelegate* delegate, | 202 PluginDelegate* delegate, |
| 215 PluginModule* module, | 203 PluginModule* module, |
| 216 ::ppapi::PPP_Instance_Combined* instance_interface) | 204 ::ppapi::PPP_Instance_Combined* instance_interface) |
| 217 : delegate_(delegate), | 205 : delegate_(delegate), |
| 218 module_(module), | 206 module_(module), |
| 219 instance_interface_(instance_interface), | 207 instance_interface_(instance_interface), |
| 220 pp_instance_(0), | 208 pp_instance_(0), |
| 221 container_(NULL), | 209 container_(NULL), |
| 222 full_frame_(false), | 210 full_frame_(false), |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 scoped_refptr<PluginInstance> ref(this); | 483 scoped_refptr<PluginInstance> ref(this); |
| 496 if (!LoadMessagingInterface()) | 484 if (!LoadMessagingInterface()) |
| 497 return; | 485 return; |
| 498 plugin_messaging_interface_->HandleMessage(pp_instance(), message); | 486 plugin_messaging_interface_->HandleMessage(pp_instance(), message); |
| 499 } | 487 } |
| 500 | 488 |
| 501 PP_Var PluginInstance::GetInstanceObject() { | 489 PP_Var PluginInstance::GetInstanceObject() { |
| 502 // Keep a reference on the stack. See NOTE above. | 490 // Keep a reference on the stack. See NOTE above. |
| 503 scoped_refptr<PluginInstance> ref(this); | 491 scoped_refptr<PluginInstance> ref(this); |
| 504 | 492 |
| 505 // Try the private interface first. If it is not supported, we fall back to | 493 // If the plugin supports the private instance interface, try to retrieve its |
| 506 // looking in the older version of the PPP_Instance interface for | 494 // instance object. |
| 507 // GetInstanceObject. If all that fails, return an undefined Var. | |
| 508 // TODO(dmichael): Remove support for PPP_Instance.GetInstanceObject | |
| 509 if (LoadPrivateInterface()) | 495 if (LoadPrivateInterface()) |
| 510 return plugin_private_interface_->GetInstanceObject(pp_instance()); | 496 return plugin_private_interface_->GetInstanceObject(pp_instance()); |
| 511 else if (instance_interface_->GetInstanceObject_0_4) | |
| 512 return instance_interface_->GetInstanceObject_0_4(pp_instance()); | |
| 513 return PP_MakeUndefined(); | 497 return PP_MakeUndefined(); |
| 514 } | 498 } |
| 515 | 499 |
| 516 void PluginInstance::ViewChanged(const gfx::Rect& position, | 500 void PluginInstance::ViewChanged(const gfx::Rect& position, |
| 517 const gfx::Rect& clip) { | 501 const gfx::Rect& clip) { |
| 518 fullscreen_ = (fullscreen_container_ != NULL); | 502 fullscreen_ = (fullscreen_container_ != NULL); |
| 519 position_ = position; | 503 position_ = position; |
| 520 | 504 |
| 521 if (clip.IsEmpty()) { | 505 if (clip.IsEmpty()) { |
| 522 // WebKit can give weird (x,y) positions for empty clip rects (since the | 506 // WebKit can give weird (x,y) positions for empty clip rects (since the |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 } | 1537 } |
| 1554 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); | 1538 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); |
| 1555 } | 1539 } |
| 1556 | 1540 |
| 1557 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { | 1541 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { |
| 1558 message_channel_->PostMessageToJavaScript(message); | 1542 message_channel_->PostMessageToJavaScript(message); |
| 1559 } | 1543 } |
| 1560 | 1544 |
| 1561 } // namespace ppapi | 1545 } // namespace ppapi |
| 1562 } // namespace webkit | 1546 } // namespace webkit |
| OLD | NEW |