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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 PluginModule* module, | 193 PluginModule* module, |
194 const void* ppp_instance_if_0_5) { | 194 const void* ppp_instance_if_0_5) { |
195 const PPP_Instance_0_5* interface = | 195 const PPP_Instance_0_5* interface = |
196 static_cast<const PPP_Instance_0_5*>(ppp_instance_if_0_5); | 196 static_cast<const PPP_Instance_0_5*>(ppp_instance_if_0_5); |
197 return new PluginInstance( | 197 return new PluginInstance( |
198 delegate, | 198 delegate, |
199 module, | 199 module, |
200 new ::ppapi::PPP_Instance_Combined(*interface)); | 200 new ::ppapi::PPP_Instance_Combined(*interface)); |
201 } | 201 } |
202 | 202 |
203 // static | |
204 PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate, | |
205 PluginModule* module, | |
206 const void* ppp_instance_if_1_0) { | |
207 const PPP_Instance_1_0* interface = | |
208 static_cast<const PPP_Instance_1_0*>(ppp_instance_if_1_0); | |
209 return new PluginInstance( | |
210 delegate, | |
211 module, | |
212 new ::ppapi::PPP_Instance_Combined(*interface)); | |
213 } | |
214 | |
203 PluginInstance::PluginInstance( | 215 PluginInstance::PluginInstance( |
204 PluginDelegate* delegate, | 216 PluginDelegate* delegate, |
205 PluginModule* module, | 217 PluginModule* module, |
206 ::ppapi::PPP_Instance_Combined* instance_interface) | 218 ::ppapi::PPP_Instance_Combined* instance_interface) |
207 : delegate_(delegate), | 219 : delegate_(delegate), |
208 module_(module), | 220 module_(module), |
209 instance_interface_(instance_interface), | 221 instance_interface_(instance_interface), |
210 pp_instance_(0), | 222 pp_instance_(0), |
211 container_(NULL), | 223 container_(NULL), |
212 full_frame_(false), | 224 full_frame_(false), |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 | 473 |
462 rv |= PPBoolToBool(plugin_input_event_interface_->HandleInputEvent( | 474 rv |= PPBoolToBool(plugin_input_event_interface_->HandleInputEvent( |
463 pp_instance(), event_resource->GetReference())); | 475 pp_instance(), event_resource->GetReference())); |
464 | 476 |
465 // Release the reference we took above. | 477 // Release the reference we took above. |
466 tracker->UnrefResource(resource); | 478 tracker->UnrefResource(resource); |
467 } | 479 } |
468 } | 480 } |
469 } | 481 } |
470 | 482 |
471 // For compatibility, also send all input events through the old interface. | 483 // For compatibility, also send all input events through the old interface, |
484 // if it exists. | |
472 // TODO(brettw) remove this. | 485 // TODO(brettw) remove this. |
473 std::vector<PP_InputEvent> pp_events; | 486 if (instance_interface_->HandleInputEvent_0_5) { |
474 CreatePPEvent(event, &pp_events); | 487 std::vector<PP_InputEvent> pp_events; |
488 CreatePPEvent(event, &pp_events); | |
475 | 489 |
476 // Each input event may generate more than one PP_InputEvent. | 490 // Each input event may generate more than one PP_InputEvent. |
477 for (size_t i = 0; i < pp_events.size(); i++) { | 491 for (size_t i = 0; i < pp_events.size(); i++) { |
478 rv |= PPBoolToBool(instance_interface_->HandleInputEvent(pp_instance(), | 492 rv |= PPBoolToBool( |
brettw
2011/07/20 04:18:48
This should be PP_ToBool now.
| |
479 &pp_events[i])); | 493 instance_interface_->HandleInputEvent_0_5(pp_instance(), |
494 &pp_events[i])); | |
495 } | |
480 } | 496 } |
481 | 497 |
482 if (cursor_.get()) | 498 if (cursor_.get()) |
483 *cursor_info = *cursor_; | 499 *cursor_info = *cursor_; |
484 return rv; | 500 return rv; |
485 } | 501 } |
486 | 502 |
487 void PluginInstance::HandleMessage(PP_Var message) { | 503 void PluginInstance::HandleMessage(PP_Var message) { |
488 // Keep a reference on the stack. See NOTE above. | 504 // Keep a reference on the stack. See NOTE above. |
489 scoped_refptr<PluginInstance> ref(this); | 505 scoped_refptr<PluginInstance> ref(this); |
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 } | 1586 } |
1571 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); | 1587 delegate()->ZoomLimitsChanged(minimum_factor, maximium_factor); |
1572 } | 1588 } |
1573 | 1589 |
1574 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { | 1590 void PluginInstance::PostMessage(PP_Instance instance, PP_Var message) { |
1575 message_channel_->PostMessageToJavaScript(message); | 1591 message_channel_->PostMessageToJavaScript(message); |
1576 } | 1592 } |
1577 | 1593 |
1578 } // namespace ppapi | 1594 } // namespace ppapi |
1579 } // namespace webkit | 1595 } // namespace webkit |
OLD | NEW |